mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 08:04:24 +01:00
Use MBEDTLS_ECJPAKE_C def. for correct conditional compilation
This commit is contained in:
parent
4feb7ae8c2
commit
136884c29b
@ -209,7 +209,7 @@ static void ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl,
|
|||||||
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
static void ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl,
|
static void ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
size_t *olen )
|
size_t *olen )
|
||||||
@ -278,7 +278,7 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
|||||||
|
|
||||||
*olen = 6;
|
*olen = 6;
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_ECJPAKE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
||||||
@ -287,7 +287,7 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
const unsigned char *end = ssl->out_buf + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
||||||
size_t kkpp_len;
|
size_t kkpp_len;
|
||||||
|
|
||||||
*olen = 0;
|
*olen = 0;
|
||||||
@ -856,7 +856,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
ssl_write_supported_elliptic_curves_ext( ssl, p + 2 + ext_len, &olen );
|
ssl_write_supported_elliptic_curves_ext( ssl, p + 2 + ext_len, &olen );
|
||||||
ext_len += olen;
|
ext_len += olen;
|
||||||
|
|
||||||
@ -1076,7 +1076,8 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl,
|
|||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
size_t len )
|
size_t len )
|
||||||
@ -1097,7 +1098,12 @@ static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
|||||||
if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED ||
|
if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED ||
|
||||||
p[0] == MBEDTLS_ECP_PF_COMPRESSED )
|
p[0] == MBEDTLS_ECP_PF_COMPRESSED )
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
||||||
ssl->handshake->ecdh_ctx.point_format = p[0];
|
ssl->handshake->ecdh_ctx.point_format = p[0];
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_ECJPAKE_C)
|
||||||
|
ssl->handshake->ecjpake_ctx.point_format = p[0];
|
||||||
|
#endif
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) );
|
MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -1109,7 +1115,7 @@ static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
|||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "no point format in common" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "no point format in common" ) );
|
||||||
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */
|
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_ECJPAKE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
||||||
@ -1629,7 +1635,8 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
|||||||
break;
|
break;
|
||||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS:
|
case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS:
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported_point_formats extension" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported_point_formats extension" ) );
|
||||||
|
|
||||||
@ -1640,7 +1647,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */
|
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_ECJPAKE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
case MBEDTLS_TLS_EXT_ECJPAKE_KKPP:
|
case MBEDTLS_TLS_EXT_ECJPAKE_KKPP:
|
||||||
|
@ -232,7 +232,8 @@ have_sig_alg:
|
|||||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
|
||||||
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
static int ssl_parse_supported_elliptic_curves( mbedtls_ssl_context *ssl,
|
static int ssl_parse_supported_elliptic_curves( mbedtls_ssl_context *ssl,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
size_t len )
|
size_t len )
|
||||||
@ -305,7 +306,12 @@ static int ssl_parse_supported_point_formats( mbedtls_ssl_context *ssl,
|
|||||||
if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED ||
|
if( p[0] == MBEDTLS_ECP_PF_UNCOMPRESSED ||
|
||||||
p[0] == MBEDTLS_ECP_PF_COMPRESSED )
|
p[0] == MBEDTLS_ECP_PF_COMPRESSED )
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
||||||
ssl->handshake->ecdh_ctx.point_format = p[0];
|
ssl->handshake->ecdh_ctx.point_format = p[0];
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_ECJPAKE_C)
|
||||||
|
ssl->handshake->ecjpake_ctx.point_format = p[0];
|
||||||
|
#endif
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) );
|
MBEDTLS_SSL_DEBUG_MSG( 4, ( "point format selected: %d", p[0] ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -316,7 +322,7 @@ static int ssl_parse_supported_point_formats( mbedtls_ssl_context *ssl,
|
|||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */
|
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_ECJPAKE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
||||||
@ -1579,7 +1585,8 @@ read_record_header:
|
|||||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
|
||||||
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES:
|
case MBEDTLS_TLS_EXT_SUPPORTED_ELLIPTIC_CURVES:
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported elliptic curves extension" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported elliptic curves extension" ) );
|
||||||
|
|
||||||
@ -1596,7 +1603,7 @@ read_record_header:
|
|||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
break;
|
break;
|
||||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C */
|
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_ECJPAKE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
case MBEDTLS_TLS_EXT_ECJPAKE_KKPP:
|
case MBEDTLS_TLS_EXT_ECJPAKE_KKPP:
|
||||||
@ -2062,7 +2069,7 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
const unsigned char *end = ssl->out_buf + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
||||||
size_t kkpp_len;
|
size_t kkpp_len;
|
||||||
|
|
||||||
*olen = 0;
|
*olen = 0;
|
||||||
@ -2383,7 +2390,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
defined(MBEDTLS_ECJPAKE_C)
|
||||||
ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen );
|
ssl_write_supported_point_formats_ext( ssl, p + 2 + ext_len, &olen );
|
||||||
ext_len += olen;
|
ext_len += olen;
|
||||||
#endif
|
#endif
|
||||||
@ -2639,12 +2646,14 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl )
|
|||||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||||
unsigned char *p = ssl->out_msg + 4;
|
unsigned char *p = ssl->out_msg + 4;
|
||||||
unsigned char *dig_signed = p;
|
unsigned char *dig_signed = p;
|
||||||
size_t dig_signed_len = 0, len;
|
size_t dig_signed_len = 0, len;
|
||||||
((void) dig_signed);
|
((void) dig_signed);
|
||||||
((void) dig_signed_len);
|
((void) dig_signed_len);
|
||||||
|
((void) len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) );
|
||||||
@ -2679,7 +2688,7 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl )
|
|||||||
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE )
|
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE )
|
||||||
{
|
{
|
||||||
size_t jlen;
|
size_t jlen;
|
||||||
const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
const unsigned char *end = ssl->out_buf + MBEDTLS_SSL_MAX_CONTENT_LEN;
|
||||||
|
|
||||||
ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx,
|
ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx,
|
||||||
p, end - p, &jlen, ssl->conf->f_rng, ssl->conf->p_rng );
|
p, end - p, &jlen, ssl->conf->f_rng, ssl->conf->p_rng );
|
||||||
|
Loading…
Reference in New Issue
Block a user