summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDemi Marie Obenour <demiobenour@gmail.com>2022-12-08 15:24:27 -0500
committerSandrine Bailleux <sandrine.bailleux@arm.com>2023-01-03 17:48:51 +0100
commit8816dbb3819e626d14e1bb9702f6446cb80e26f0 (patch)
tree1665bb4e4b2bdc2df24a3e225649558321ecc4d3 /drivers
parent2439a808863afbe20ccc6857cdea9b2cff2c08db (diff)
downloadarm-trusted-firmware-8816dbb3819e626d14e1bb9702f6446cb80e26f0.tar.gz
fix(auth): require bit strings to have no unused bits
This is already checked by the crypto module or by mbedTLS, but checking it in the X.509 parser is harmless. Change-Id: Ifdbe3b4c6d04481bb8e93106ee04b49a70f50d5d Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/auth/mbedtls/mbedtls_x509_parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c
index 244f1c95e..87f280c13 100644
--- a/drivers/auth/mbedtls/mbedtls_x509_parser.c
+++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c
@@ -281,7 +281,8 @@ static int cert_parse(void *img, unsigned int img_len)
}
p += len;
- ret = mbedtls_asn1_get_tag(&p, pk_end, &len, MBEDTLS_ASN1_BIT_STRING);
+ /* Key is a BIT STRING and must use all bytes in SubjectPublicKeyInfo */
+ ret = mbedtls_asn1_get_bitstring_null(&p, pk_end, &len);
if ((ret != 0) || (p + len != pk_end)) {
return IMG_PARSER_ERR_FORMAT;
}
@@ -422,7 +423,7 @@ static int cert_parse(void *img, unsigned int img_len)
* signatureValue BIT STRING
*/
signature.p = p;
- ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_BIT_STRING);
+ ret = mbedtls_asn1_get_bitstring_null(&p, end, &len);
if (ret != 0) {
return IMG_PARSER_ERR_FORMAT;
}