mirror of
https://github.com/Legrandin/pycryptodome.git
synced 2025-12-08 05:19:46 +00:00
Added Wycheproof tests for AES-SIV
This commit is contained in:
parent
8f6b6757c6
commit
5b326e48bc
6 changed files with 4309 additions and 127 deletions
|
|
@ -189,7 +189,10 @@ class _S2V(object):
|
|||
self._key = _copy_bytes(None, None, key)
|
||||
self._ciphermod = ciphermod
|
||||
self._last_string = self._cache = b'\x00' * ciphermod.block_size
|
||||
|
||||
# Max number of update() call we can process
|
||||
self._n_updates = ciphermod.block_size * 8 - 1
|
||||
|
||||
if cipher_params is None:
|
||||
self._cipher_params = {}
|
||||
else:
|
||||
|
|
@ -224,12 +227,8 @@ class _S2V(object):
|
|||
item : byte string
|
||||
The next component of the vector.
|
||||
:Raise TypeError: when the limit on the number of components has been reached.
|
||||
:Raise ValueError: when the component is empty
|
||||
"""
|
||||
|
||||
if not item:
|
||||
raise ValueError("A component cannot be empty")
|
||||
|
||||
if self._n_updates == 0:
|
||||
raise TypeError("Too many components passed to S2V")
|
||||
self._n_updates -= 1
|
||||
|
|
@ -248,8 +247,10 @@ class _S2V(object):
|
|||
"""
|
||||
|
||||
if len(self._last_string) >= 16:
|
||||
# xorend
|
||||
final = self._last_string[:-16] + strxor(self._last_string[-16:], self._cache)
|
||||
else:
|
||||
# zero-pad & xor
|
||||
padded = (self._last_string + b'\x80' + b'\x00' * 15)[:16]
|
||||
final = strxor(padded, self._double(self._cache))
|
||||
mac = CMAC.new(self._key,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue