|
@@ -117,7 +117,7 @@ class SpeckCipher(object):
|
|
l_schedule = [(self.key >> (x * self.word_size)) & self.mod_mask for x in
|
|
l_schedule = [(self.key >> (x * self.word_size)) & self.mod_mask for x in
|
|
range(1, self.key_size // self.word_size)]
|
|
range(1, self.key_size // self.word_size)]
|
|
|
|
|
|
- print([hex(x) for x in l_schedule])
|
|
|
|
|
|
+ #print([hex(x) for x in l_schedule])
|
|
for x in range(self.rounds - 1):
|
|
for x in range(self.rounds - 1):
|
|
new_l_k = self.encrypt_round(l_schedule[x], self.key_schedule[x], x)
|
|
new_l_k = self.encrypt_round(l_schedule[x], self.key_schedule[x], x)
|
|
l_schedule.append(new_l_k[0])
|
|
l_schedule.append(new_l_k[0])
|
|
@@ -314,7 +314,18 @@ class SpeckCipher(object):
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
#cipher = SpeckCipher(0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100, 256, 128, 'ECB')
|
|
#cipher = SpeckCipher(0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100, 256, 128, 'ECB')
|
|
- cipher = SpeckCipher(0x0102030405060708, 64, 32, 'ECB')
|
|
|
|
|
|
+ cipher = SpeckCipher(0x8877665544332211, 64, 32, 'ECB')
|
|
|
|
+
|
|
|
|
+ for i in range(22):
|
|
|
|
+ a, b = cipher.decrypt_round(0x2211, 0x00dd, i)
|
|
|
|
+ print(hex(a))
|
|
|
|
+ print(hex(b))
|
|
|
|
+
|
|
|
|
+ for key in range(2**16):
|
|
|
|
+ _, a = cipher.encrypt_round(key, 0x2211, 0)
|
|
|
|
+
|
|
|
|
+ if a == 0xdd:
|
|
|
|
+ print("found: " + hex(key))
|
|
|
|
|
|
#g = cipher.encrypt(0x65736f6874206e49202e72656e6f6f70)
|
|
#g = cipher.encrypt(0x65736f6874206e49202e72656e6f6f70)
|
|
g = cipher.encrypt(0xdeadbeef)
|
|
g = cipher.encrypt(0xdeadbeef)
|