aboutsummaryrefslogtreecommitdiffstats
path: root/src/usr/imgtrust.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-08-12 12:36:41 +0100
committerMichael Brown <mcb30@ipxe.org>2024-08-14 13:04:01 +0100
commit97635eb71b5ad7e81e79f32fef5f4394bcee0722 (patch)
tree5cade59887c1c710ccd184bfc62cb16339b5a22b /src/usr/imgtrust.c
parent998edc6ec515a6c9b0635d728b1cc51253e7dd7f (diff)
downloadipxe-97635eb71b5ad7e81e79f32fef5f4394bcee0722.tar.gz
[crypto] Generalise cms_signature to cms_message
There is some exploitable similarity between the data structures used for representing CMS signatures and CMS encryption keys. In both cases, the CMS message fundamentally encodes a list of participants (either message signers or message recipients), where each participant has an associated certificate and an opaque octet string representing the signature or encrypted cipher key. The ASN.1 structures are not identical, but are sufficiently similar to be worth exploiting: for example, the SignerIdentifier and RecipientIdentifier data structures are defined identically. Rename data structures and functions, and add the concept of a CMS message type. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr/imgtrust.c')
-rw-r--r--src/usr/imgtrust.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/usr/imgtrust.c b/src/usr/imgtrust.c
index 54ea3378f..7f7e7ed14 100644
--- a/src/usr/imgtrust.c
+++ b/src/usr/imgtrust.c
@@ -50,18 +50,18 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
int imgverify ( struct image *image, struct image *signature,
const char *name ) {
- struct cms_signature *sig;
- struct cms_signer_info *info;
+ struct cms_message *cms;
+ struct cms_participant *part;
time_t now;
int rc;
/* Parse signature */
- if ( ( rc = cms_signature ( signature, &sig ) ) != 0 )
+ if ( ( rc = cms_message ( signature, &cms ) ) != 0 )
goto err_parse;
/* Complete all certificate chains */
- list_for_each_entry ( info, &sig->info, list ) {
- if ( ( rc = create_validator ( &monojob, info->chain,
+ list_for_each_entry ( part, &cms->participants, list ) {
+ if ( ( rc = create_validator ( &monojob, part->chain,
NULL ) ) != 0 )
goto err_create_validator;
if ( ( rc = monojob_wait ( NULL, 0 ) ) != 0 )
@@ -70,12 +70,12 @@ int imgverify ( struct image *image, struct image *signature,
/* Use signature to verify image */
now = time ( NULL );
- if ( ( rc = cms_verify ( sig, image, name, now, NULL, NULL ) ) != 0 )
+ if ( ( rc = cms_verify ( cms, image, name, now, NULL, NULL ) ) != 0 )
goto err_verify;
- /* Drop reference to signature */
- cms_put ( sig );
- sig = NULL;
+ /* Drop reference to message */
+ cms_put ( cms );
+ cms = NULL;
/* Record signature verification */
syslog ( LOG_NOTICE, "Image \"%s\" signature OK\n", image->name );
@@ -85,7 +85,7 @@ int imgverify ( struct image *image, struct image *signature,
err_verify:
err_validator_wait:
err_create_validator:
- cms_put ( sig );
+ cms_put ( cms );
err_parse:
syslog ( LOG_ERR, "Image \"%s\" signature bad: %s\n",
image->name, strerror ( rc ) );