X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/4fa9c3d0a87911ef71653cb99aa1c70f633a9473..8e7ce26ffa675a1249751a2a2e5d3b5c1cdc0553:/OneRoundIoT/openssl/openssl_evp.c?ds=inline diff --git a/OneRoundIoT/openssl/openssl_evp.c b/OneRoundIoT/openssl/openssl_evp.c index 3c1416f..bd4243a 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(); @@ -153,15 +155,24 @@ int main (int argc, char** argv) * real application? :-) */ - for(int i=1; i