diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-03-14 19:37:56 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-03-14 19:37:56 +0000 |
commit | 320bfc1be79513f2a782f9ee8894cf7a7b9ffe2d (patch) | |
tree | 88b544dce8cf3d100cee2b1f4f286eefbf106270 /crypto/cms/cms_smime.c | |
parent | b820455c6e0aa38e7bdf121ec971f72e0eb097d0 (diff) |
Reorganise encrypted content info code to avoid duplication and be more
consistent with other content types.
Diffstat (limited to 'crypto/cms/cms_smime.c')
-rw-r--r-- | crypto/cms/cms_smime.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index a1ee0f24e2..458efbece8 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -212,16 +212,37 @@ int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, } } + if (CMS_EncryptedData_set1_key(cms, NULL, key, keylen) <= 0) + return 0; cont = CMS_dataInit(cms, dcont); if (!cont) return 0; - r = CMS_EncryptedData_set1_key(cont, cms, key, keylen); - if (r) - r = cms_copy_content(out, cont, flags); + r = cms_copy_content(out, cont, flags); BIO_free_all(cont); return r; } +CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, + const unsigned char *key, size_t keylen, + unsigned int flags) + { + CMS_ContentInfo *cms; + cms = CMS_ContentInfo_new(); + if (!cms) + return NULL; + if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen)) + return NULL; + + if(!(flags & CMS_DETACHED)) + CMS_set_detached(cms, 0); + + if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, in, flags)) + return cms; + + CMS_ContentInfo_free(cms); + return NULL; + } + static int cms_signerinfo_verify_cert(CMS_SignerInfo *si, X509_STORE *store, STACK_OF(X509) *certs, |