Hi

In my test program I noticed that EVP_CIPHER_CTX_iv_length dont report
correct value after EVP_CTRL_GCM_SET_IVLEN
The EVP_CIPHER_CTX_iv_length reports 12 instead of 16

The CTEXT changes as I change value from 12 to 16 in
EVP_CIPHER_CTX_ctrl(EVP_CTRL_GCM_SET_IVLEN) suggesting that the ivlen of 16
is active but is not reflected in the return from EVP_CIPHER_CTX_iv_length .

I am using following code.

EVP_CIPHER_CTX * ctx = new EVP_CIPHER_CTX;
EVP_CIPHER_CTX_init(ctx);
const EVP_CIPHER * cipher = EVP_aes_256_gcm();
printf("%-20s key.len=%2d iv.len=%2d bsize=%2d\n", "aes256gcm cipher",
EVP_CIPHER_key_length(cipher), EVP_CIPHER_iv_length(cipher),
EVP_CIPHER_block_size(cipher));

if(! EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, crypt_dir))
RPX_throw_opensslerror;
if(! EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL))
RPX_throw_opensslerror;
if(! EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, crypt_dir))
RPX_throw_opensslerror;

printf("%-20s key.len=%2d iv.len=%2d bsize=%2d\n", "aes256gcm context",
EVP_CIPHER_CTX_key_length(ctx), EVP_CIPHER_CTX_iv_length(ctx),
EVP_CIPHER_CTX_block_size(ctx));


Cheers
Bog

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to