aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils.py20
-rw-r--r--tests/utils.py10
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 4dede2e7..0d71174b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -347,9 +347,29 @@ def test_load_nist_gcm_vectors():
AAD =
Tag = 1665b0f1a0b456e1664cfd3de08ccd
PT =
+
+ [Keylen = 128]
+ [IVlen = 8]
+ [PTlen = 104]
+ [AADlen = 0]
+ [Taglen = 128]
+
+ Count = 0
+ Key = 58fab7632bcf10d2bcee58520bf37414
+ IV = 3c
+ CT = 15c4db4cbb451211179d57017f
+ AAD =
+ Tag = eae841d4355feeb3f786bc86625f1e5b
+ FAIL
""").splitlines()
assert load_nist_vectors(vector_data) == [
{'aad': b'',
+ 'iv': b'3c',
+ 'tag': b'eae841d4355feeb3f786bc86625f1e5b',
+ 'key': b'58fab7632bcf10d2bcee58520bf37414',
+ 'ct': b'15c4db4cbb451211179d57017f',
+ 'fail': True},
+ {'aad': b'',
'pt': b'',
'iv': b'4e8df20faaf2c8eebe922902',
'tag': b'e39aeaebe86aa309a4d062d6274339',
diff --git a/tests/utils.py b/tests/utils.py
index 8fa9af92..988a80b0 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -40,7 +40,15 @@ def load_nist_vectors(vector_data):
# Look for section headers
if line.startswith("[") and line.endswith("]"):
- section = line[1:-1]
+ if "=" in line:
+ # GCM section headers
+ if "Keylen" in line:
+ section = line[1:-1]
+ else:
+ section += line[1:-1]
+ else:
+ # non-GCM section headers
+ section = line[1:-1]
continue
if line.strip() == "FAIL":