diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 16:41:34 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2019-03-22 16:52:21 +0100 |
| commit | e83abe9fdbab07e6df80443240d4d649303a3dd4 (patch) | |
| tree | 76febb030151dff29ef62a4b27145ed73bd57b42 /python/genkat_aead.py | |
| parent | ba01ba773731cb2c906beb6855dfea588dc8cf09 (diff) | |
| download | lilliput-ae-implem-e83abe9fdbab07e6df80443240d4d649303a3dd4.tar.xz | |
[implem-python] Déplacement dans le dossier SOUMISSION_NIST
Et ajout d'un métascript pour vérifier la conformité.
Il ne reste plus qu'à… (bis)
Diffstat (limited to 'python/genkat_aead.py')
| -rwxr-xr-x | python/genkat_aead.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/python/genkat_aead.py b/python/genkat_aead.py deleted file mode 100755 index 01bed6f..0000000 --- a/python/genkat_aead.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 - -import crypto_aead - - -MAX_MESSAGE_LENGTH = 32 -MAX_ADATA_LENGTH = 32 - - -def print_bstr(output, label, buf): - print('{l} = {b}'.format(l=label, b=buf.hex().upper()), file=output) - - -def generate_test_vectors(): - output_path = 'LWC_AEAD_KAT_{key}_{npub}.txt'.format( - key=crypto_aead.KEYBYTES*8, npub=crypto_aead.NPUBBYTES*8 - ) - - npub = bytes(range(crypto_aead.NPUBBYTES)) - key = bytes(range(crypto_aead.KEYBYTES)) - - with open(output_path, 'w') as output: - - count = 1 - for mlen in range(MAX_MESSAGE_LENGTH+1): - for adlen in range(MAX_ADATA_LENGTH+1): - print('Count = {c}'.format(c=count), file=output) - - msg = bytes(range(mlen)) - ad = bytes(range(adlen)) - - print_bstr(output, 'Key', key) - print_bstr(output, 'Nonce', npub) - print_bstr(output, 'PT', msg) - print_bstr(output, 'AD', ad) - - ct = crypto_aead.encrypt(msg, ad, npub, key) - - print_bstr(output, 'CT', ct) - - crypto_aead.decrypt(ct, ad, npub, key) - - count += 1 - - print(file=output) - - -if __name__ == '__main__': - generate_test_vectors() |
