X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/ff9e923170329eacc0f53ba1c9673622b6f8b5a2..493692c718afc65e4ab01b078bb6368235220599:/OneRoundHash/oneroundhash.cpp?ds=inline diff --git a/OneRoundHash/oneroundhash.cpp b/OneRoundHash/oneroundhash.cpp index 642dc07..864961d 100644 --- a/OneRoundHash/oneroundhash.cpp +++ b/OneRoundHash/oneroundhash.cpp @@ -746,7 +746,7 @@ void decrypt_authenticate_algorithm_2Blocks_V2(uchar* seq_in, uchar *seq_out, i } template -void encrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uchar* IV,mylong myrand) { +void encrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Sbox1, uchar *Sbox2, uchar* IV,uchar* MAC,mylong myrand) { uchar RM1[h]; uchar tmp1[h]; mylong *rm1=(mylong*)RM1; @@ -791,16 +791,16 @@ void encrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, i } for(int a=0;a -void decrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Inv_Sbox1, uchar *Inv_Sbox2 ,uchar *Sbox1, uchar *Sbox2, uchar* IV,mylong myrand) { +void decrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, int len, uchar* RM, int *Pbox, int *PboxSRM, uchar *Inv_Sbox1, uchar *Inv_Sbox2 ,uchar *Sbox1, uchar *Sbox2, uchar* IV,uchar* MAC,mylong myrand) { uchar RM1[h]; uchar tmp1[h]; mylong *rm1=(mylong*)RM1; @@ -844,10 +844,10 @@ void decrypt_authenticate_algorithm_2Blocks_V3(uchar* seq_in, uchar *seq_out, i } for(int a=0;a(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV,myrand,0); - if(cbcrm) - encrypt_cbc_rm<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV,0); - if(ecbrm) - encrypt_ecb_rm<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV,0); - if(ecbprng) - encrypt_ecb_prng<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV,myrand,0); - } - break;*/ + if(v1b) + encrypt_authenticate_algorithm<16>(seq, seq2, len, RM, Pbox, PboxSRM, Sbox1, Sbox2, IV1, MAC, myrand); + if(v2b1) + encrypt_authenticate_algorithm_2Blocks<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b2) + encrypt_authenticate_algorithm_2Blocks_V2<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b3) + encrypt_authenticate_algorithm_2Blocks_V3<16>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,MAC,myrand); + } + break; + + case 32: for(i=0;i(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand); if(v2b3) - encrypt_authenticate_algorithm_2Blocks_V3<32>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,myrand); + encrypt_authenticate_algorithm_2Blocks_V3<32>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,MAC,myrand); } break; + + case 64: + for(i=0;i(seq, seq2, len, RM, Pbox, PboxSRM, Sbox1, Sbox2, IV1, MAC, myrand); + if(v2b1) + encrypt_authenticate_algorithm_2Blocks<64>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b2) + encrypt_authenticate_algorithm_2Blocks_V2<64>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b3) + encrypt_authenticate_algorithm_2Blocks_V3<64>(seq, seq2,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,IV1,MAC,myrand); + } + break; + + + } @@ -1108,6 +1138,10 @@ int main(int argc, char** argv) { cout<<"Time encrypt "<(seq2,seq,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,IV,myrand,0); - if(cbcrm) - decrypt_cbc_rm<16>(seq2,seq,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,IV,0); - if(ecbrm) - decrypt_ecb_rm<16>(seq2,seq,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,IV,0); - if(ecbprng) - decrypt_ecb_prng<16>(seq2,seq,len,RM,Pbox,PboxSRM,Sbox1,Sbox2,Inv_Sbox1,Inv_Sbox2,IV,myrand,0); - } - break;*/ + if(v1b) + decrypt_authenticate_algorithm<16>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand); + if(v2b1) + decrypt_authenticate_algorithm_2Blocks<16>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b2) + decrypt_authenticate_algorithm_2Blocks_V2<16>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b3) + decrypt_authenticate_algorithm_2Blocks_V3<16>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand); + } + break; + case 32: for(i=0;i(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand); if(v2b3) - decrypt_authenticate_algorithm_2Blocks_V3<32>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,myrand); + decrypt_authenticate_algorithm_2Blocks_V3<32>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand); } break; + + case 64: + for(i=0;i(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand); + if(v2b1) + decrypt_authenticate_algorithm_2Blocks<64>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b2) + decrypt_authenticate_algorithm_2Blocks_V2<64>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,IV2,MAC,myrand); + if(v2b3) + decrypt_authenticate_algorithm_2Blocks_V3<64>(seq2, seq,len,RM,Pbox,PboxSRM,Inv_Sbox1,Inv_Sbox2,Sbox1,Sbox2,IV1,MAC,myrand); + } + break; + + + + } + time_decrypt+=TimeStop(t); // cout<<"Time decrypt "<