Also check the RSA length for public keys

Do for public keys what
"Fix mbedtls_pk_get_bitlen() for RSA with non-byte-aligned sizes"
did for key pairs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2024-02-12 16:59:17 +01:00
parent 59d09486dc
commit 069cec1737

View file

@ -100,6 +100,10 @@ void pk_parse_public_keyfile_rsa(char *key_file, int result)
rsa = mbedtls_pk_rsa(ctx);
TEST_EQUAL(mbedtls_rsa_check_pubkey(rsa), 0);
size_t bitlen = mbedtls_rsa_get_bitlen(rsa);
TEST_EQUAL(mbedtls_pk_get_bitlen(&ctx), bitlen);
TEST_EQUAL(mbedtls_pk_get_len(&ctx), (bitlen + 7) / 8);
#if defined(MBEDTLS_PSA_CRYPTO_C)
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
TEST_EQUAL(mbedtls_pk_get_psa_attributes(&ctx,