diff --git a/library/pk.c b/library/pk.c index 0a7a40bf6..5171961a7 100644 --- a/library/pk.c +++ b/library/pk.c @@ -544,11 +544,14 @@ int mbedtls_pk_sign_ext( mbedtls_pk_type_t pk_type, return( mbedtls_pk_sign( ctx, md_alg, hash, hash_len, sig, sig_size, sig_len, f_rng, p_rng ) ); } - - return( mbedtls_pk_psa_sign_ext( PSA_ALG_RSA_PSS( - mbedtls_psa_translate_md( md_alg ) ), - ctx->pk_ctx, hash, hash_len, - sig, sig_size, sig_len ) ); +#if defined(MBEDTLS_RSA_C) + return( mbedtls_pk_psa_rsa_sign_ext( PSA_ALG_RSA_PSS( + mbedtls_psa_translate_md( md_alg ) ), + ctx->pk_ctx, hash, hash_len, + sig, sig_size, sig_len ) ); +#else /* MBEDTLS_RSA_C */ + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); +#endif /* !MBEDTLS_RSA_C */ } #endif /* MBEDTLS_PSA_CRYPTO_C */ diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 76b7a1b8d..cc4d6f225 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -197,10 +197,10 @@ static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, } #if defined(MBEDTLS_PSA_CRYPTO_C) -int mbedtls_pk_psa_sign_ext( psa_algorithm_t psa_alg_md, void *pk_ctx, - const unsigned char *hash, size_t hash_len, - unsigned char *sig, size_t sig_size, - size_t *sig_len ) +int mbedtls_pk_psa_rsa_sign_ext( psa_algorithm_t psa_alg_md, void *pk_ctx, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t sig_size, + size_t *sig_len ) { mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) pk_ctx; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; @@ -269,10 +269,10 @@ static int rsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); #endif /* SIZE_MAX > UINT_MAX */ - return( mbedtls_pk_psa_sign_ext( PSA_ALG_RSA_PKCS1V15_SIGN( - mbedtls_psa_translate_md( md_alg ) ), - ctx, hash, hash_len, - sig, sig_size, sig_len ) ); + return( mbedtls_pk_psa_rsa_sign_ext( PSA_ALG_RSA_PKCS1V15_SIGN( + mbedtls_psa_translate_md( md_alg ) ), + ctx, hash, hash_len, + sig, sig_size, sig_len ) ); } #else static int rsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, diff --git a/library/pk_wrap.h b/library/pk_wrap.h index e31000596..5dae6b45c 100644 --- a/library/pk_wrap.h +++ b/library/pk_wrap.h @@ -150,10 +150,12 @@ int mbedtls_pk_error_from_psa_ecdsa( psa_status_t status ); int mbedtls_pk_error_from_psa_rsa( psa_status_t status ); #endif -int mbedtls_pk_psa_sign_ext( psa_algorithm_t psa_alg_md, void *ctx, - const unsigned char *hash, size_t hash_len, - unsigned char *sig, size_t sig_size, - size_t *sig_len ); +#if defined(MBEDTLS_RSA_C) +int mbedtls_pk_psa_rsa_sign_ext( psa_algorithm_t psa_alg_md, void *ctx, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t sig_size, + size_t *sig_len ); +#endif /* MBEDTLS_RSA_C */ #endif /* MBEDTLS_PSA_CRYPTO_C */