mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
modify nist loader to support multi-line GCM sections
This commit is contained in:
parent
984eeeb388
commit
c985dbb47b
2 changed files with 29 additions and 1 deletions
|
|
@ -347,8 +347,28 @@ 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',
|
||||
|
|
|
|||
|
|
@ -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":
|
||||
|
|
|
|||
Loading…
Reference in a new issue