summaryrefslogtreecommitdiffstats
path: root/crypto/cms/cms_enc.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-03-14 13:21:48 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-03-14 13:21:48 +0000
commitb820455c6e0aa38e7bdf121ec971f72e0eb097d0 (patch)
tree0f10ad6bfc453e02a18feeb398d99f0aff256433 /crypto/cms/cms_enc.c
parent5c4436c97759a98794cd84dc37c937fa637aad61 (diff)
Encrypted Data type processing. Add options to cms utility and run section 7
tests in RFC4134.
Diffstat (limited to 'crypto/cms/cms_enc.c')
-rw-r--r--crypto/cms/cms_enc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c
index 084bc12466..b395bc499b 100644
--- a/crypto/cms/cms_enc.c
+++ b/crypto/cms/cms_enc.c
@@ -132,18 +132,11 @@ int cms_bio_to_EncryptedContent(CMS_EncryptedContentInfo *ec,
/* Return BIO based on EncryptedContentInfo and key */
-BIO *cms_EncryptedContent_to_bio(CMS_EncryptedContentInfo *ec,
+int cms_EncryptedContent_to_bio(BIO *b, CMS_EncryptedContentInfo *ec,
const unsigned char *key, int keylen)
{
- BIO *b;
EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *ciph;
- b = BIO_new(BIO_f_cipher());
- if (!b)
- {
- CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_TO_BIO, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
BIO_get_cipher_ctx(b, &ctx);
ciph = EVP_get_cipherbyobj(ec->contentEncryptionAlgorithm->algorithm);
@@ -187,10 +180,18 @@ BIO *cms_EncryptedContent_to_bio(CMS_EncryptedContentInfo *ec,
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
goto err;
}
- return b;
+ return 1;
err:
- BIO_free(b);
- return NULL;
+ return 0;
}
+int CMS_EncryptedData_set1_key(BIO *b, CMS_ContentInfo *cms,
+ const unsigned char *key, size_t keylen)
+ {
+ CMS_EncryptedContentInfo *ec;
+ if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_encrypted)
+ return 0;
+ ec = cms->d.encryptedData->encryptedContentInfo;
+ return cms_EncryptedContent_to_bio(b, ec, key, keylen);
+ }