mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Fix and test pk_copy_from_psa with an unsupported algorithm
Fix mbedtls_pk_copy_from_psa() and mbedtls_pk_copy_public_from_psa() to still work when the algorithm in the key policy is not an RSA algorithm (typically PSA_ALG_NONE). Add a dedicated test case and adjust the test code. Fixes the test case "Copy from PSA: non-exportable -> public, RSA" when MBEDTLS_PKCS1_V15 is disabled. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -1444,7 +1444,8 @@ static int copy_from_psa(mbedtls_svc_key_id_t key_id,
|
||||
|
||||
if (PSA_ALG_IS_RSA_OAEP(alg_type) || PSA_ALG_IS_RSA_PSS(alg_type)) {
|
||||
ret = mbedtls_rsa_set_padding(mbedtls_pk_rsa(*pk), MBEDTLS_RSA_PKCS_V21, md_type);
|
||||
} else {
|
||||
} else if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg_type) ||
|
||||
alg_type == PSA_ALG_RSA_PKCS1V15_CRYPT) {
|
||||
ret = mbedtls_rsa_set_padding(mbedtls_pk_rsa(*pk), MBEDTLS_RSA_PKCS_V15, md_type);
|
||||
}
|
||||
if (ret != 0) {
|
||||
|
Reference in New Issue
Block a user