From: couturie Date: Fri, 18 Aug 2017 13:25:28 +0000 (+0200) Subject: new X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/cf457ee9b22e34dcc92f91f0400035a2f7d85d82?ds=sidebyside;hp=-c new --- cf457ee9b22e34dcc92f91f0400035a2f7d85d82 diff --git a/OneRoundIoT/OneRound/Makefile b/OneRoundIoT/OneRound/Makefile new file mode 100644 index 0000000..8aa0484 --- /dev/null +++ b/OneRoundIoT/OneRound/Makefile @@ -0,0 +1,16 @@ +CXX=g++ +C=gcc +CFLAGS=-O3 -std=c++11 +OBJ = pixmap_io.o one_round_new.o + +%.o: %.c + $(C) -c -o $@ $< $(CFLAGS) + +%.o: %.cpp + $(CXX) -c -o $@ $< $(CFLAGS) + +one_round_new: $(OBJ) + $(CXX) -o $@ $^ $(CFLAGS) + +clean: + rm -rf $(OBJ) one_round_new diff --git a/OneRoundIoT/openssl/Makefile b/OneRoundIoT/openssl/Makefile new file mode 100644 index 0000000..d123b57 --- /dev/null +++ b/OneRoundIoT/openssl/Makefile @@ -0,0 +1,15 @@ +C=gcc +CFLAGS= -I /usr/include/openssl/ -lcrypto -O3 -std=c99 +OBJ = pixmap_io.o openssl_evp.o + + +openssl_evp: $(OBJ) + $(C) -o $@ $^ $(CFLAGS) + + +%.o: %.c + $(C) -c -o $@ $< + + +clean: + rm -rf $(OBJ) openssl_evp diff --git a/OneRoundIoT/openssl/openssl_evp.c b/OneRoundIoT/openssl/openssl_evp.c index 3c1416f..b452b9a 100644 --- a/OneRoundIoT/openssl/openssl_evp.c +++ b/OneRoundIoT/openssl/openssl_evp.c @@ -60,10 +60,11 @@ int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, //256 //avant ecb - if(ctr) + if(ctr) { if(1 != EVP_EncryptInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv)) handleErrors(); - else + } + else if(1 != EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv)) handleErrors(); @@ -118,10 +119,11 @@ int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, //256 //avant => ecb - if(ctr) + if(ctr) { if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv)) handleErrors(); - else + } + else if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv)) handleErrors();