{
byte plain[size_mesg];
-byte plain2[size_mesg];
- //byte hashValue [h] ;
- // byte hashValue [h]
+//byte plain2[size_mesg];
byte Hashval[h];
byte Hashval2[h];
-int itk=10;
-int timecompute[itk];
-float timee=0;
-for (int it=0;it<itk;it++){
//%%%%%%%%%%%%% Initialization of seed%%%%%%%%%%%%%%
int seed=random(2^32);
randomSeed(seed);
for(int i=0;i<size_mesg;i++) {
plain[i]=random(255);
}
- //printf("\n\noriginal key :");
- //printArray(Hashval,h);
-
// copy of hashval to hashval2 (it is the output of the hash function)
for(int i=0;i<h;i++){
// Modify message with a random index
- for(int i=0;i<size_mesg;i++){
- plain2[i]=plain[i];
- }
-
int indx=random(size_mesg);
Serial.println("Index");
Serial.println(indx);
- plain2[indx]=plain2[indx]+1;
+ plain[indx]=plain[indx]+1;
unsigned long ms3 = micros ();
- hash_DSD_BIN(plain2, Hashval2,nblocks,PboxRM,Sbox1,h);
- timecompute[it]=micros() - ms3;
+ hash_DSD_BIN(plain, Hashval2,nblocks,PboxRM,Sbox1,h);
Serial.print("Hash time: ");
- Serial.println(timecompute[it]);
+ Serial.println(micros() - ms3);
printf("\n\nModify PLAIN :");
printArray(plain,16*2);
bool equal=true;
for(int i=0;i<size_mesg;i++) {
-
if(Hashval2[i]!=Hashval[i]) {
equal=false;
}
-}
+/*}
timee=mean(itk, timecompute) ;
Serial.println ("Mean Time");
Serial.println(timee);
delay(500);
+ */
+
/*
- ms1 = micros ();
- // encrypt_ctr(cipher, check,nblocks,RM2,Pbox,PboxRM,Sbox1,Sbox2,0);
- hash_DSD_BIN(plain2, Hashval,nblocks,PboxRM,Sbox1,h);
- Serial.print("ONE Decryption took: ");
- Serial.println(micros() - ms1);*/
+
//printf("\nCHECK :");
//printArray(check,16*2);
-
+ */
}
//--------------------------------------------------------------------