/rev/86d0c1d49af8
changeset: 1205:86d0c1d49af8
user: Marcel Keller <[email protected]>
date: Mon Jul 27 15:24:11 2009 +0200
summary: Added an inversion by exponentiation variant with least rounds.
diffstat:
viff/aes.py | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diffs (45 lines):
diff -r d43f766c4cac -r 86d0c1d49af8 viff/aes.py
--- a/viff/aes.py Mon Jul 27 12:16:25 2009 +0200
+++ b/viff/aes.py Mon Jul 27 15:24:11 2009 +0200
@@ -107,6 +107,8 @@
self.invert = lambda byte: byte ** 254
elif (use_exponentiation == "shortest_chain_with_least_rounds"):
self.invert = self.invert_by_exponentiation_with_less_rounds
+ elif (use_exponentiation == "chain_with_least_rounds"):
+ self.invert = self.invert_by_exponentiation_with_least_rounds
else:
self.invert = self.invert_by_exponentiation
else:
@@ -117,7 +119,8 @@
exponentiation_variants = ["standard_square_and_multiply",
"shortest_sequential_chain",
- "shortest_chain_with_least_rounds"]
+ "shortest_chain_with_least_rounds",
+ "chain_with_least_rounds"]
def invert_by_masking(self, byte):
bits = bit_decompose(byte)
@@ -181,6 +184,22 @@
byte_254 = byte_200 * byte_54
return byte_254
+ def invert_by_exponentiation_with_least_rounds(self, byte):
+ byte_2 = byte * byte
+ byte_3 = byte_2 * byte
+ byte_4 = byte_2 * byte_2
+ byte_7 = byte_4 * byte_3
+ byte_8 = byte_4 * byte_4
+ byte_15 = byte_8 * byte_7
+ byte_16 = byte_8 * byte_8
+ byte_31 = byte_16 * byte_15
+ byte_32 = byte_16 * byte_16
+ byte_63 = byte_32 * byte_31
+ byte_64 = byte_32 * byte_32
+ byte_127 = byte_64 * byte_63
+ byte_254 = byte_127 * byte_127
+ return byte_254
+
# matrix for byte_sub, the last column is the translation vector
A = Matrix([[1,0,0,0,1,1,1,1, 1],
[1,1,0,0,0,1,1,1, 1],
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk