]> AND Private Git Repository - Cipher_code.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
update of old one round in order to degrade it
authorcouturie <you@example.com>
Tue, 17 Apr 2018 13:15:20 +0000 (15:15 +0200)
committercouturie <you@example.com>
Tue, 17 Apr 2018 13:15:20 +0000 (15:15 +0200)
Old_one_round/one_round_light_auth.cpp

index 138efb641da09cb8d55f4e664db923c69ab98da3..6e6a4afcd8310e95c8280dae6ea71ebb365a00d6 100644 (file)
@@ -129,49 +129,37 @@ template<int h>
 void myhash(uchar *X, uchar* RM2, uchar *Sbox2) {
   uchar Y[h];
   uchar X2[h];
+  uchar Z[h];
 
   for(int k=0;k<h;k++) {
     
       
-    for(int a=0;a<h;a+=4) {
+    for(int a=0;a<h;a++) {
       X2[a]=RM2[a]^X[k*h+a];
-      X2[a+1]=RM2[a+1]^X[k*h+a+1];
-      X2[a+2]=RM2[a+2]^X[k*h+a+2];
-      X2[a+3]=RM2[a+3]^X[k*h+a+3];
     }
 
 
     Y[0]=X2[0]^X2[h-1];
-    Y[1]=Y[0]^X2[0];
-    Y[2]=Y[1]^X2[1];
-    Y[3]=Y[2]^X2[2];
-    for(int a=4;a<h;a+=4) {
+    for(int a=4;a<h;a++) {
       Y[a]=Y[a-1]^X2[a-1];
-      Y[a+1]=Y[a]^X2[a];
-      Y[a+2]=Y[a+1]^X2[a+1];
-      Y[a+3]=Y[a+2]^X2[a+2];
     }
     
     
-    for(int a=0;a<h;a+=4) {
+    for(int a=0;a<h;a++) {
       Y[a]=Sbox2[Y[a]];
-      Y[a+1]=Sbox2[Y[a+1]];
-      Y[a+2]=Sbox2[Y[a+2]];
-      Y[a+3]=Sbox2[Y[a+3]];
+    }
+
+
+    Z[h-1]=Y[h-1]^Y[0];
+    for(int a=h-1;a>0;a--) {
+      Z[a-1]=Z[a]^Y[a];
     }
     
-    
-    
-    RM2[h-1]=Y[h-1]^Y[0];
-    RM2[h-2]=RM2[h-1]^Y[h-1];
-    RM2[h-3]=RM2[h-2]^Y[h-2];
-    RM2[h-4]=RM2[h-3]^Y[h-3];
-    for(int a=h-4;a>0;a-=4) {
-      RM2[a-1]=RM2[a]^Y[a];
-      RM2[a-2]=RM2[a-1]^Y[a-1];
-      RM2[a-3]=RM2[a-2]^Y[a-2];
-      RM2[a-4]=RM2[a-3]^Y[a-3];
+    for(int a=0;a<h;a++) {
+       RM2[a]=Z[a];
     }
+      
+
   }
 }