From: Andrew Zaborowski Date: Tue, 07 Apr 2020 00:26:07 +0000 Subject: [RFC] keys: Verify public keys without X509 AKID Message-Id: <20200407002607.25234-1-andrew.zaborowski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: To: keyrings@vger.kernel.org There are apparently non-root X.509 v3 certificates in use out there that contain no Authority Key Identifier extension (RFC5280 section 4.2.1.1) which the kernel asymmetric key code relies on for any lookup and verification. I'm not sure if these certificates are generated by openssl with a special setting or by some other software. Looking at RFC5280 4.2.1.1 it says: "This extension is used where an issuer has multiple signing keys [...]" making it sound like the extension is optional if the issuer uses only one signing key. It also says: "The keyIdentifier field of the authorityKeyIdentifier extension MUST be included in all certificates [...]" making it sound like it's mandatory for everyone. Openssl does treat the AKID extensions as completely optional but there's no comment in the code explaining the reasoning. I propose to add lookups by just the Distinguished Names in the certificate to solve this. The change is a little more invasive than I'd like but I think it makes sense to support these certificates. A third id would have to be added to the struct asymmetric_key_ids declaration in asymmetric-type.h, and to the struct public_key_signature::auth_ids declaration in public_key.h, a third ID parameter in find_asymmetric_key() and a third query syntax like "name:" would have to be supported in addition to "id:.." and "ex:..", which would be used then the other two IDs are not present. The combinatino of the three IDs in struct asymmetric_key_ids would still be unique to each key. Lookups would be unambiguous provided that the CAs respect the condition that the AKID may only be omitted if they use a single signing key. What's your opinion about adding this before I spend time on it? Best regards