KEYS: Handle missing Authority Key Identifier x509 extension
Subsystems (3)
PATCH RESEND 1/1 KEYS: Handle missing Authority Key Identifier x509 extension
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 need to be the same anyway. This is noted in 4.2.1.1 as an exception for self-signed certificates where the keyIdentifier field may be empty.
There are root certificates in use where this is the case. This affects the checks in the restrict functions in crypto/asymmetric_keys/restrict.c but at the point the restrict functions run we have no access to the certificate struct to be able to do this substitution there. A self-signed certificate with the auth_ids NULL will fail the restrict checks while other self-signed certificates will be verified against themselves and pass.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -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;
Signature · 1 line
2.14.1
PATCH RESEND 1/1 KEYS: Handle missing Authority Key Identifier x509 extension
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 need to be the same anyway. This is noted in 4.2.1.1 as an exception for self-signed certificates where the keyIdentifier field may be empty.
There are root certificates in use where this is the case. This affects the checks in the restrict functions in crypto/asymmetric_keys/restrict.c but at the point the restrict functions run we have no access to the certificate struct to be able to do this substitution there. A self-signed certificate with the auth_ids NULL will fail the restrict checks while other self-signed certificates will be verified against themselves and pass.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -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;
Signature · 1 line
2.14.1
PATCH RESEND 1/1 KEYS: Handle missing Authority Key Identifier x509 extension
In reply to Andrew ZaborowskiIf 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.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -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;
Signature · 1 line
2.14.1
PATCH RESEND 1/1 KEYS: Handle missing Authority Key Identifier x509 extension
In reply to Andrew ZaborowskiIf 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.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -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;
Signature · 1 line
2.14.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Update comment for restrict_link_by_key_or_keyring_chain
Add the bit of information that makes restrict_link_by_key_or_keyring_chain different from restrict_link_by_key_or_keyring to the inline docs comment.
--- crypto/asymmetric_keys/restrict.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
crypto/asymmetric_keys/restrict.c +4 -3
@@ -244,9 +244,10 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring,* @payload: The payload of the new key. * @trusted: A key or ring of keys that can be used to vouch for the new cert. * -* Check the new certificate only against the key or keys passed in the data -* parameter. If one of those is the signing key and validates the new -* certificate, then mark the new certificate as being ok to link. +* Check the new certificate against the key or keys passed in the data +* parameter and against the keys already linked to the destination keyring. If +* one of those is the signing key and validates the new certificate, then mark +* the new certificate as being ok to link. * * Returns 0 if the new certificate was accepted, -ENOKEY if we * couldn't find a matching parent certificate in the trusted list,
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Update comment for restrict_link_by_key_or_keyring_chain
Add the bit of information that makes restrict_link_by_key_or_keyring_chain different from restrict_link_by_key_or_keyring to the inline docs comment.
--- crypto/asymmetric_keys/restrict.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
crypto/asymmetric_keys/restrict.c +4 -3
@@ -244,9 +244,10 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring,* @payload: The payload of the new key. * @trusted: A key or ring of keys that can be used to vouch for the new cert. * -* Check the new certificate only against the key or keys passed in the data -* parameter. If one of those is the signing key and validates the new -* certificate, then mark the new certificate as being ok to link. +* Check the new certificate against the key or keys passed in the data +* parameter and against the keys already linked to the destination keyring. If +* one of those is the signing key and validates the new certificate, then mark +* the new certificate as being ok to link. * * Returns 0 if the new certificate was accepted, -ENOKEY if we * couldn't find a matching parent certificate in the trusted list,
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Update comment for restrict_link_by_key_or_keyring_chain
Add the bit of information that makes restrict_link_by_key_or_keyring_chain different from restrict_link_by_key_or_keyring to the inline docs comment.
--- crypto/asymmetric_keys/restrict.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
crypto/asymmetric_keys/restrict.c +4 -3
@@ -244,9 +244,10 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring,* @payload: The payload of the new key. * @trusted: A key or ring of keys that can be used to vouch for the new cert. * -* Check the new certificate only against the key or keys passed in the data -* parameter. If one of those is the signing key and validates the new -* certificate, then mark the new certificate as being ok to link. +* Check the new certificate against the key or keys passed in the data +* parameter and against the keys already linked to the destination keyring. If +* one of those is the signing key and validates the new certificate, then mark +* the new certificate as being ok to link. * * Returns 0 if the new certificate was accepted, -ENOKEY if we * couldn't find a matching parent certificate in the trusted list,
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiIn a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1. crypto/asymmetric_keys/x509_cert_parser.c can't handle this and makes (at least) the restrict.c functions refuse to work with certificates that don't include the AKID. Fix this by filling in the missing cert->sig->auth_ids with the certificate's own IDs after parsing and determinig the certificate is self-signed.
The asymmetric_key_generate_id return value is not checked because it's already succeeded once at this point.
There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
crypto/asymmetric_keys/x509_cert_parser.c +19 -0
@@ -136,6 +136,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;
Signature · 1 line
2.20.1
PATCH RESEND 1/1 keys: Update comment for restrict_link_by_key_or_keyring_chain
Add the bit of information that makes restrict_link_by_key_or_keyring_chain different from restrict_link_by_key_or_keyring to the inline docs comment.
--- crypto/asymmetric_keys/restrict.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
crypto/asymmetric_keys/restrict.c +4 -3
@@ -244,9 +244,10 @@ int restrict_link_by_key_or_keyring(struct key *dest_keyring,* @payload: The payload of the new key. * @trusted: A key or ring of keys that can be used to vouch for the new cert. * -* Check the new certificate only against the key or keys passed in the data -* parameter. If one of those is the signing key and validates the new -* certificate, then mark the new certificate as being ok to link. +* Check the new certificate against the key or keys passed in the data +* parameter and against the keys already linked to the destination keyring. If +* one of those is the signing key and validates the new certificate, then mark +* the new certificate as being ok to link. * * Returns 0 if the new certificate was accepted, -ENOKEY if we * couldn't find a matching parent certificate in the trusted list,
Signature · 1 line
2.20.1
Re: [RESEND][PATCH] keys: Handle missing Authority Key Identifier X509 extension
In reply to Andrew ZaborowskiQuoted 9 lines · Andrew Zaborowski
In a self-signed certificate the subject and issuer are the same and so the Authority Key Identifier X.509 v3 extension is explicitly made optional in RFC5280 section 4.2.1.1.
crypto/asymmetric_keys/x509_cert_parser.ccan't handle this and makes (at least) therestrict.cfunctions refuse to work with certificates that don't include the AKID. Fix this by filling in the missingcert->sig->auth_idswith the certificate's own IDs after parsing and determinig the certificate is self-signed.
Quoted 7 lines
The
asymmetric_key_generate_idreturn value is not checked because it's already succeeded once at this point.There are root X.509 v3 certificates in use where this is the case, mostly oldish ones.
Signed-off-by Andrew Zaborowski <[email protected]>
Quoted 38 lines
--- crypto/asymmetric_keys/x509_cert_parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)crypto/asymmetric_keys/x509_cert_parser.c +19
-0@@ -136,6 +136,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;Signature · 1 line
2.20.1
/Jarkko