All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: keyrings@vger.kernel.org
Subject: [RESEND][PATCH] KEYS: Handle missing Authority Key Identifier x509 extension
Date: Fri, 08 Feb 2019 14:35:31 +0000	[thread overview]
Message-ID: <20190208143531.15655-1-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <20180505060152.21571-1-andrew.zaborowski@intel.com>

If the certificate is self-signed and the Key Identifier is not present
in the Authority Key Identifier extension (RFC5280 4.2.1.1), fill in the
sig->auth_ids values with the certificate's own key IDs since they must
be the same.  A note in 4.2.1.1 makes the AKID keyIdentifier optional
in self-signed certificates as an exception.

There are root certificates in use where this is the case.  This would
affect the checks in the restrict functions in
crypto/asymmetric_keys/restrict.c.  As a consequence the restrict
functions would behave differently depending on whether the (optional)
AKID was found or not.

The asymmetric_key_generate_id return value is not checked because it's
already succeeded once at this point.

Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
---
 crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index b6cabac4b6..1424f20703 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -130,6 +130,25 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 	if (ret < 0)
 		goto error_decode;
 
+	if (cert->self_signed) {
+		if (!cert->sig->auth_ids[0]) {
+			/* Duplicate cert->id */
+			kid = asymmetric_key_generate_id(cert->raw_serial,
+							 cert->raw_serial_size,
+							 cert->raw_issuer,
+							 cert->raw_issuer_size);
+			cert->sig->auth_ids[0] = kid;
+		}
+
+		if (!cert->sig->auth_ids[1] && cert->skid) {
+			/* Duplicate cert->skid */
+			kid = asymmetric_key_generate_id(cert->raw_skid,
+							 cert->raw_skid_size,
+							 "", 0);
+			cert->sig->auth_ids[1] = kid;
+		}
+	}
+
 	kfree(ctx);
 	return cert;
 
-- 
2.14.1

  parent reply	other threads:[~2019-02-08 14:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-05  6:01 [RESEND][PATCH] KEYS: Handle missing Authority Key Identifier x509 extension Andrew Zaborowski
2018-08-18  0:11 ` Andrew Zaborowski
2018-10-19 22:13 ` Andrew Zaborowski
2019-02-08 14:35 ` Andrew Zaborowski [this message]
2020-04-07  0:25 ` [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension Andrew Zaborowski
2020-05-04  8:51 ` Andrew Zaborowski
2020-06-25 22:10 ` Andrew Zaborowski
2020-06-25 22:10   ` [RESEND][PATCH] keys: Update comment for restrict_link_by_key_or_keyring_chain Andrew Zaborowski
2020-07-29 23:49 ` [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension Andrew Zaborowski
2020-07-29 23:50   ` [RESEND][PATCH] keys: Update comment for restrict_link_by_key_or_keyring_chain Andrew Zaborowski
2020-09-07 10:39 ` [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension Andrew Zaborowski
2020-09-07 10:39   ` [RESEND][PATCH] keys: Update comment for restrict_link_by_key_or_keyring_chain Andrew Zaborowski
2020-10-13 13:39 ` [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension Andrew Zaborowski
2020-10-13 13:39   ` [RESEND][PATCH] keys: Update comment for restrict_link_by_key_or_keyring_chain Andrew Zaborowski
2020-10-18 20:22 ` [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension Jarkko Sakkinen
2020-10-18 20:22   ` Jarkko Sakkinen
2020-05-04  9:08 [RESEND][PATCH] keys: Update comment for restrict_link_by_key_or_keyring_chain Andrew Zaborowski
2020-10-18 20:25 ` Jarkko Sakkinen
2020-10-18 20:25   ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190208143531.15655-1-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=keyrings@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.