diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/cms/cms_smime.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/lib/libcrypto/cms/cms_smime.c b/src/lib/libcrypto/cms/cms_smime.c index a8ddf7c67c..a4918643d2 100644 --- a/src/lib/libcrypto/cms/cms_smime.c +++ b/src/lib/libcrypto/cms/cms_smime.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_smime.c,v 1.30 2025/11/03 14:29:50 tb Exp $ */ | 1 | /* $OpenBSD: cms_smime.c,v 1.31 2025/11/28 06:07:09 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -277,27 +277,32 @@ CMS_ContentInfo * | |||
| 277 | CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, | 277 | CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, |
| 278 | const unsigned char *key, size_t keylen, unsigned int flags) | 278 | const unsigned char *key, size_t keylen, unsigned int flags) |
| 279 | { | 279 | { |
| 280 | CMS_ContentInfo *cms; | 280 | CMS_ContentInfo *cms = NULL; |
| 281 | 281 | ||
| 282 | if (!cipher) { | 282 | if (cipher == NULL) { |
| 283 | CMSerror(CMS_R_NO_CIPHER); | 283 | CMSerror(CMS_R_NO_CIPHER); |
| 284 | return NULL; | 284 | goto err; |
| 285 | } | 285 | } |
| 286 | cms = CMS_ContentInfo_new(); | 286 | |
| 287 | if (cms == NULL) | 287 | if ((cms = CMS_ContentInfo_new()) == NULL) |
| 288 | return NULL; | 288 | goto err; |
| 289 | if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen)) { | 289 | |
| 290 | CMS_ContentInfo_free(cms); | 290 | if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen)) |
| 291 | return NULL; | 291 | goto err; |
| 292 | |||
| 293 | if ((flags & CMS_DETACHED) == 0) { | ||
| 294 | if (!CMS_set_detached(cms, 0)) | ||
| 295 | goto err; | ||
| 292 | } | 296 | } |
| 293 | 297 | ||
| 294 | if (!(flags & CMS_DETACHED)) | 298 | if ((flags & (CMS_STREAM | CMS_PARTIAL)) == 0) { |
| 295 | CMS_set_detached(cms, 0); | 299 | if (!CMS_final(cms, in, NULL, flags)) |
| 300 | goto err; | ||
| 301 | } | ||
| 296 | 302 | ||
| 297 | if ((flags & (CMS_STREAM | CMS_PARTIAL)) || | 303 | return cms; |
| 298 | CMS_final(cms, in, NULL, flags)) | ||
| 299 | return cms; | ||
| 300 | 304 | ||
| 305 | err: | ||
| 301 | CMS_ContentInfo_free(cms); | 306 | CMS_ContentInfo_free(cms); |
| 302 | 307 | ||
| 303 | return NULL; | 308 | return NULL; |
