summaryrefslogtreecommitdiffstats
path: root/crypto/cms/cms_enc.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-03-15 13:37:32 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-03-15 13:37:32 +0000
commite540d1cd77d4cf0edea74212a5e598d073ce2e67 (patch)
tree3db9a1fed983e5e11b246597b5026ed1511240d4 /crypto/cms/cms_enc.c
parentfd47c36136c7ac9b86f14c69b23a7d2df4fce132 (diff)
Check for cipher BIO errors and set key length after parameter decode.
Diffstat (limited to 'crypto/cms/cms_enc.c')
-rw-r--r--crypto/cms/cms_enc.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c
index 54a1e431c2..fbf87b6735 100644
--- a/crypto/cms/cms_enc.c
+++ b/crypto/cms/cms_enc.c
@@ -115,18 +115,6 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
if (enc)
calg->algorithm = OBJ_nid2obj(EVP_CIPHER_CTX_type(ctx));
- /* If necessary set key length */
-
- if (ec->keylen != EVP_CIPHER_CTX_key_length(ctx))
- {
- if (EVP_CIPHER_CTX_set_key_length(ctx, ec->keylen) <= 0)
- {
- CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
- CMS_R_INVALID_KEY_LENGTH);
- goto err;
- }
- }
-
if (enc)
{
int ivlen;
@@ -146,6 +134,18 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
goto err;
}
+ /* If necessary set key length */
+
+ if (ec->keylen != EVP_CIPHER_CTX_key_length(ctx))
+ {
+ if (EVP_CIPHER_CTX_set_key_length(ctx, ec->keylen) <= 0)
+ {
+ CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
+ CMS_R_INVALID_KEY_LENGTH);
+ goto err;
+ }
+ }
+
if (EVP_CipherInit_ex(ctx, NULL, NULL, ec->key, piv, enc) <= 0)
{
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,