aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asymmetric_keys
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2015-07-20 16:16:32 -0400
committerDavid Howells <dhowells@redhat.com>2015-08-12 12:01:01 -0400
commita4c6e57f4f5fa65cbdb8cc1c14ff5ca7c56766c3 (patch)
treeb58633416215ee7c0fb6e5b7900877cbff934f02 /crypto/asymmetric_keys
parent2c7fd3675ef1867d0d0c39e9f0bb5ddb67bfc7a7 (diff)
X.509: Change recorded SKID & AKID to not include Subject or Issuer
The key identifiers fabricated from an X.509 certificate are currently: (A) Concatenation of serial number and issuer (B) Concatenation of subject and subjectKeyID (SKID) When verifying one X.509 certificate with another, the AKID in the target can be used to match the authoritative certificate. The AKID can specify the match in one or both of two ways: (1) Compare authorityCertSerialNumber and authorityCertIssuer from the AKID to identifier (A) above. (2) Compare keyIdentifier from the AKID plus the issuer from the target certificate to identifier (B) above. When verifying a PKCS#7 message, the only available comparison is between the IssuerAndSerialNumber field and identifier (A) above. However, a subsequent patch adds CMS support. Whilst CMS still supports a match on IssuerAndSerialNumber as for PKCS#7, it also supports an alternative - which is the SubjectKeyIdentifier field. This is used to match to an X.509 certificate on the SKID alone. No subject information is available to be used. To this end change the fabrication of (B) above to be from the X.509 SKID alone. The AKID in keyIdentifier form then only matches on that and does not include the issuer. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-By: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'crypto/asymmetric_keys')
-rw-r--r--crypto/asymmetric_keys/x509_cert_parser.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 6c130dd56f35..849fd760923e 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -454,9 +454,7 @@ int x509_process_extension(void *context, size_t hdrlen,
454 454
455 ctx->cert->raw_skid_size = vlen; 455 ctx->cert->raw_skid_size = vlen;
456 ctx->cert->raw_skid = v; 456 ctx->cert->raw_skid = v;
457 kid = asymmetric_key_generate_id(ctx->cert->raw_subject, 457 kid = asymmetric_key_generate_id(v, vlen, "", 0);
458 ctx->cert->raw_subject_size,
459 v, vlen);
460 if (IS_ERR(kid)) 458 if (IS_ERR(kid))
461 return PTR_ERR(kid); 459 return PTR_ERR(kid);
462 ctx->cert->skid = kid; 460 ctx->cert->skid = kid;
@@ -553,9 +551,7 @@ int x509_akid_note_kid(void *context, size_t hdrlen,
553 if (ctx->cert->akid_skid) 551 if (ctx->cert->akid_skid)
554 return 0; 552 return 0;
555 553
556 kid = asymmetric_key_generate_id(ctx->cert->raw_issuer, 554 kid = asymmetric_key_generate_id(value, vlen, "", 0);
557 ctx->cert->raw_issuer_size,
558 value, vlen);
559 if (IS_ERR(kid)) 555 if (IS_ERR(kid))
560 return PTR_ERR(kid); 556 return PTR_ERR(kid);
561 pr_debug("authkeyid %*phN\n", kid->len, kid->data); 557 pr_debug("authkeyid %*phN\n", kid->len, kid->data);