mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-03 06:01:08 +00:00
Adapt ssl_get_ecdh_params_from_cert() to use raw public key
We must dispatch between the peer's public key stored as part of the peer's CRT in the current session structure (situation until now, and future behaviour if MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is enabled), and the sole public key stored in the handshake structure (new, if MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is disabled).
This commit is contained in:
parent
374800a231
commit
53b6b7e09b
|
@ -2429,21 +2429,26 @@ static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
const mbedtls_ecp_keypair *peer_key;
|
const mbedtls_ecp_keypair *peer_key;
|
||||||
|
mbedtls_pk_context * peer_pk;
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
|
||||||
|
peer_pk = &ssl->handshake->peer_pubkey;
|
||||||
|
#else /* !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||||
if( ssl->session_negotiate->peer_cert == NULL )
|
if( ssl->session_negotiate->peer_cert == NULL )
|
||||||
{
|
{
|
||||||
/* Should never happen */
|
/* Should never happen */
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||||
}
|
}
|
||||||
|
peer_pk = &ssl->session_negotiate->peer_cert->pk;
|
||||||
|
#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||||
|
|
||||||
if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk,
|
if( ! mbedtls_pk_can_do( peer_pk, MBEDTLS_PK_ECKEY ) )
|
||||||
MBEDTLS_PK_ECKEY ) )
|
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) );
|
||||||
return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH );
|
return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH );
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_key = mbedtls_pk_ec( ssl->session_negotiate->peer_cert->pk );
|
peer_key = mbedtls_pk_ec( *peer_pk );
|
||||||
|
|
||||||
if( ( ret = mbedtls_ecdh_get_params( &ssl->handshake->ecdh_ctx, peer_key,
|
if( ( ret = mbedtls_ecdh_get_params( &ssl->handshake->ecdh_ctx, peer_key,
|
||||||
MBEDTLS_ECDH_THEIRS ) ) != 0 )
|
MBEDTLS_ECDH_THEIRS ) ) != 0 )
|
||||||
|
|
Loading…
Reference in a new issue