x509_get_authority_key_id: add length check + test

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2023-02-01 11:06:08 +01:00
parent 8661fed943
commit 6ec839a1f9
2 changed files with 9 additions and 0 deletions

View file

@ -751,6 +751,11 @@ static int x509_get_authority_key_id(unsigned char **p,
return ret;
}
if (*p + len != end) {
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH);
}
if ((ret = mbedtls_asn1_get_tag(p, end, &len,
MBEDTLS_ASN1_CONTEXT_SPECIFIC)) != 0) {
/* KeyIdentifier is an OPTIONAL field */