mirror of
https://github.com/espressif/mbedtls.git
synced 2026-11-12 10:40:58 +00:00
feat(component/mbedtls): Add support for RSASSA-PSS with RSA alt
This commit is contained in:
@@ -1344,6 +1344,20 @@ int mbedtls_pk_sign_ext(mbedtls_pk_type_t pk_type,
|
||||
sig, sig_size, sig_len);
|
||||
#else /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
|
||||
if (pk_type == MBEDTLS_PK_RSASSA_PSS) {
|
||||
mbedtls_rsa_alt_context *rsa_alt = ctx->pk_ctx;
|
||||
mbedtls_rsa_context *rsa = (mbedtls_rsa_context *)rsa_alt->key;
|
||||
mbedtls_rsa_set_padding(rsa, MBEDTLS_RSA_PKCS_V21, md_alg);
|
||||
return mbedtls_pk_sign(ctx, md_alg, hash, hash_len,
|
||||
sig, sig_size, sig_len, f_rng, p_rng);
|
||||
} else {
|
||||
return MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (sig_size < mbedtls_pk_get_len(ctx)) {
|
||||
return MBEDTLS_ERR_PK_BUFFER_TOO_SMALL;
|
||||
}
|
||||
@@ -1360,6 +1374,7 @@ int mbedtls_pk_sign_ext(mbedtls_pk_type_t pk_type,
|
||||
*sig_len = rsa_ctx->len;
|
||||
}
|
||||
return ret;
|
||||
#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
|
||||
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
|
||||
+1
-1
@@ -1278,7 +1278,7 @@ const mbedtls_pk_info_t mbedtls_ecdsa_info = {
|
||||
|
||||
static int rsa_alt_can_do(mbedtls_pk_type_t type)
|
||||
{
|
||||
return type == MBEDTLS_PK_RSA;
|
||||
return (type == MBEDTLS_PK_RSA) || (type == MBEDTLS_PK_RSASSA_PSS);
|
||||
}
|
||||
|
||||
static size_t rsa_alt_get_bitlen(mbedtls_pk_context *pk)
|
||||
|
||||
Reference in New Issue
Block a user