Project

General

Profile

Feature #8667 » 0001-Alternate-implementation-of-gcm-IV-length-support.patch

against trunk - dwaite (David Waite), 05/04/2014 06:31 PM

View differences:

ext/openssl/ossl_cipher.c
return key;
}
#define ossl_is_gcm(nid) (nid) == NID_aes_128_gcm || \
(nid) == NID_aes_192_gcm || \
(nid) == NID_aes_256_gcm
/*
* call-seq:
* cipher.iv = string -> string
......
static VALUE
ossl_cipher_set_iv(VALUE self, VALUE iv)
{
long ivlen;
int nid;
EVP_CIPHER_CTX *ctx;
StringValue(iv);
GetCipher(self, ctx);
if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))
ossl_raise(eCipherError, "iv length too short");
ivlen = RSTRING_LEN(iv);
nid = EVP_CIPHER_CTX_nid(ctx);
#ifdef HAVE_AUTHENTICATED_ENCRYPTION
if (ossl_is_gcm(nid)) {
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, NULL);
} else {
#endif
if (ivlen < EVP_CIPHER_CTX_iv_length(ctx))
ossl_raise(eCipherError, "iv length too short");
#ifdef HAVE_AUTHENTICATED_ENCRYPTION
}
#endif
if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)
ossl_raise(eCipherError, NULL);
ossl_raise(eCipherError, NULL);
return iv;
}
......
return data;
}
#define ossl_is_gcm(nid) (nid) == NID_aes_128_gcm || \
(nid) == NID_aes_192_gcm || \
(nid) == NID_aes_256_gcm
static VALUE
ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
{
(2-2/2)