aboutsummaryrefslogtreecommitdiff
path: root/test-vectors.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-vectors.py')
-rwxr-xr-xtest-vectors.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/test-vectors.py b/test-vectors.py
index 7deb8d4..2cd75f5 100755
--- a/test-vectors.py
+++ b/test-vectors.py
@@ -21,6 +21,7 @@
# =============================================================================
from pypride import Pride
+import time
test_vectors = [
{'key': "00000000000000000000000000000000", 'plaintext': "0000000000000000", 'ciphertext': "82b4109fcc70bd1f"},
@@ -30,8 +31,28 @@ test_vectors = [
{'key': "0000000000000000fedcba9876543210", 'plaintext': "0123456789abcdef", 'ciphertext': "d1372929712d336e"}
]
+time_cipher = 0
+time_encrypt = 0
+time_decrypt = 0
+
for vector in test_vectors:
- cipher = Pride(vector['key'].decode('hex'))
- encryption = cipher.encrypt(vector['plaintext'].decode('hex'))
- decryption = cipher.decrypt(vector['ciphertext'].decode('hex'))
- print encryption == vector['ciphertext'].decode('hex'), decryption == vector['plaintext'].decode('hex') \ No newline at end of file
+ key = vector['key'].decode('hex')
+ start = time.time()
+ cipher = Pride(key)
+ time_cipher += time.time() - start
+
+ plaintext = vector['plaintext'].decode('hex')
+ start = time.time()
+ encryption = cipher.encrypt(plaintext)
+ time_encrypt += time.time() - start
+
+ ciphertext = vector['ciphertext'].decode('hex')
+ start = time.time()
+ decryption = cipher.decrypt(ciphertext)
+ time_decrypt += time.time() - start
+
+ print encryption == vector['ciphertext'].decode('hex'), decryption == vector['plaintext'].decode('hex')
+
+print "Generating round keys:", str(time_cipher) + "s"
+print "Encryption:", str(time_encrypt) + "s"
+print "Decryption:", str(time_decrypt) + "s" \ No newline at end of file