diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2012-05-10 13:27:57 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2012-05-10 13:27:57 +0000 |
commit | 3978429ad5a07907eae59ff9d20fba117208ef23 (patch) | |
tree | aadebd66c092428f18b225eee41321fc3b2197cd | |
parent | 885945d6e13a0c346eb935e08c63d8b9b95c6a16 (diff) |
Reported by: Solar Designer of Openwall
Make sure tkeylen is initialised properly when encrypting CMS messages.
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | crypto/cms/cms_enc.c | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -4,7 +4,9 @@ Changes between 0.9.8w and 0.9.8x [xx XXX xxxx] - *) + *) Initialise tkeylen properly when encrypting CMS messages. + Thanks to Solar Designer of Openwall for reporting this issue. + [Steve Henson] Changes between 0.9.8v and 0.9.8w [23 Apr 2012] diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c index 580083b45f..f873ce3794 100644 --- a/crypto/cms/cms_enc.c +++ b/crypto/cms/cms_enc.c @@ -139,10 +139,10 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); goto err; } + tkeylen = EVP_CIPHER_CTX_key_length(ctx); /* Generate random session key */ if (!enc || !ec->key) { - tkeylen = EVP_CIPHER_CTX_key_length(ctx); tkey = OPENSSL_malloc(tkeylen); if (!tkey) { @@ -174,7 +174,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) /* Only reveal failure if debugging so we don't * leak information which may be useful in MMA. */ - if (ec->debug) + if (enc || ec->debug) { CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, CMS_R_INVALID_KEY_LENGTH); |