From 7e0f6789a8187ca8c691e4211b91eb16e5588203 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 23 Apr 2015 13:23:43 +0200 Subject: Performance --- pypride.py | 2 +- test-vectors.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pypride.py b/pypride.py index b30b565..c011f74 100644 --- a/pypride.py +++ b/pypride.py @@ -239,7 +239,7 @@ def matrixMultiply(matrix, input): input as Int Output: Int""" - mult = [ mapXor([c * ((input >> (15 - c_i)) & 0x1) for c_i, c in reversed(list(enumerate(r)))]) for r in matrix ] + mult = [ mapXor([1 for c_i, c in enumerate(r) if c == 1 and input & (0x1 << (15 - c_i))]) for r in matrix ] return sum([(1 << (15-i)) * v for i,v in enumerate(mult)]) def roundKey(key, i): diff --git a/test-vectors.py b/test-vectors.py index 2cd75f5..065bb76 100755 --- a/test-vectors.py +++ b/test-vectors.py @@ -54,5 +54,5 @@ for vector in test_vectors: 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 +print "Encryption: ", str(time_encrypt) + "s" +print "Decryption: ", str(time_decrypt) + "s" \ No newline at end of file -- cgit v1.2.3