From: hn Date: Sat, 30 Sep 2017 16:28:50 +0000 (+0200) Subject: new hash X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/a2a985ff223e108bdc73b0ade26f5c1eb970acf0?ds=sidebyside new hash --- diff --git a/Arduino/sketch_One_Round/sketch_One_Round.ino b/Arduino/sketch_One_Round/sketch_One_Round.ino index 014b85b..503d3f3 100644 --- a/Arduino/sketch_One_Round/sketch_One_Round.ino +++ b/Arduino/sketch_One_Round/sketch_One_Round.ino @@ -349,3 +349,4 @@ void prekey_test () prekey (128) ; } + diff --git a/Arduino/sketch_Proposed_Hash/sketch_Proposed_Hash.ino b/Arduino/sketch_Proposed_Hash/sketch_Proposed_Hash.ino new file mode 100644 index 0000000..4f6d466 --- /dev/null +++ b/Arduino/sketch_Proposed_Hash/sketch_Proposed_Hash.ino @@ -0,0 +1,391 @@ +#include +//#include "./printf.h" +//#include + +typedef byte uchar; +const int size_mesg=256; // size of plain-message +const int sleepTimeS = 10; +const int h=4; // size of each block +const int nblocks=size_mesg/h; // number of blocks +int rp=1; + + +byte DK[64]; +int PboxRM[h]; +uchar Sbox1[256]; + + +//-------------------------------------------------------------------- +//Function: KSA algorithm of RC4 +//-------------------------------------------------------------------- +void rc4key(uchar *key, uchar *sc, int size_DK) { + + for(int i=0;i<256;i++) { + sc[i]=i; + } + + + uchar j0 = 0; + for(int i0=0; i0<256; i0++) { + j0 = (j0 + sc[i0] + key[i0%size_DK] )&0xFF; + uchar tmp = sc[i0]; + sc[i0] = sc[j0 ]; + sc[j0] = tmp; + } +} + + +//-------------------------------------------------------------------- +//Function: Modified KSA of RC4 +//-------------------------------------------------------------------- +void rc4keyperm(uchar *key,int nblocks, int rp,int *sc, int size_DK) { + + //sc=1:nblocks; + for (int i=0;i