When we are not using pkcs7-data, avoid seing signedAttributes since
some clients get upset by that (pkcs7 based or just plain broken). git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20926 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -946,7 +946,7 @@ hx509_cms_create_signed_1(hx509_context context,
|
|||||||
AlgorithmIdentifier digest;
|
AlgorithmIdentifier digest;
|
||||||
hx509_name name;
|
hx509_name name;
|
||||||
SignerInfo *signer_info;
|
SignerInfo *signer_info;
|
||||||
heim_octet_string buf, content;
|
heim_octet_string buf, content, sigdata;
|
||||||
SignedData sd;
|
SignedData sd;
|
||||||
int ret;
|
int ret;
|
||||||
size_t size;
|
size_t size;
|
||||||
@@ -1023,18 +1023,24 @@ hx509_cms_create_signed_1(hx509_context context,
|
|||||||
signer_info->signedAttrs = NULL;
|
signer_info->signedAttrs = NULL;
|
||||||
signer_info->unsignedAttrs = NULL;
|
signer_info->unsignedAttrs = NULL;
|
||||||
|
|
||||||
ALLOC(signer_info->signedAttrs, 1);
|
|
||||||
if (signer_info->signedAttrs == NULL) {
|
ret = copy_AlgorithmIdentifier(&digest, &signer_info->digestAlgorithm);
|
||||||
ret = ENOMEM;
|
if (ret) {
|
||||||
|
hx509_clear_error_string(context);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
/*
|
||||||
|
* If its not pkcs7-data send signedAttributes
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (der_heim_oid_cmp(eContentType, oid_id_pkcs7_data()) != 0) {
|
||||||
|
CMSAttributes sa;
|
||||||
heim_octet_string sig;
|
heim_octet_string sig;
|
||||||
|
|
||||||
ret = copy_AlgorithmIdentifier(&digest, &signer_info->digestAlgorithm);
|
ALLOC(signer_info->signedAttrs, 1);
|
||||||
if (ret) {
|
if (signer_info->signedAttrs == NULL) {
|
||||||
hx509_clear_error_string(context);
|
ret = ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,9 +1078,6 @@ hx509_cms_create_signed_1(hx509_context context,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (der_heim_oid_cmp(eContentType, oid_id_pkcs7_data()) != 0) {
|
|
||||||
|
|
||||||
ASN1_MALLOC_ENCODE(ContentType,
|
ASN1_MALLOC_ENCODE(ContentType,
|
||||||
buf.data,
|
buf.data,
|
||||||
@@ -1095,19 +1098,13 @@ hx509_cms_create_signed_1(hx509_context context,
|
|||||||
hx509_clear_error_string(context);
|
hx509_clear_error_string(context);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
CMSAttributes sa;
|
|
||||||
heim_octet_string os;
|
|
||||||
|
|
||||||
sa.val = signer_info->signedAttrs->val;
|
sa.val = signer_info->signedAttrs->val;
|
||||||
sa.len = signer_info->signedAttrs->len;
|
sa.len = signer_info->signedAttrs->len;
|
||||||
|
|
||||||
ASN1_MALLOC_ENCODE(CMSAttributes,
|
ASN1_MALLOC_ENCODE(CMSAttributes,
|
||||||
os.data,
|
sigdata.data,
|
||||||
os.length,
|
sigdata.length,
|
||||||
&sa,
|
&sa,
|
||||||
&size,
|
&size,
|
||||||
ret);
|
ret);
|
||||||
@@ -1115,21 +1112,25 @@ hx509_cms_create_signed_1(hx509_context context,
|
|||||||
hx509_clear_error_string(context);
|
hx509_clear_error_string(context);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (size != os.length)
|
if (size != sigdata.length)
|
||||||
_hx509_abort("internal ASN.1 encoder error");
|
_hx509_abort("internal ASN.1 encoder error");
|
||||||
|
} else {
|
||||||
ret = _hx509_create_signature(context,
|
sigdata.data = content.data;
|
||||||
_hx509_cert_private_key(cert),
|
sigdata.length = content.length;
|
||||||
_hx509_crypto_default_sig_alg,
|
}
|
||||||
&os,
|
|
||||||
&signer_info->signatureAlgorithm,
|
|
||||||
&signer_info->signature);
|
ret = _hx509_create_signature(context,
|
||||||
|
_hx509_cert_private_key(cert),
|
||||||
der_free_octet_string(&os);
|
_hx509_crypto_default_sig_alg,
|
||||||
if (ret) {
|
&sigdata,
|
||||||
hx509_clear_error_string(context);
|
&signer_info->signatureAlgorithm,
|
||||||
goto out;
|
&signer_info->signature);
|
||||||
}
|
if (sigdata.data != content.data)
|
||||||
|
der_free_octet_string(&sigdata);
|
||||||
|
if (ret) {
|
||||||
|
hx509_clear_error_string(context);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_SEQ(&sd.digestAlgorithms, 1);
|
ALLOC_SEQ(&sd.digestAlgorithms, 1);
|
||||||
|
Reference in New Issue
Block a user