Browse Source

working jupyter notebook and updated FW implementation

Hans Martin 3 years ago
parent
commit
7dda63c96a

File diff suppressed because it is too large
+ 103 - 81
.ipynb_checkpoints/Speck-Analysis-checkpoint.ipynb


File diff suppressed because it is too large
+ 83 - 73
Speck-Analysis.ipynb


BIN
cw_firmware/speck


+ 6 - 2
cw_firmware/speck3264.c

@@ -39,9 +39,12 @@ void Speck3264Encrypt(u16 Pt[],u16 Ct[],u16 rk[])
     Ct[0]=Pt[0]; Ct[1]=Pt[1];
 
     // full 22  rounds
-    // for(i=0;i<22;) ER16(Ct[1],Ct[0],rk[i++]);
+    // for(i=0;i<22;) ;
     //ER16(Ct[1],Ct[0],rk[0]);
-    ER16(Ct[1],Ct[0],0x65);
+    for(i=0;i<22;) {
+        //ER16(Ct[1],Ct[0],0xdead);
+        ER16(Ct[1],Ct[0],rk[i++]);
+    }
 }
 
 
@@ -64,6 +67,7 @@ void Speck3264_EncryptBlock(u8 pt[], u8 k[], u8 ct[]) {
     BytesToWords16(pt,Pt,8);
     BytesToWords16(k,K,16);
 
+
     Speck3264KeySchedule(K,rk);
 
     // DEBUG Purposes

BIN
paper/efficient-side-channel-protections.pdf


+ 3 - 2
simulation/speck.py

@@ -117,12 +117,13 @@ class SpeckCipher(object):
         l_schedule = [(self.key >> (x * self.word_size)) & self.mod_mask for x in
                       range(1, self.key_size // self.word_size)]
 
+        print([hex(x) for x in l_schedule])
         for x in range(self.rounds - 1):
             new_l_k = self.encrypt_round(l_schedule[x], self.key_schedule[x], x)
             l_schedule.append(new_l_k[0])
             self.key_schedule.append(new_l_k[1])
 
-        print(self.key_schedule)
+        print([hex(x) for x in self.key_schedule])
 
     def encrypt(self, plaintext):
         try:
@@ -316,5 +317,5 @@ if __name__ == "__main__":
     cipher = SpeckCipher(0x0102030405060708, 64, 32, 'ECB')
 
     #g = cipher.encrypt(0x65736f6874206e49202e72656e6f6f70)
-    g = cipher.encrypt(0xdeadbeefdeadbeef)
+    g = cipher.encrypt(0xdeadbeef)
     print(hex(g))

File diff suppressed because it is too large
+ 825 - 12
simulation/speck_cpa_simulation.ipynb


Some files were not shown because too many files changed in this diff