mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-11 21:41:47 +03:00
Merge pull request #8779 from gilles-peskine-arm/rsa-bitlen-fix
Fix mbedtls_pk_get_bitlen for a key size that is not a multiple of 8
This commit is contained in:
@ -58,7 +58,7 @@ static int rsa_can_do(mbedtls_pk_type_t type)
|
||||
static size_t rsa_get_bitlen(mbedtls_pk_context *pk)
|
||||
{
|
||||
const mbedtls_rsa_context *rsa = (const mbedtls_rsa_context *) pk->pk_ctx;
|
||||
return 8 * mbedtls_rsa_get_len(rsa);
|
||||
return mbedtls_rsa_get_bitlen(rsa);
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
|
@ -1014,6 +1014,14 @@ int mbedtls_rsa_get_md_alg(const mbedtls_rsa_context *ctx)
|
||||
return ctx->hash_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get length in bits of RSA modulus
|
||||
*/
|
||||
size_t mbedtls_rsa_get_bitlen(const mbedtls_rsa_context *ctx)
|
||||
{
|
||||
return mbedtls_mpi_bitlen(&ctx->N);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get length in bytes of RSA modulus
|
||||
*/
|
||||
|
Reference in New Issue
Block a user