python3: struct-packed C strings are Python bytes (#31171)
This commit is contained in:
parent
a6dba11961
commit
c1c8ca9182
|
@ -87,7 +87,7 @@ def aes_base64_decrypt(key, payload, raise_on_error=True):
|
|||
def add_padding(msg, block_size):
|
||||
'''Pad message with zero bytes to match block_size'''
|
||||
pad_length = block_size - (len(msg) + 2) % block_size
|
||||
padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, '\0' * pad_length)
|
||||
padded = struct.pack('<h%ds%ds' % (len(msg), pad_length), len(msg), msg, b'\0' * pad_length)
|
||||
assert len(padded) % block_size == 0
|
||||
return padded
|
||||
|
||||
|
@ -139,7 +139,7 @@ def aes_base64url_deterministic_encrypt(key, data, salt, hash_name='sha256', cou
|
|||
|
||||
hmac = prf(key, crypted)[:hmac_size]
|
||||
|
||||
raw = struct.pack('<2sBH', 'a2', mode, count) + crypted + hmac
|
||||
raw = struct.pack('<2sBH', b'a2', mode, count) + crypted + hmac
|
||||
return base64url_encode(raw)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue