jonesmarvin8 41f34f4ff4 fixes
2026-04-26 20:27:22 -04:00

10 lines
330 B
Python

def iso7816_pad(data: bytes, block_size: int) -> bytes:
pad_len = block_size - (len(data) % block_size)
return data + b'\x80' + b'\x00' * (pad_len - 1)
def iso7816_unpad(padded: bytes) -> bytes:
if b'\x80' not in padded:
raise ValueError("Invalid ISO7816 padding")
return padded[:padded.rindex(b'\x80')]