From 09560a14c64f9a5e418334d3a5e77447e32ae85f Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 23 Apr 2015 12:51:25 +0200 Subject: Timing; generate roundkeys on initialisation --- test-vectors.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'test-vectors.py') 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 -- cgit v1.2.3