X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/94e90035b1b2f00c5862a03f69a0b23d9b53df51..3ed2f4b380f0d9f49ff45bf6accf8a55c511a353:/OneRoundIoT/openssl/openssl_evp_cmac.c diff --git a/OneRoundIoT/openssl/openssl_evp_cmac.c b/OneRoundIoT/openssl/openssl_evp_cmac.c index ae01f5c..f1d3984 100755 --- a/OneRoundIoT/openssl/openssl_evp_cmac.c +++ b/OneRoundIoT/openssl/openssl_evp_cmac.c @@ -34,6 +34,14 @@ double TimeStop(double t) } +void printBytes(unsigned char *buf, size_t len) { + for(int i=0; i<len; i++) { + printf("%02x ", buf[i]); + } + printf("\n"); +} + + void handleErrors(void) { ERR_print_errors_fp(stderr); @@ -110,6 +118,8 @@ unsigned char mact[16] = {0}; if(1 != CMAC_Final(ctx, mact, &mactlen)) handleErrors(); ciphertext_len += len; + // printBytes(mact, mactlen); + /* Clean up */ CMAC_CTX_free(ctx); @@ -189,13 +199,14 @@ int main (int argc, char** argv) int size_buf=1; int lena=0; - + int change=0; for(int i=1; i<argc; i++){ if(strncmp(argv[i],"nb",2)==0) nb_test = atoi(&(argv[i][2])); //nb of test if(strncmp(argv[i],"ctr",3)==0) ctr = atoi(&(argv[i][3])); //CTR ? 1 otherwise CBC like if(strncmp(argv[i],"sizebuf",7)==0) size_buf = atoi(&(argv[i][7])); //SIZE of the buffer if(strncmp(argv[i],"lena",4)==0) lena = atoi(&(argv[i][4])); //Use Lena or buffer + if(strncmp(argv[i],"c",1)==0) change = atoi(&(argv[i][1])); //Use Lena or buffer } /* printf("nb times %d\n",nb_test); @@ -261,7 +272,15 @@ int main (int argc, char** argv) } } - + if(change==1) { + + plaintext[4]++; + } + if(change==2) { + + plaintext[9]++; + } + uchar *ciphertext = malloc(imsize+1000); //add that for cbc @@ -296,8 +315,9 @@ int main (int argc, char** argv) time_encrypt+=TimeStop(t); // printf("Time encrypt %f\n",time); - printf("%f\t",(double)imsize*nb_test/time_encrypt); + printf("%e\t",(double)imsize*nb_test/time_encrypt); + /* if(lena) { for(int i=0;i<oneD;i++) { data_R[i]=ciphertext[i]; @@ -306,7 +326,7 @@ int main (int argc, char** argv) } store_RGB_pixmap("lena2.ppm", data_R, data_G, data_B, width, height); } - + */ /* t=0; t=TimeStart();