Can I use AES CTR mode encryption using the EVP API?

I am new to OpenSSL. I understand that encryption must be done using the EVP API, which acts as a common interface to all ciphers. AES CTR mode seems to be present in the OpenSSL version that I have, but the definition for EVP_aes_128_ctr is disabled in evp.h:

#if 0 const EVP_CIPHER *EVP_aes_128_ctr(void); #endif 

Any idea why this is? Can I just remove #if 0? Any other pointers to getting 128-bit AES CTR mode encryption for working in OpenSSL will be appreciated!

Thanks!

+7
openssl encryption aes
source share
2 answers

By the way, it seems that the answer is no, not yet. But maybe soon. I found this email stream, indicating that a fix to resolve this issue could be sent in June 2010:

http://www.mail-archive.com/libssh2-devel@cool.haxx.se/msg01972.html

But when I downloaded the latest development branch from SVN, AES CTR was still not included in EVP. In the end, I just used it, for which I found this link useful:

AES CTR 256 Encryption Operating Mode in OpenSSL

+4
source share

I am using AES CTR 128 mode and it works. I am using libssl1.0.0 (I'm not sure if I am answering the correct question! I hope this is helpful). Here is part of my code:

 EVP_CipherInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv,1); EVP_CipherUpdate (ctx, ciphertext, &len, plaintext, plaintext_len); /* Finalise the encryption. */ if(! EVP_CipherFinal_ex(ctx, ciphertext + len, &len)) handleErrors(); /*setting padding option*/ EVP_CIPHER_CTX_set_padding(ctx,0); /* Clean up */ EVP_CIPHER_CTX_free(ctx); 
+1
source share

All Articles