aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto/cms.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-05-14 00:13:00 +0100
committerMichael Brown <mcb30@ipxe.org>2012-05-14 00:20:28 +0100
commit7deb610881d36dd156edbf705f923cf43cc0fdf5 (patch)
treea5d2ddfc3a44e9facb35f3aa23b7ddf9167520d1 /src/crypto/cms.c
parent88c09b36cfefc037cca7c409423b14d8c556e3be (diff)
downloadipxe-7deb610881d36dd156edbf705f923cf43cc0fdf5.tar.gz
[crypto] Generalise asn1_{digest,pubkey,signature}_algorithm()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto/cms.c')
-rw-r--r--src/crypto/cms.c41
1 files changed, 9 insertions, 32 deletions
diff --git a/src/crypto/cms.c b/src/crypto/cms.c
index 18e59bfba..2083433e5 100644
--- a/src/crypto/cms.c
+++ b/src/crypto/cms.c
@@ -65,15 +65,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
__einfo_error ( EINFO_ENOTSUP_SIGNEDDATA )
#define EINFO_ENOTSUP_SIGNEDDATA \
__einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Not a digital signature" )
-#define ENOTSUP_DIGEST \
- __einfo_error ( EINFO_ENOTSUP_DIGEST )
-#define EINFO_ENOTSUP_DIGEST \
- __einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported digest algorithm" )
-#define ENOTSUP_PUBKEY \
- __einfo_error ( EINFO_ENOTSUP_PUBKEY )
-#define EINFO_ENOTSUP_PUBKEY \
- __einfo_uniqify ( EINFO_ENOTSUP, 0x03, \
- "Unsupported public-key algorithm" )
/** "pkcs7-signedData" object identifier */
static uint8_t oid_signeddata[] = { ASN1_OID_SIGNEDDATA };
@@ -257,21 +248,14 @@ static int cms_parse_digest_algorithm ( struct cms_signature *sig,
struct cms_signer_info *info,
const struct asn1_cursor *raw ) {
struct asn1_algorithm *algorithm;
+ int rc;
/* Identify algorithm */
- algorithm = asn1_algorithm ( raw );
- if ( ! algorithm ) {
- DBGC ( sig, "CMS %p/%p could not identify digest algorithm:\n",
- sig, info );
+ if ( ( rc = asn1_digest_algorithm ( raw, &algorithm ) ) != 0 ) {
+ DBGC ( sig, "CMS %p/%p could not identify digest algorithm: "
+ "%s\n", sig, info, strerror ( rc ) );
DBGC_HDA ( sig, 0, raw->data, raw->len );
- return -ENOTSUP_DIGEST;
- }
-
- /* Check algorithm is a digest algorithm */
- if ( ! algorithm->digest ) {
- DBGC ( sig, "CMS %p/%p algorithm %s is not a digest "
- "algorithm\n", sig, info, algorithm->name );
- return -EINVAL_DIGEST;
+ return rc;
}
/* Record digest algorithm */
@@ -294,21 +278,14 @@ static int cms_parse_signature_algorithm ( struct cms_signature *sig,
struct cms_signer_info *info,
const struct asn1_cursor *raw ) {
struct asn1_algorithm *algorithm;
+ int rc;
/* Identify algorithm */
- algorithm = asn1_algorithm ( raw );
- if ( ! algorithm ) {
+ if ( ( rc = asn1_pubkey_algorithm ( raw, &algorithm ) ) != 0 ) {
DBGC ( sig, "CMS %p/%p could not identify public-key "
- "algorithm:\n", sig, info );
+ "algorithm: %s\n", sig, info, strerror ( rc ) );
DBGC_HDA ( sig, 0, raw->data, raw->len );
- return -ENOTSUP_PUBKEY;
- }
-
- /* Check algorithm is a signature algorithm */
- if ( ! algorithm->pubkey ) {
- DBGC ( sig, "CMS %p/%p algorithm %s is not a public-key "
- "algorithm\n", sig, info, algorithm->name );
- return -EINVAL_PUBKEY;
+ return rc;
}
/* Record signature algorithm */