summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2012-05-10 13:46:09 +0000
committerDr. Stephen Henson <steve@openssl.org>2012-05-10 13:46:09 +0000
commit225055c30b625d9928fbc691f7362f4b1ed085e5 (patch)
tree760e54effc50b47be840031dccf2e868e7d38fb1
parente0311481b87ce790c164af88f54c2f9234b30ddb (diff)
Reported by: Solar Designer of Openwall
Make sure tkeylen is initialised properly when encrypting CMS messages.
-rw-r--r--CHANGES4
-rw-r--r--crypto/cms/cms_enc.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 33c30602ed..8425bb37ea 100644
--- a/CHANGES
+++ b/CHANGES
@@ -291,6 +291,10 @@
Changes between 1.0.1b and 1.0.1c [xx XXX xxxx]
+
+ *) Initialise tkeylen properly when encrypting CMS messages.
+ Thanks to Solar Designer of Openwall for reporting this issue.
+ [Steve Henson]
*) In FIPS mode don't try to use composite ciphers as they are not
approved.
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);