Fix parsing of authorityCertSerialNumber (use valid tags)

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2023-05-03 16:19:16 +02:00
parent f5b8f78ad7
commit 8194285cf1
2 changed files with 3 additions and 4 deletions

View file

@ -674,13 +674,12 @@ static int x509_get_authority_key_id(unsigned char **p,
/* Getting authorityCertSerialNumber using the required specific class tag [2] */
if ((ret = mbedtls_asn1_get_tag(p, end, &len,
MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_INTEGER |
2)) != 0) {
MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2)) != 0) {
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS, ret);
} else {
authority_key_id->authorityCertSerialNumber.len = len;
authority_key_id->authorityCertSerialNumber.p = *p;
authority_key_id->authorityCertSerialNumber.tag = MBEDTLS_ASN1_OCTET_STRING;
authority_key_id->authorityCertSerialNumber.tag = MBEDTLS_ASN1_INTEGER;
*p += len;
}
}

View file

@ -1538,7 +1538,7 @@ void x509_crt_parse_authoritykeyid(data_t *buf,
/* Serial test */
TEST_ASSERT(crt.authority_key_id.authorityCertSerialNumber.tag ==
MBEDTLS_ASN1_OCTET_STRING);
MBEDTLS_ASN1_INTEGER);
TEST_ASSERT(crt.authority_key_id.authorityCertSerialNumber.len == serialLength);
} else {
TEST_ASSERT(crt.authority_key_id.keyIdentifier.tag == 0);