mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix bug in python aes-gcm-siv reference implementation
This commit is contained in:
parent
eda60a5d9c
commit
77d3f8a646
1 changed files with 9 additions and 7 deletions
|
|
@ -121,13 +121,15 @@ def b2i(s):
|
|||
|
||||
|
||||
def i2b(i):
|
||||
if i == 0:
|
||||
return b'\x00'*16
|
||||
s = b''
|
||||
while i:
|
||||
s += chr(i & 0xff) if six.PY2 else bytes([i & 0xff])
|
||||
i >>= 8
|
||||
return bytes(s)
|
||||
return i.to_bytes(16, 'little')
|
||||
# original implementation below -- if the leading bytes are '00', it will truncate and return a 15-long array, instead of 16-long, which is incorrect.
|
||||
#if i == 0:
|
||||
# return b'\x00'*16
|
||||
#s = b''
|
||||
#while i:
|
||||
# s += chr(i & 0xff) if six.PY2 else bytes([i & 0xff])
|
||||
# i >>= 8
|
||||
#return bytes(s)
|
||||
|
||||
|
||||
def s2i(s):
|
||||
|
|
|
|||
Loading…
Reference in a new issue