Add signature scheme rsa pss
Signed-off-by: XiaokangQian <xiaokang.qian@arm.com>
This commit is contained in:
parent
146247de71
commit
82d34ccf47
2 changed files with 32 additions and 1 deletions
|
@ -6370,6 +6370,12 @@ static uint16_t ssl_preset_default_sig_algs[] = {
|
|||
MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512,
|
||||
#endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP521R1_ENABLED */
|
||||
#endif /* MBEDTLS_ECDSA_C */
|
||||
|
||||
/* RSA algorithms */
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256,
|
||||
#endif
|
||||
|
||||
MBEDTLS_TLS13_SIG_NONE
|
||||
};
|
||||
|
||||
|
|
|
@ -320,6 +320,11 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
|||
unsigned char verify_hash[MBEDTLS_MD_MAX_SIZE];
|
||||
size_t verify_hash_len;
|
||||
|
||||
void const *opts_ptr = NULL;
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
mbedtls_pk_rsassa_pss_options opts;
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
|
||||
/*
|
||||
* struct {
|
||||
* SignatureScheme algorithm;
|
||||
|
@ -368,6 +373,13 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
|||
md_alg = MBEDTLS_MD_SHA512;
|
||||
sig_alg = MBEDTLS_PK_ECDSA;
|
||||
break;
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
case MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256:
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "Certificate Verify: using RSA" ) );
|
||||
md_alg = MBEDTLS_MD_SHA256;
|
||||
sig_alg = MBEDTLS_PK_RSASSA_PSS;
|
||||
break;
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
default:
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) );
|
||||
goto error;
|
||||
|
@ -426,8 +438,21 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
|||
}
|
||||
|
||||
MBEDTLS_SSL_DEBUG_BUF( 3, "verify hash", verify_hash, verify_hash_len );
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
|
||||
if( sig_alg == MBEDTLS_PK_RSASSA_PSS )
|
||||
{
|
||||
const mbedtls_md_info_t* md_info;
|
||||
opts.mgf1_hash_id = md_alg;
|
||||
if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL )
|
||||
{
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
opts.expected_salt_len = mbedtls_md_get_size( md_info );
|
||||
opts_ptr = (const void*) &opts;
|
||||
}
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
|
||||
if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL,
|
||||
if( ( ret = mbedtls_pk_verify_ext( sig_alg, opts_ptr,
|
||||
&ssl->session_negotiate->peer_cert->pk,
|
||||
md_alg, verify_hash, verify_hash_len,
|
||||
p, signature_len ) ) == 0 )
|
||||
|
|
Loading…
Reference in a new issue