diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-21 16:04:16 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-21 16:04:16 +0100 |
| commit | aaf0d2c49f343e909dc69b487056ca31238ffabf (patch) | |
| tree | 9e054a390aad0be8f2acec8a77de3a7e97d881ba /python/genkat_aead.py | |
| parent | 57952a7dd9d9c586dcac84e46987d15d49674774 (diff) | |
| download | lilliput-ae-implem-aaf0d2c49f343e909dc69b487056ca31238ffabf.tar.xz | |
[implem-python] Nettoyage PEP8
- espaces avant ':'
- espaces en trop après ','
- parenthèses dans les if
- levée d'exception plutôt que 'return None' implicite
Simplification de genkat_aead.py grâce à l'exception levée par le
module.
Diffstat (limited to 'python/genkat_aead.py')
| -rwxr-xr-x | python/genkat_aead.py | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/python/genkat_aead.py b/python/genkat_aead.py index daa48f8..8b38d9b 100755 --- a/python/genkat_aead.py +++ b/python/genkat_aead.py @@ -16,27 +16,8 @@ MODE_SUFFIXES = { } -def bstr(buf): - return ''.join('{:02X}'.format(b) for b in buf) - - def print_bstr(output, label, buf): - print('{l} = {b}'.format(l=label, b=bstr(buf)), file=output) - - -class DecryptionError(Exception): - def __init__(self, expected, actual, mode, keylen): - self.expected = expected - self.actual = actual - self.mode = mode - self.keylen = keylen - - def __str__(self): - return '({s.mode} / {s.keylen}) Expected {exp}; got {act}'.format( - s=self, - exp=bstr(self.expected) if self.expected is not None else 'NONE', - act=bstr(self.actual) if self.actual is not None else 'NONE' - ) + print('{l} = {b}'.format(l=label, b=buf.hex().upper()), file=output) def generate_test_vectors(mode, keylen): @@ -74,10 +55,7 @@ def generate_test_vectors(mode, keylen): print_bstr(output, 'CT', ct+tag) - msg2 = decrypt(ct, tag, ad, key, nonce, mode) - - if msg != msg2: - raise DecryptionError(msg, msg2, mode, keylen) + decrypt(ct, tag, ad, key, nonce, mode) count+=1 |
