From: couturie Date: Wed, 3 Nov 2021 12:56:33 +0000 (+0100) Subject: new X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/3ed2f4b380f0d9f49ff45bf6accf8a55c511a353?ds=inline new --- diff --git a/OneRoundIoT/openssl/Makefile b/OneRoundIoT/openssl/Makefile index 34b74d2..b88f1c9 100644 --- a/OneRoundIoT/openssl/Makefile +++ b/OneRoundIoT/openssl/Makefile @@ -6,6 +6,7 @@ OBJ3 = pixmap_io.o openssl_evp_ccm.o OBJ4 = pixmap_io.o aesccm.o OBJ5 = pixmap_io.o openssl_evp_gcm.o OBJ6 = pixmap_io.o openssl_evp_hmac.o +OBJ7 = pixmap_io.o openssl_evp_ocb.o openssl_evp: $(OBJ) $(C) -o $@ $^ $(CFLAGS) @@ -26,11 +27,14 @@ openssl_evp_gcm: $(OBJ5) openssl_evp_hmac: $(OBJ6) $(C) -o $@ $^ $(CFLAGS) +openssl_evp_ocb: $(OBJ7) + $(C) -o $@ $^ $(CFLAGS) + %.o: %.c $(C) -c -o $@ $< -O3 clean: - rm -rf $(OBJ) openssl_evp openssl_evp_cmac openssl_evp_ccm + rm -rf $(OBJ) openssl_evp openssl_evp_cmac openssl_evp_ccm openssl_evp_ocb diff --git a/OneRoundIoT/openssl/openssl_evp_ocb.c b/OneRoundIoT/openssl/openssl_evp_ocb.c new file mode 100755 index 0000000..480df1e --- /dev/null +++ b/OneRoundIoT/openssl/openssl_evp_ocb.c @@ -0,0 +1,371 @@ +//gcc pixmap_io.c -c +//gcc openssl_evp.c pixmap_io.o -o openssl_evp -I /usr/include/openssl/ -lcrypto -O3 -std=c99 + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pixmap_io.h" + +typedef unsigned char uchar; + +int nb_test=1; +int ctr=0; + +double TimeStart() +{ + struct timeval tstart; + gettimeofday(&tstart,0); + return( (double) (tstart.tv_sec + tstart.tv_usec*1e-6) ); +} + +double TimeStop(double t) +{ + struct timeval tend; + + gettimeofday(&tend,0); + t = (double) (tend.tv_sec + tend.tv_usec*1e-6) - t; + return (t); +} + + +void printBytes(unsigned char *buf, size_t len) { + for(int i=0; i ecb + if(ctr) { + if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_ocb(), NULL, key, iv)) + handleErrors(); + } + else + if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_ocb(), NULL, key, iv)) + handleErrors(); + + /* Provide the message to be decrypted, and obtain the plaintext output. + * EVP_DecryptUpdate can be called multiple times if necessary + */ + +/* static double time=0; + double t=0; + t=TimeStart(); +*/ + for(int i=0;i