From 994c6a6e920abfc3823984ef4d6caaf85c2008da Mon Sep 17 00:00:00 2001 From: couturie <you@example.com> Date: Tue, 10 Jul 2018 15:55:51 +0200 Subject: [PATCH 1/1] new --- Arduino/sketch_AES/sketch_AES.ino | 2 +- IDA/Makefile | 2 +- IDA/ida_gf65.cpp | 42 +++++++++++++++++++++---- OneRoundIoT/OneRound/Makefile | 2 +- OneRoundIoT/OneRound/one_round_hash.cpp | 2 ++ OneRoundIoT/OneRound/one_round_new.cpp | 22 +++++++++++-- 6 files changed, 61 insertions(+), 11 deletions(-) diff --git a/Arduino/sketch_AES/sketch_AES.ino b/Arduino/sketch_AES/sketch_AES.ino index 998f763..c2805c3 100644 --- a/Arduino/sketch_AES/sketch_AES.ino +++ b/Arduino/sketch_AES/sketch_AES.ino @@ -6,7 +6,7 @@ AES aes ; byte *key = (unsigned char*)"0123456789010123"; -const int size_mesg=64; +const int size_mesg=16*15; diff --git a/IDA/Makefile b/IDA/Makefile index 71745c6..f34a69b 100644 --- a/IDA/Makefile +++ b/IDA/Makefile @@ -16,7 +16,7 @@ ida_gf64: ida_gf64.cpp g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -I/home/couturie/ajeter/jerasure/include /home/couturie/ajeter/jerasure/src/.libs/jerasure.o /home/couturie/ajeter/jerasure/src/.libs/galois.o -lgf_complete -fpermissive ida_gf65: ida_gf65.cpp - g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -I/home/couturie/ajeter/jerasure/include /home/couturie/ajeter/jerasure/src/.libs/jerasure.o /home/couturie/ajeter/jerasure/src/.libs/galois.o -lgf_complete -fpermissive + g++ -o $@ $< -std=c++11 -O3 -lm -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -g -O3 -Wall -I/home/couturie/ajeter/jerasure/include /home/couturie/ajeter/jerasure/src/.libs/jerasure.o /home/couturie/ajeter/jerasure/src/.libs/galois.o -lgf_complete -fpermissive -lpthread clean: rm test_mat2 ida ida_gf64 diff --git a/IDA/ida_gf65.cpp b/IDA/ida_gf65.cpp index 09c4162..2a914c5 100644 --- a/IDA/ida_gf65.cpp +++ b/IDA/ida_gf65.cpp @@ -10,6 +10,10 @@ #include <string.h> #include <algorithm> // std::random_shuffle #include <vector> // std::vector +#include <unistd.h> +#include <thread> + + extern "C" { #include "jerasure.h" } @@ -20,7 +24,7 @@ typedef unsigned long mylong; using namespace std; -string cloud[5]={"dropboxida1","googleida1","megaida1","onedriveida1","pcloudida1"}; +string cloud[5]={"dropboxida1","googleida1","onedriveida2","onedriveida1","pcloudida1"}; void display(mylong *mat, int r, int c) { @@ -441,18 +445,27 @@ int main(int argc, char **argv) // display(matC,t,t); - + thread th[n]; //Save trunks for(int i=0;i<n;i++) { stringstream ss; ss <<"lena_"<<i<<".png"; string str = ss.str(); saveFile((uint8_t*)&matC[i*len], str.c_str(),len*sizeof(mylong)); - sendChunk( str,i); +// sendChunk( str,i); + th[i] = thread(sendChunk,str, i); } + for(int i=0;i<n;i++) { + th[i].join(); + } +/* cout<<"sleep begin"<<endl; + sleep(2); + cout<<"sleep end"<<endl; +*/ + mylong *matCs = malloc(sizeof(mylong)*t*len); mylong *matGs = malloc(sizeof(mylong)*t*t); @@ -469,9 +482,10 @@ int main(int argc, char **argv) std::cout << "random chunk" << std::endl; int ind=0; + + + for(int ii=0;ii<t;ii++) { -// for(int i=n-1;i>=t;i--) { -// for(int i=0;i<n;i+=2) { auto i=myvector[ii]; std::cout << myvector[i] << " "; @@ -481,7 +495,23 @@ int main(int argc, char **argv) ss <<"lena_"<<i<<".png"; string str = ss.str(); - retrieveChunk(str,i); +// retrieveChunk(str,i); + th[ii] = thread(retrieveChunk,str, i); + } + + + ind=0; + + for(int ii=0;ii<t;ii++) { + + auto i=myvector[ii]; + std::cout << myvector[i] << " "; + + + stringstream ss; + ss <<"lena_"<<i<<".png"; + string str = ss.str(); + th[ii].join(); readFile((uint8_t*)&matCs[ind*len], str.c_str(),len*sizeof(mylong)); // display(&matCs[ind*len],1,1); diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile index c3775dd..be3d7b7 100644 --- a/OneRoundIoT/OneRound/Makefile +++ b/OneRoundIoT/OneRound/Makefile @@ -8,7 +8,7 @@ else ifeq ($(uname_m),armv6l) CFLAGS=-O3 -march=armv6 -mfpu=vfp -mfloat-abi=hard -lrt else -CFLAGS=-O3 +CFLAGS=-O3 `pkg-config --cflags --libs glib-2.0` endif endif diff --git a/OneRoundIoT/OneRound/one_round_hash.cpp b/OneRoundIoT/OneRound/one_round_hash.cpp index 373892c..2688609 100644 --- a/OneRoundIoT/OneRound/one_round_hash.cpp +++ b/OneRoundIoT/OneRound/one_round_hash.cpp @@ -12,6 +12,8 @@ #include<string.h> #include <fstream> #include <sys/time.h> +#include <glib.h> + /*#include <cryptopp/hex.h> #include <cryptopp/sha.h> diff --git a/OneRoundIoT/OneRound/one_round_new.cpp b/OneRoundIoT/OneRound/one_round_new.cpp index be38534..d4441a9 100644 --- a/OneRoundIoT/OneRound/one_round_new.cpp +++ b/OneRoundIoT/OneRound/one_round_new.cpp @@ -9,6 +9,8 @@ #include<string.h> #include <fstream> #include <sys/time.h> +#include <glib.h> + /*#include <cryptopp/hex.h> #include <cryptopp/sha.h> @@ -412,6 +414,10 @@ int main(int argc, char** argv) { uchar *data_R, *data_G, *data_B; int imsize; uchar *buffer; + + + + if(lena==1) { load_RGB_pixmap("lena.ppm", &width, &height, &data_R, &data_G, &data_B); @@ -466,15 +472,27 @@ int main(int argc, char** argv) { for (int i = 0; i < 256 ; i++) { mix[i]=Secretkey[i]^counter[i]; + } + gchar *sha512; + + sha512 = g_compute_checksum_for_string(G_CHECKSUM_SHA512, (const char*) mix, 256); +// g_print("%s\n", sha512); + + + + + + + // cout<<"hash "<<endl; for (int i = 0; i < 64 ; i++) { // DK[i]=digest[i]; - DK[i]=mix[i]; + DK[i]=sha512[i]; } - + g_free(sha512); int *Pbox=new int[len]; -- 2.39.5