pkparse: fix check for ASN1 errors in mbedtls_pk_parse_subpubkey()

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2024-02-02 13:59:51 +01:00
parent fc590dd361
commit 5a19892528

View file

@ -854,7 +854,8 @@ int mbedtls_pk_parse_subpubkey(unsigned char **p, const unsigned char *end,
if (ret == 0) { if (ret == 0) {
/* On success all the input has been consumed by the parsing function. */ /* On success all the input has been consumed by the parsing function. */
*p += end - *p; *p += end - *p;
} else if (ret & 0x7f) { } else if ((ret <= MBEDTLS_ERR_ASN1_OUT_OF_DATA) &&
(ret >= MBEDTLS_ERR_ASN1_BUF_TOO_SMALL)) {
/* In case of ASN1 error codes add MBEDTLS_ERR_PK_INVALID_PUBKEY. */ /* In case of ASN1 error codes add MBEDTLS_ERR_PK_INVALID_PUBKEY. */
ret = MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PK_INVALID_PUBKEY, ret); ret = MBEDTLS_ERROR_ADD(MBEDTLS_ERR_PK_INVALID_PUBKEY, ret);
} else { } else {