]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(auth): reject padding after BIT STRING in signatures
authorDemi Marie Obenour <demiobenour@gmail.com>
Thu, 8 Dec 2022 20:24:10 +0000 (15:24 -0500)
committerDemi Marie Obenour <demiobenour@gmail.com>
Thu, 29 Dec 2022 23:41:10 +0000 (18:41 -0500)
It is forbidden by ASN.1 DER.

Change-Id: Id8a48e14bb8a1a17a6481ea3fde0803723c05e31
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
drivers/auth/mbedtls/mbedtls_crypto.c

index 178bbf5f45f1083f4ed97ae323d3f1f1abbea252..42a09255da48b34f6d28761a77d16ba9ba82c8f3 100644 (file)
@@ -115,7 +115,7 @@ static int verify_signature(void *data_ptr, unsigned int data_len,
        end = (unsigned char *)(p + sig_len);
        signature.tag = *p;
        rc = mbedtls_asn1_get_bitstring_null(&p, end, &signature.len);
-       if (rc != 0) {
+       if ((rc != 0) || ((size_t)(end - p) != signature.len)) {
                rc = CRYPTO_ERR_SIGNATURE;
                goto end1;
        }