mirror of https://github.com/nucypher/nucypher.git
Use length in bytes...
parent
ce5805a468
commit
1acf1c3034
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue