From bd0fd45010fd0c1803d6368bd7d7dab255615f51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Couturier?= <raphael.couturier@univ-fcomte.fr> Date: Wed, 4 Mar 2020 12:05:39 +0100 Subject: [PATCH 1/1] new --- OneRoundIoT/OneRound/one_round_hash_new2.cpp | 22 +++++------ OneRoundIoT/OneRound/one_round_hash_new3.cpp | 22 +++++------ OneRoundIoT/OneRound/run_hash_throughput.py | 39 ++++++++++++++++++++ OneRoundIoT/openssl/openssl_evp_cmac.c | 2 +- OneRoundIoT/openssl/openssl_evp_hmac.c | 2 +- 5 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 OneRoundIoT/OneRound/run_hash_throughput.py diff --git a/OneRoundIoT/OneRound/one_round_hash_new2.cpp b/OneRoundIoT/OneRound/one_round_hash_new2.cpp index ae346fe..911d7f3 100644 --- a/OneRoundIoT/OneRound/one_round_hash_new2.cpp +++ b/OneRoundIoT/OneRound/one_round_hash_new2.cpp @@ -212,9 +212,9 @@ int main(int argc, char** argv) { } - cout<<size_buf<<endl; + // cout<<size_buf<<endl; int seed=12;//time(NULL); - cout<<seed<<endl; + //cout<<seed<<endl; srand48(seed); uchar Secretkey[key_size]; @@ -275,7 +275,7 @@ int main(int argc, char** argv) { } } - printf("seq 4 %d\n",seq[4]); + //printf("seq 4 %d\n",seq[4]); if(change==1) { seq[4]++; @@ -285,7 +285,7 @@ int main(int argc, char** argv) { seq[9]++; } - printf("seq 4 %d\n",seq[4]); + // printf("seq 4 %d\n",seq[4]); @@ -293,7 +293,7 @@ int main(int argc, char** argv) { int total_len=imsize; int rp=1; int len= total_len/h; - cout<<len<<endl; + //cout<<len<<endl; uchar *mix=new uchar[256]; @@ -340,7 +340,7 @@ int main(int argc, char** argv) { rc4keyperm(&DK[24], h, rp, PboxRM, 8); time+=TimeStop(t); - cout<<"Time initializaton "<<time<<endl; + //cout<<"Time initializaton "<<time<<endl; @@ -356,7 +356,7 @@ int main(int argc, char** argv) { RM2[i]=RM1[i]; } - cout<<"imsize "<<imsize<<endl; + //cout<<"imsize "<<imsize<<endl; /* for(int i=0;i<imsize;i++){ cout<<(int)seq[i]<<" "; @@ -375,13 +375,13 @@ int main(int argc, char** argv) { time+=TimeStop(t); - cout<<"Hash Time "<<time<<endl; + //cout<<"Hash Time "<<time<<endl; cout<<(double)imsize*nb_test/time<<"\t"; - for(int i=0;i<h;i++){ + /*for(int i=0;i<h;i++){ cout<<(int)RM1[i]<<" "; - } - cout<<endl; + }*/ + // cout<<endl; diff --git a/OneRoundIoT/OneRound/one_round_hash_new3.cpp b/OneRoundIoT/OneRound/one_round_hash_new3.cpp index 81580ce..db0ea08 100644 --- a/OneRoundIoT/OneRound/one_round_hash_new3.cpp +++ b/OneRoundIoT/OneRound/one_round_hash_new3.cpp @@ -234,9 +234,9 @@ int main(int argc, char** argv) { } - cout<<size_buf<<endl; + // cout<<size_buf<<endl; int seed=12;//time(NULL); - cout<<seed<<endl; + // cout<<seed<<endl; srand48(seed); uchar Secretkey[key_size]; @@ -297,7 +297,7 @@ int main(int argc, char** argv) { } } - printf("seq 4 %d\n",seq[4]); + //printf("seq 4 %d\n",seq[4]); if(change==1) { seq[4]++; @@ -307,7 +307,7 @@ int main(int argc, char** argv) { seq[9]++; } - printf("seq 4 %d\n",seq[4]); + // printf("seq 4 %d\n",seq[4]); @@ -315,7 +315,7 @@ int main(int argc, char** argv) { int total_len=imsize; int rp=1; int len= total_len/h; - cout<<len<<endl; + //cout<<len<<endl; uchar *mix=new uchar[256]; @@ -367,7 +367,7 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); time+=TimeStop(t); - cout<<"Time initializaton "<<time<<endl; + // cout<<"Time initializaton "<<time<<endl; @@ -383,7 +383,7 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); RM2[i]=RM1[i]; } - cout<<"imsize "<<imsize<<endl; + // cout<<"imsize "<<imsize<<endl; /* for(int i=0;i<imsize;i++){ cout<<(int)seq[i]<<" "; @@ -402,13 +402,13 @@ rc4keyperm(&DK[32], len, rp, Pbox, 16); time+=TimeStop(t); - cout<<"Hash Time "<<time<<endl; + // cout<<"Hash Time "<<time<<endl; cout<<(double)imsize*nb_test/time<<"\t"; - for(int i=0;i<h;i++){ + /* for(int i=0;i<h;i++){ cout<<(int)RM1[i]<<" "; - } - cout<<endl; + }*/ + // cout<<endl; diff --git a/OneRoundIoT/OneRound/run_hash_throughput.py b/OneRoundIoT/OneRound/run_hash_throughput.py new file mode 100644 index 0000000..5fd2f46 --- /dev/null +++ b/OneRoundIoT/OneRound/run_hash_throughput.py @@ -0,0 +1,39 @@ +#python3 run_hash_throughput.py > exe_hash_throughtput.txt + +import subprocess +import re + + + +print("#size \t h \t time") +print("variant 1"); +h=8 +for k in range(1,6): + result=subprocess.check_output("one_round_hash_new2 lena1 nb100 h"+str(h),shell=True) + res=result.decode() + print(str(512*512*3)+"\t"+str(h)+"\t"+res) + h=h+h + +print("variant 2"); +h=8 +for k in range(1,6): + result=subprocess.check_output("one_round_hash_new3 lena1 nb100 h"+str(h),shell=True) + res=result.decode() + print(str(512*512*3)+"\t"+str(h)+"\t"+res) + h=h+h + +print("cmac"); +h=8 +for k in range(1,6): + result=subprocess.check_output("../openssl/openssl_evp_cmac lena1 nb100 h"+str(h),shell=True) + res=result.decode() + print(str(512*512*3)+"\t"+str(h)+"\t"+res) + h=h+h + +print("hmac"); +h=8 +for k in range(1,6): + result=subprocess.check_output("../openssl/openssl_evp_hmac lena1 nb100 h"+str(h),shell=True) + res=result.decode() + print(str(512*512*3)+"\t"+str(h)+"\t"+res) + h=h+h diff --git a/OneRoundIoT/openssl/openssl_evp_cmac.c b/OneRoundIoT/openssl/openssl_evp_cmac.c index d8c0377..f1d3984 100755 --- a/OneRoundIoT/openssl/openssl_evp_cmac.c +++ b/OneRoundIoT/openssl/openssl_evp_cmac.c @@ -118,7 +118,7 @@ unsigned char mact[16] = {0}; if(1 != CMAC_Final(ctx, mact, &mactlen)) handleErrors(); ciphertext_len += len; - printBytes(mact, mactlen); + // printBytes(mact, mactlen); /* Clean up */ CMAC_CTX_free(ctx); diff --git a/OneRoundIoT/openssl/openssl_evp_hmac.c b/OneRoundIoT/openssl/openssl_evp_hmac.c index 59f5f8a..5e738ea 100644 --- a/OneRoundIoT/openssl/openssl_evp_hmac.c +++ b/OneRoundIoT/openssl/openssl_evp_hmac.c @@ -134,7 +134,7 @@ int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, ciphertext_len += len; - printBytes(hash_sha256, result_len); + // printBytes(hash_sha256, result_len); /* char *p = &hash_sha256_hex[0]; -- 2.39.5