diff options
author | Camil Staps | 2015-04-23 13:36:20 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-23 13:36:20 +0200 |
commit | 4f98014f9e47be4761afa42741025b571b8eeb31 (patch) | |
tree | c0d2a029142de78088ce6d9eaf6fd13b25b1e219 | |
parent | Cleanup (diff) |
Nicer test vectors
-rwxr-xr-x | test-vectors.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test-vectors.py b/test-vectors.py index 065bb76..f4d3399 100755 --- a/test-vectors.py +++ b/test-vectors.py @@ -35,7 +35,9 @@ time_cipher = 0 time_encrypt = 0 time_decrypt = 0 -for vector in test_vectors: +all_passed = True + +for v_i, vector in enumerate(test_vectors): key = vector['key'].decode('hex') start = time.time() cipher = Pride(key) @@ -51,7 +53,16 @@ for vector in test_vectors: decryption = cipher.decrypt(ciphertext) time_decrypt += time.time() - start - print encryption == vector['ciphertext'].decode('hex'), decryption == vector['plaintext'].decode('hex') + if encryption != vector['ciphertext'].decode('hex'): + print "Encryption for vector", v_i, "failed: was", encryption.encode('hex'), "; should have been", vector['ciphertext'] + all_passed = False + + if decryption != vector['plaintext'].decode('hex'): + print "Decryption for vector", v_i, "failed: was", decryption.encode('hex'), "; should have been", vector['plaintext'] + all_passed = False + +if all_passed: + print "All tests passed." print "Generating round keys:", str(time_cipher) + "s" print "Encryption: ", str(time_encrypt) + "s" |