Allow passing in encryptedContent and flag.

Add new flag HX509_CMS_UE_DONT_REQUIRE_KU_ENCIPHERMENT.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18063 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-09-11 06:31:34 +00:00
parent b82929db43
commit 9358faef60

View File

@@ -249,8 +249,10 @@ find_CMSIdentifier(hx509_context context,
int int
hx509_cms_unenvelope(hx509_context context, hx509_cms_unenvelope(hx509_context context,
hx509_certs certs, hx509_certs certs,
int flags,
const void *data, const void *data,
size_t length, size_t length,
const heim_octet_string *encryptedContent,
heim_oid *contentType, heim_oid *contentType,
heim_octet_string *content) heim_octet_string *content)
{ {
@@ -258,11 +260,11 @@ hx509_cms_unenvelope(hx509_context context,
EnvelopedData ed; EnvelopedData ed;
hx509_cert cert; hx509_cert cert;
AlgorithmIdentifier *ai; AlgorithmIdentifier *ai;
heim_octet_string *enccontent; const heim_octet_string *enccontent;
heim_octet_string *params, params_data; heim_octet_string *params, params_data;
heim_octet_string ivec; heim_octet_string ivec;
size_t size; size_t size;
int ret, i; int ret, i, findflags = 0;
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
@@ -271,6 +273,9 @@ hx509_cms_unenvelope(hx509_context context,
memset(content, 0, sizeof(*content)); memset(content, 0, sizeof(*content));
memset(contentType, 0, sizeof(*contentType)); memset(contentType, 0, sizeof(*contentType));
if (flags & HX509_CMS_UE_DONT_REQUIRE_KU_ENCIPHERMENT)
findflags |= HX509_QUERY_KU_ENCIPHERMENT;
ret = decode_EnvelopedData(data, length, &ed, &size); ret = decode_EnvelopedData(data, length, &ed, &size);
if (ret) { if (ret) {
hx509_set_error_string(context, 0, ret, hx509_set_error_string(context, 0, ret,
@@ -285,12 +290,16 @@ hx509_cms_unenvelope(hx509_context context,
goto out; goto out;
} }
if (ed.encryptedContentInfo.encryptedContent == NULL) { enccontent = ed.encryptedContentInfo.encryptedContent;
if (enccontent == NULL) {
if (encryptedContent == NULL) {
ret = HX509_CMS_NO_DATA_AVAILABLE; ret = HX509_CMS_NO_DATA_AVAILABLE;
hx509_set_error_string(context, 0, ret, hx509_set_error_string(context, 0, ret,
"Content missing from encrypted data"); "Content missing from encrypted data");
goto out; goto out;
} }
enccontent = encryptedContent;
}
cert = NULL; cert = NULL;
for (i = 0; i < ed.recipientInfos.len; i++) { for (i = 0; i < ed.recipientInfos.len; i++) {
@@ -306,8 +315,7 @@ hx509_cms_unenvelope(hx509_context context,
*/ */
ret = find_CMSIdentifier(context, &ri->rid, certs, &cert, ret = find_CMSIdentifier(context, &ri->rid, certs, &cert,
HX509_QUERY_PRIVATE_KEY| HX509_QUERY_PRIVATE_KEY|findflags);
HX509_QUERY_KU_ENCIPHERMENT);
if (ret) if (ret)
continue; continue;
@@ -342,8 +350,6 @@ hx509_cms_unenvelope(hx509_context context,
goto out; goto out;
} }
enccontent = ed.encryptedContentInfo.encryptedContent;
ai = &ed.encryptedContentInfo.contentEncryptionAlgorithm; ai = &ed.encryptedContentInfo.contentEncryptionAlgorithm;
if (ai->parameters) { if (ai->parameters) {
params_data.data = ai->parameters->data; params_data.data = ai->parameters->data;