Use length in bytes...

pull/20/head
tux 2017-09-01 02:12:19 -06:00
parent ce5805a468
commit 1acf1c3034
1 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ class KMAC_256(object):
# TODO If performance is needed, this could be optimized a bit...
# TODO Would be preferable to follow NIST and use cSHAKE.
def __init__(self):
self.LENGTH = 256
self.LENGTH_BYTES = 32
self.BLOCK_SIZE_BYTES = 136
def _bytepad(self, x, w):
@ -28,7 +28,7 @@ class KMAC_256(object):
kmac = hashlib.shake_256()
new_X = (self._bytepad(key, self.BLOCK_SIZE_BYTES)
+ message
+ (self.LENGTH).to_bytes(2, byteorder='big'))
+ (self.LENGTH_BYTES).to_bytes(2, byteorder='big'))
kmac.update(new_X)
return kmac.digest(self.LENGTH)
return kmac.digest(self.LENGTH_BYTES)