X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/656b608a022c716868f21e2aa84da15fb6aa4e86..06700270edf2ed0941561de3f7dde136accc51f0:/OneRoundIoT/openssl/openssl_evp.c diff --git a/OneRoundIoT/openssl/openssl_evp.c b/OneRoundIoT/openssl/openssl_evp.c index be8eb74..0a4b949 100644 --- a/OneRoundIoT/openssl/openssl_evp.c +++ b/OneRoundIoT/openssl/openssl_evp.c @@ -16,6 +16,9 @@ typedef unsigned char uchar; int nb_test=1; int ctr=0; +double time_encrypt=0; +double time_decrypt=0; + double TimeStart() { struct timeval tstart; @@ -49,6 +52,9 @@ int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, int ciphertext_len; + + + /* Create and initialise the context */ if(!(ctx = EVP_CIPHER_CTX_new())) handleErrors(); @@ -58,51 +64,46 @@ int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, * IV size for *most* modes is the same as the block size. For AES this * is 128 bits */ + double t=TimeStart(); + //256 //avant ecb - if(ctr) { - if(1 != EVP_EncryptInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv)) - handleErrors(); - } - else + for(int i=0;i ecb if(ctr) { if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv)) @@ -142,27 +148,32 @@ int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, * EVP_DecryptUpdate can be called multiple times if necessary */ - static double time=0; +/* static double time=0; double t=0; t=TimeStart(); +*/ -// for(int i=0;i