Reported by: Solar Designer of Openwall
authorDr. Stephen Henson <steve@openssl.org>
Thu, 10 May 2012 13:27:57 +0000 (13:27 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 10 May 2012 13:27:57 +0000 (13:27 +0000)
Make sure tkeylen is initialised properly when encrypting CMS messages.

CHANGES
crypto/cms/cms_enc.c

diff --git a/CHANGES b/CHANGES
index e1e5bd519d2d2e4971482e076d217be67f6ab8bc..e2ec1e1978c2c3906eef2600ebfa5503d5f65d29 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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]
 
index 580083b45f870aebd3e21680cfe70d6d15260dfd..f873ce3794452a1ba64cbae3f98b68c09076f256 100644 (file)
@@ -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);