0002-python3-struct-packed-C-strings-are-Python-bytes-311.patch
src/authentic2/crypto.py | ||
---|---|---|
64 | 64 |
def add_padding(msg, block_size): |
65 | 65 |
'''Pad message with zero bytes to match block_size''' |
66 | 66 |
pad_length = block_size - (len(msg) + 2) % block_size |
67 |
padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, '\0' * pad_length) |
|
67 |
padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, b'\0' * pad_length)
|
|
68 | 68 |
assert len(padded) % block_size == 0 |
69 | 69 |
return padded |
70 | 70 | |
... | ... | |
113 | 113 | |
114 | 114 |
hmac = prf(key, crypted)[:hmac_size] |
115 | 115 | |
116 |
raw = struct.pack('<2sBH', 'a2', mode, count) + crypted + hmac |
|
116 |
raw = struct.pack('<2sBH', b'a2', mode, count) + crypted + hmac
|
|
117 | 117 |
return base64url_encode(raw) |
118 | 118 | |
119 | 119 | |
120 |
- |