mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:45:42 +01:00
Add ssl_conf_dhm_min_bitlen()
This commit is contained in:
parent
bf27eaac79
commit
bd990d6629
@ -577,6 +577,10 @@ struct mbedtls_ssl_config
|
||||
unsigned int badmac_limit; /*!< limit of records with a bad MAC */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
|
||||
unsigned int dhm_min_bitlen; /*!< min. bit length of the DHM prime */
|
||||
#endif
|
||||
|
||||
unsigned char max_major_ver; /*!< max. major version used */
|
||||
unsigned char max_minor_ver; /*!< max. minor version used */
|
||||
unsigned char min_major_ver; /*!< min. major version used */
|
||||
@ -1477,6 +1481,19 @@ int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, cons
|
||||
int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx );
|
||||
#endif /* MBEDTLS_DHM_C && defined(MBEDTLS_SSL_SRV_C) */
|
||||
|
||||
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
|
||||
/**
|
||||
* \brief Set the minimum length for Diffie-Hellman parameters.
|
||||
* (Client-side only.)
|
||||
* (Default: 1024 bits.)
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param bitlen Minimum bit length of the DHM prime
|
||||
*/
|
||||
void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf,
|
||||
unsigned int bitlen );
|
||||
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SET_CURVES)
|
||||
/**
|
||||
* \brief Set the allowed curves in order of preference.
|
||||
|
@ -1648,10 +1648,11 @@ static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl, unsigned char *
|
||||
return( ret );
|
||||
}
|
||||
|
||||
if( ssl->handshake->dhm_ctx.len < 64 ||
|
||||
ssl->handshake->dhm_ctx.len > 512 )
|
||||
if( ssl->handshake->dhm_ctx.len * 8 < ssl->conf->dhm_min_bitlen )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message (DHM length)" ) );
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHM prime too short: %d < %d",
|
||||
ssl->handshake->dhm_ctx.len * 8,
|
||||
ssl->conf->dhm_min_bitlen ) );
|
||||
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
|
||||
}
|
||||
|
||||
|
@ -5458,6 +5458,17 @@ int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context
|
||||
}
|
||||
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
|
||||
/*
|
||||
* Set the minimum length for Diffie-Hellman parameters
|
||||
*/
|
||||
void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf,
|
||||
unsigned int bitlen )
|
||||
{
|
||||
conf->dhm_min_bitlen = bitlen;
|
||||
}
|
||||
#endif /* MBEDTLS_DHM_C && MBEDTLS_SSL_CLI_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SET_CURVES)
|
||||
/*
|
||||
* Set the allowed elliptic curves
|
||||
@ -6665,6 +6676,10 @@ int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf,
|
||||
conf->renego_period[7] = 0x00;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
|
||||
conf->dhm_min_bitlen = 1024;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
|
||||
if( endpoint == MBEDTLS_SSL_IS_SERVER )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user