Skip to content

Commit cf9540d

Browse files
author
Martijn de Milliano
committed
AES-SIV: correct error in key size check
Adjust the code to match the key sizes in the RFC. Update test to cover this.
1 parent e9ebda0 commit cf9540d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tests/test_ciphers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,14 @@ def test_ed448_sign_verify(ed448_private, ed448_public):
734734

735735

736736
@pytest.mark.skipif(not _lib.AES_SIV_ENABLED, reason="AES-SIV not enabled")
737-
def test_aessiv_encrypt_decrypt():
738-
key = random.randbytes(32)
737+
@pytest.mark.parametrize("key_size", [256 // 8, 384 // 8, 512 // 8])
738+
def test_aessiv_encrypt_decrypt(key_size):
739+
"""
740+
Test that data encrypted by AES-SIV can be decrypted.
741+
742+
:param key_size: AES-SIV key size in bytes.
743+
"""
744+
key = random.randbytes(key_size)
739745
aessiv = AesSiv(key)
740746
associated_data = random.randbytes(16)
741747
nonce = random.randbytes(12)

wolfcrypt/ciphers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ class AesSiv(object):
280280
"""
281281
AES-SIV (Synthetic Initialization Vector) implementation as described in RFC 5297.
282282
"""
283-
_key_sizes = [16, 24, 32]
283+
# RFC 5297 defines key sizes of 256-, 384-, or 512 bits.
284+
_key_sizes = [32, 48, 64]
284285
block_size = 16
285286

286287
def __init__(self, key):

0 commit comments

Comments
 (0)