forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
X.509: Add a crypto key parser for binary (DER) X.509 certificates
Add a crypto key parser for binary (DER) encoded X.509 certificates. The certificate is parsed and, if possible, the signature is verified. An X.509 key can be added like this: # keyctl padd crypto bar @s </tmp/x509.cert 15768135 and displayed like this: # cat /proc/keys 00f09a47 I--Q--- 1 perm 39390000 0 0 asymmetri bar: X509.RSA e9fd6d08 [] Note that this only works with binary certificates. PEM encoded certificates are ignored by the parser. Note also that the X.509 key ID is not congruent with the PGP key ID, but for the moment, they will match. If a NULL or "" name is given to add_key(), then the parser will generate a key description from the CertificateSerialNumber and Name fields of the TBSCertificate: 00aefc4e I--Q--- 1 perm 39390000 0 0 asymmetri bfbc0cd76d050ea4:/C=GB/L=Cambridge/O=Red Hat/CN=kernel key: X509.RSA 0c688c7b [] Signed-off-by: David Howells <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
- Loading branch information
1 parent
e104599
commit c26fd69
Showing
8 changed files
with
832 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*-asn1.[ch] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Certificate ::= SEQUENCE { | ||
tbsCertificate TBSCertificate ({ x509_note_tbs_certificate }), | ||
signatureAlgorithm AlgorithmIdentifier, | ||
signature BIT STRING ({ x509_note_signature }) | ||
} | ||
|
||
TBSCertificate ::= SEQUENCE { | ||
version [ 0 ] Version DEFAULT, | ||
serialNumber CertificateSerialNumber, | ||
signature AlgorithmIdentifier ({ x509_note_pkey_algo }), | ||
issuer Name ({ x509_note_issuer }), | ||
validity Validity, | ||
subject Name ({ x509_note_subject }), | ||
subjectPublicKeyInfo SubjectPublicKeyInfo, | ||
issuerUniqueID [ 1 ] IMPLICIT UniqueIdentifier OPTIONAL, | ||
subjectUniqueID [ 2 ] IMPLICIT UniqueIdentifier OPTIONAL, | ||
extensions [ 3 ] Extensions OPTIONAL | ||
} | ||
|
||
Version ::= INTEGER | ||
CertificateSerialNumber ::= INTEGER | ||
|
||
AlgorithmIdentifier ::= SEQUENCE { | ||
algorithm OBJECT IDENTIFIER ({ x509_note_OID }), | ||
parameters ANY OPTIONAL | ||
} | ||
|
||
Name ::= SEQUENCE OF RelativeDistinguishedName | ||
|
||
RelativeDistinguishedName ::= SET OF AttributeValueAssertion | ||
|
||
AttributeValueAssertion ::= SEQUENCE { | ||
attributeType OBJECT IDENTIFIER ({ x509_note_OID }), | ||
attributeValue ANY ({ x509_extract_name_segment }) | ||
} | ||
|
||
Validity ::= SEQUENCE { | ||
notBefore Time ({ x509_note_not_before }), | ||
notAfter Time ({ x509_note_not_after }) | ||
} | ||
|
||
Time ::= CHOICE { | ||
utcTime UTCTime, | ||
generalTime GeneralizedTime | ||
} | ||
|
||
SubjectPublicKeyInfo ::= SEQUENCE { | ||
algorithm AlgorithmIdentifier, | ||
subjectPublicKey BIT STRING ({ x509_extract_key_data }) | ||
} | ||
|
||
UniqueIdentifier ::= BIT STRING | ||
|
||
Extensions ::= SEQUENCE OF Extension | ||
|
||
Extension ::= SEQUENCE { | ||
extnid OBJECT IDENTIFIER ({ x509_note_OID }), | ||
critical BOOLEAN DEFAULT, | ||
extnValue OCTET STRING ({ x509_process_extension }) | ||
} |
Oops, something went wrong.