From ce882b53649f754f92e0e7e42fee81ffd9561d53 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Thu, 8 Dec 2022 15:24:36 -0500 Subject: [PATCH] refactor(auth): do not include SEQUENCE tag in saved extensions This makes the code a little bit smaller. No functional change intended. Change-Id: I794d2927fcd034a79e29c9bba1f8e4410203f547 Signed-off-by: Demi Marie Obenour --- drivers/auth/mbedtls/mbedtls_x509_parser.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c index d8f201e98..4b880d99c 100644 --- a/drivers/auth/mbedtls/mbedtls_x509_parser.c +++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c @@ -85,9 +85,6 @@ static int get_ext(const char *oid, void **ext, unsigned int *ext_len) p = v3_ext.p; end = v3_ext.p + v3_ext.len; - mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | - MBEDTLS_ASN1_SEQUENCE); - while (p < end) { zeromem(&extn_oid, sizeof(extn_oid)); is_critical = 0; /* DEFAULT FALSE */ @@ -274,6 +271,7 @@ static int cert_parse(void *img, unsigned int img_len) pk_end = p + len; pk.len = pk_end - pk.p; + /* algorithm */ ret = mbedtls_asn1_get_tag(&p, pk_end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE); if (ret != 0) { @@ -342,13 +340,13 @@ static int cert_parse(void *img, unsigned int img_len) * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension * -- must use all remaining bytes in TBSCertificate */ - v3_ext.p = p; ret = mbedtls_asn1_get_tag(&p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE); if ((ret != 0) || (len != (size_t)(end - p))) { return IMG_PARSER_ERR_FORMAT; } - v3_ext.len = end - v3_ext.p; + v3_ext.p = p; + v3_ext.len = len; /* * Check extensions integrity. At least one extension is -- 2.39.5