Merge pull request #5791 from superna9999/5788-unify-non-opaque-and-opaque-psks
Unify non-opaque and opaque PSKs
This commit is contained in:
commit
9bbb7bacae
@ -1428,7 +1428,6 @@ struct mbedtls_ssl_config
|
||||
* configured, this has value \c 0.
|
||||
*/
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
unsigned char *MBEDTLS_PRIVATE(psk); /*!< The raw pre-shared key. This field should
|
||||
* only be set via mbedtls_ssl_conf_psk().
|
||||
* If either no PSK or an opaque PSK
|
||||
|
@ -5371,7 +5371,6 @@ static psa_status_t psa_tls12_prf_psk_to_ms_set_key(
|
||||
*cur++ = MBEDTLS_BYTE_1( data_length );
|
||||
*cur++ = MBEDTLS_BYTE_0( data_length );
|
||||
memcpy( cur, data, data_length );
|
||||
mbedtls_platform_zeroize( (void*) data, data_length );
|
||||
cur += data_length;
|
||||
|
||||
status = psa_tls12_prf_set_key( prf, pms, cur - pms );
|
||||
|
@ -652,9 +652,11 @@ struct mbedtls_ssl_handshake_params
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
mbedtls_svc_key_id_t psk_opaque; /*!< Opaque PSK from the callback */
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
uint8_t psk_opaque_is_internal;
|
||||
#else
|
||||
unsigned char *psk; /*!< PSK from the callback */
|
||||
size_t psk_len; /*!< Length of PSK from callback */
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
|
||||
@ -1305,12 +1307,34 @@ void mbedtls_ssl_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl,
|
||||
size_t msg_len );
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl,
|
||||
mbedtls_key_exchange_type_t key_ex );
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
int mbedtls_ssl_conf_has_static_psk( mbedtls_ssl_config const *conf );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/**
|
||||
* Get the first defined opaque PSK by order of precedence:
|
||||
* 1. handshake PSK set by \c mbedtls_ssl_set_hs_psk_opaque() in the PSK
|
||||
* callback
|
||||
* 2. static PSK configured by \c mbedtls_ssl_conf_psk_opaque()
|
||||
* Return an opaque PSK
|
||||
*/
|
||||
static inline mbedtls_svc_key_id_t mbedtls_ssl_get_opaque_psk(
|
||||
const mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
return( ssl->handshake->psk_opaque );
|
||||
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->conf->psk_opaque ) )
|
||||
return( ssl->conf->psk_opaque );
|
||||
|
||||
return( MBEDTLS_SVC_KEY_ID_INIT );
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Get the first defined PSK by order of precedence:
|
||||
* 1. handshake PSK set by \c mbedtls_ssl_set_hs_psk() in the PSK callback
|
||||
@ -1341,27 +1365,6 @@ static inline int mbedtls_ssl_get_psk( const mbedtls_ssl_context *ssl,
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/**
|
||||
* Get the first defined opaque PSK by order of precedence:
|
||||
* 1. handshake PSK set by \c mbedtls_ssl_set_hs_psk_opaque() in the PSK
|
||||
* callback
|
||||
* 2. static PSK configured by \c mbedtls_ssl_conf_psk_opaque()
|
||||
* Return an opaque PSK
|
||||
*/
|
||||
static inline mbedtls_svc_key_id_t mbedtls_ssl_get_opaque_psk(
|
||||
const mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
return( ssl->handshake->psk_opaque );
|
||||
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->conf->psk_opaque ) )
|
||||
return( ssl->conf->psk_opaque );
|
||||
|
||||
return( MBEDTLS_SVC_KEY_ID_INIT );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
@ -1528,7 +1528,6 @@ static int ssl_conf_psk_is_configured( mbedtls_ssl_config const *conf )
|
||||
if( !mbedtls_svc_key_id_is_null( conf->psk_opaque ) )
|
||||
return( 1 );
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
if( conf->psk != NULL )
|
||||
return( 1 );
|
||||
|
||||
@ -1545,11 +1544,6 @@ static void ssl_conf_remove_psk( mbedtls_ssl_config *conf )
|
||||
* user's responsibility. */
|
||||
conf->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
}
|
||||
/* This and the following branch should never
|
||||
* be taken simultaenously as we maintain the
|
||||
* invariant that raw and opaque PSKs are never
|
||||
* configured simultaneously. As a safeguard,
|
||||
* though, `else` is omitted here. */
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
if( conf->psk != NULL )
|
||||
{
|
||||
@ -1631,10 +1625,16 @@ static void ssl_remove_psk( mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
{
|
||||
/* The maintenance of the external PSK key slot is the
|
||||
* user's responsibility. */
|
||||
if( ssl->handshake->psk_opaque_is_internal )
|
||||
{
|
||||
psa_destroy_key( ssl->handshake->psk_opaque );
|
||||
ssl->handshake->psk_opaque_is_internal = 0;
|
||||
}
|
||||
ssl->handshake->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#else
|
||||
if( ssl->handshake->psk != NULL )
|
||||
{
|
||||
mbedtls_platform_zeroize( ssl->handshake->psk,
|
||||
@ -1642,11 +1642,19 @@ static void ssl_remove_psk( mbedtls_ssl_context *ssl )
|
||||
mbedtls_free( ssl->handshake->psk );
|
||||
ssl->handshake->psk_len = 0;
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
|
||||
int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *psk, size_t psk_len )
|
||||
{
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_key_attributes_t key_attributes = psa_key_attributes_init();
|
||||
psa_status_t status;
|
||||
psa_algorithm_t alg;
|
||||
mbedtls_svc_key_id_t key;
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
if( psk == NULL || ssl->handshake == NULL )
|
||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
||||
|
||||
@ -1655,6 +1663,24 @@ int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl,
|
||||
|
||||
ssl_remove_psk( ssl );
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ssl->handshake->ciphersuite_info->mac == MBEDTLS_MD_SHA384)
|
||||
alg = PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_384);
|
||||
else
|
||||
alg = PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_256);
|
||||
|
||||
psa_set_key_usage_flags( &key_attributes, PSA_KEY_USAGE_DERIVE );
|
||||
psa_set_key_algorithm( &key_attributes, alg );
|
||||
psa_set_key_type( &key_attributes, PSA_KEY_TYPE_DERIVE );
|
||||
|
||||
status = psa_import_key( &key_attributes, psk, psk_len, &key );
|
||||
if( status != PSA_SUCCESS )
|
||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||
|
||||
/* Allow calling psa_destroy_key() on psk remove */
|
||||
ssl->handshake->psk_opaque_is_internal = 1;
|
||||
return mbedtls_ssl_set_hs_psk_opaque( ssl, key );
|
||||
#else
|
||||
if( ( ssl->handshake->psk = mbedtls_calloc( 1, psk_len ) ) == NULL )
|
||||
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
|
||||
|
||||
@ -1662,6 +1688,7 @@ int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl,
|
||||
memcpy( ssl->handshake->psk, psk, ssl->handshake->psk_len );
|
||||
|
||||
return( 0 );
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
@ -3231,11 +3258,25 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl )
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
{
|
||||
/* The maintenance of the external PSK key slot is the
|
||||
* user's responsibility. */
|
||||
if( ssl->handshake->psk_opaque_is_internal )
|
||||
{
|
||||
psa_destroy_key( ssl->handshake->psk_opaque );
|
||||
ssl->handshake->psk_opaque_is_internal = 0;
|
||||
}
|
||||
ssl->handshake->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
}
|
||||
#else
|
||||
if( handshake->psk != NULL )
|
||||
{
|
||||
mbedtls_platform_zeroize( handshake->psk, handshake->psk_len );
|
||||
mbedtls_free( handshake->psk );
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C) && \
|
||||
@ -4424,6 +4465,12 @@ void mbedtls_ssl_config_free( mbedtls_ssl_config *conf )
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ! mbedtls_svc_key_id_is_null( conf->psk_opaque ) )
|
||||
{
|
||||
conf->psk_opaque = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
if( conf->psk != NULL )
|
||||
{
|
||||
mbedtls_platform_zeroize( conf->psk, conf->psk_len );
|
||||
@ -4812,6 +4859,7 @@ int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl,
|
||||
static psa_status_t setup_psa_key_derivation( psa_key_derivation_operation_t* derivation,
|
||||
mbedtls_svc_key_id_t key,
|
||||
psa_algorithm_t alg,
|
||||
const unsigned char* raw_psk, size_t raw_psk_length,
|
||||
const unsigned char* seed, size_t seed_length,
|
||||
const unsigned char* label, size_t label_length,
|
||||
const unsigned char* other_secret,
|
||||
@ -4845,7 +4893,7 @@ static psa_status_t setup_psa_key_derivation( psa_key_derivation_operation_t* de
|
||||
{
|
||||
status = psa_key_derivation_input_bytes(
|
||||
derivation, PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||
NULL, 0 );
|
||||
raw_psk, raw_psk_length );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4911,6 +4959,7 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||
|
||||
status = setup_psa_key_derivation( &derivation,
|
||||
master_key, alg,
|
||||
NULL, 0,
|
||||
random, rlen,
|
||||
(unsigned char const *) label,
|
||||
(size_t) strlen( label ),
|
||||
@ -5100,30 +5149,6 @@ static int ssl_set_handshake_prfs( mbedtls_ssl_handshake_params *handshake,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED )
|
||||
static int ssl_use_opaque_psk( mbedtls_ssl_context const *ssl )
|
||||
{
|
||||
if( ssl->conf->f_psk != NULL )
|
||||
{
|
||||
/* If we've used a callback to select the PSK,
|
||||
* the static configuration is irrelevant. */
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->conf->psk_opaque ) )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||
MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
/*
|
||||
* Compute master secret if needed
|
||||
*
|
||||
@ -5196,8 +5221,7 @@ static int ssl_compute_master( mbedtls_ssl_handshake_params *handshake,
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
if( mbedtls_ssl_ciphersuite_uses_psk( handshake->ciphersuite_info ) == 1 &&
|
||||
ssl_use_opaque_psk( ssl ) == 1 )
|
||||
if( mbedtls_ssl_ciphersuite_uses_psk( handshake->ciphersuite_info ) == 1 )
|
||||
{
|
||||
/* Perform PSK-to-MS expansion in a single step. */
|
||||
psa_status_t status;
|
||||
@ -5240,6 +5264,7 @@ static int ssl_compute_master( mbedtls_ssl_handshake_params *handshake,
|
||||
}
|
||||
|
||||
status = setup_psa_key_derivation( &derivation, psk, alg,
|
||||
ssl->conf->psk, ssl->conf->psk_len,
|
||||
seed, seed_len,
|
||||
(unsigned char const *) lbl,
|
||||
(size_t) strlen( lbl ),
|
||||
@ -5472,7 +5497,8 @@ void ssl_calc_verify_tls_sha384( const mbedtls_ssl_context *ssl,
|
||||
}
|
||||
#endif /* MBEDTLS_SHA384_C */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exchange_type_t key_ex )
|
||||
{
|
||||
unsigned char *p = ssl->handshake->premaster;
|
||||
@ -5481,11 +5507,6 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
size_t psk_len = 0;
|
||||
int psk_ret = mbedtls_ssl_get_psk( ssl, &psk, &psk_len );
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
(void) key_ex;
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO && MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
|
||||
if( psk_ret == MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED )
|
||||
{
|
||||
/*
|
||||
@ -5560,19 +5581,10 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
p += 2 + len;
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K );
|
||||
|
||||
/* For opaque PSK fill premaster with the the shared secret without PSK. */
|
||||
if( psk_ret == MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||
( "skip PMS generation for opaque DHE-PSK" ) );
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
if( key_ex == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -5593,7 +5605,7 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
MBEDTLS_DEBUG_ECDH_Z );
|
||||
}
|
||||
else
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO && MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
@ -5616,7 +5628,7 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO && MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
static int ssl_write_hello_request( mbedtls_ssl_context *ssl );
|
||||
|
@ -62,37 +62,16 @@ int mbedtls_ssl_conf_has_static_psk( mbedtls_ssl_config const *conf )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
if( conf->psk != NULL && conf->psk_len != 0 )
|
||||
return( 1 );
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ! mbedtls_svc_key_id_is_null( conf->psk_opaque ) )
|
||||
return( 1 );
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
( defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) )
|
||||
static int ssl_conf_has_static_raw_psk( mbedtls_ssl_config const *conf )
|
||||
{
|
||||
if( conf->psk_identity == NULL ||
|
||||
conf->psk_identity_len == 0 )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
if( conf->psk != NULL && conf->psk_len != 0 )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||
( MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ||
|
||||
MBEDTLS_KEY_EXCHANGE_PSK_ENABLED ) */
|
||||
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
@ -3067,41 +3046,6 @@ ecdh_calc_secret:
|
||||
/* Write the ECDH computation length before the ECDH computation */
|
||||
MBEDTLS_PUT_UINT16_BE( zlen, pms, 0 );
|
||||
pms += zlen_size + zlen;
|
||||
|
||||
/* In case of opaque psk skip writting psk to pms.
|
||||
* Opaque key will be handled later. */
|
||||
if( ssl_conf_has_static_raw_psk( ssl->conf ) == 1 )
|
||||
{
|
||||
const unsigned char *psk = NULL;
|
||||
size_t psk_len = 0;
|
||||
|
||||
if( mbedtls_ssl_get_psk( ssl, &psk, &psk_len )
|
||||
== MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED )
|
||||
/*
|
||||
* This should never happen because the existence of a PSK is always
|
||||
* checked before calling this function
|
||||
*/
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
|
||||
/* opaque psk<0..2^16-1>; */
|
||||
if( (size_t)( pms_end - pms ) < ( 2 + psk_len ) )
|
||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
||||
|
||||
/* Write the PSK length as uint16 */
|
||||
MBEDTLS_PUT_UINT16_BE( psk_len, pms, 0 );
|
||||
pms += 2;
|
||||
|
||||
/* Write the PSK itself */
|
||||
memcpy( pms, psk, psk_len );
|
||||
pms += psk_len;
|
||||
|
||||
ssl->handshake->pmslen = pms - ssl->handshake->premaster;
|
||||
}
|
||||
else
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||
( "skip PMS generation for opaque ECDHE-PSK" ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||
@ -3182,6 +3126,25 @@ ecdh_calc_secret:
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_public", ret );
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
unsigned char *pms = ssl->handshake->premaster;
|
||||
unsigned char *pms_end = pms + sizeof( ssl->handshake->premaster );
|
||||
size_t pms_len;
|
||||
|
||||
/* Write length only when we know the actual value */
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx,
|
||||
pms + 2, pms_end - ( pms + 2 ), &pms_len,
|
||||
ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret );
|
||||
return( ret );
|
||||
}
|
||||
MBEDTLS_PUT_UINT16_BE( pms_len, pms, 0 );
|
||||
pms += 2 + pms_len;
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
|
||||
@ -3213,31 +3176,15 @@ ecdh_calc_secret:
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
|
||||
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK &&
|
||||
ssl_conf_has_static_raw_psk( ssl->conf ) == 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||
( "skip PMS generation for opaque PSK" ) );
|
||||
}
|
||||
else
|
||||
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK &&
|
||||
ssl_conf_has_static_raw_psk( ssl->conf ) == 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||
( "skip PMS generation for opaque RSA-PSK" ) );
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||
MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl,
|
||||
ciphersuite_info->key_exchange ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1,
|
||||
"mbedtls_ssl_psk_derive_premaster", ret );
|
||||
"mbedtls_ssl_psk_derive_premaster", ret );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
@ -160,43 +160,17 @@ static int ssl_conf_has_psk_or_cb( mbedtls_ssl_config const *conf )
|
||||
if( conf->psk_identity_len == 0 || conf->psk_identity == NULL )
|
||||
return( 0 );
|
||||
|
||||
if( conf->psk != NULL && conf->psk_len != 0 )
|
||||
return( 1 );
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ! mbedtls_svc_key_id_is_null( conf->psk_opaque ) )
|
||||
return( 1 );
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
( defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) )
|
||||
static int ssl_use_opaque_psk( mbedtls_ssl_context const *ssl )
|
||||
{
|
||||
if( ssl->conf->f_psk != NULL )
|
||||
{
|
||||
/* If we've used a callback to select the PSK,
|
||||
* the static configuration is irrelevant. */
|
||||
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
if( ! mbedtls_svc_key_id_is_null( ssl->conf->psk_opaque ) )
|
||||
if( conf->psk != NULL && conf->psk_len != 0 )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||
( MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ||
|
||||
MBEDTLS_KEY_EXCHANGE_PSK_ENABLED ||
|
||||
MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) */
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl,
|
||||
@ -4009,19 +3983,14 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/* For opaque PSKs, we perform the PSK-to-MS derivation atomatically
|
||||
* and skip the intermediate PMS. */
|
||||
if( ssl_use_opaque_psk( ssl ) == 1 )
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "skip PMS generation for opaque PSK" ) );
|
||||
else
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl,
|
||||
ciphersuite_info->key_exchange ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
|
||||
@ -4053,19 +4022,14 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/* For opaque PSKs, we perform the PSK-to-MS derivation automatically
|
||||
* and skip the intermediate PMS. */
|
||||
if( ssl_use_opaque_psk( ssl ) == 1 )
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "skip PMS generation for opaque RSA-PSK" ) );
|
||||
else
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl,
|
||||
ciphersuite_info->key_exchange ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */
|
||||
@ -4089,12 +4053,31 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
unsigned char *pms = ssl->handshake->premaster;
|
||||
unsigned char *pms_end = pms + sizeof( ssl->handshake->premaster );
|
||||
size_t pms_len;
|
||||
|
||||
/* Write length only when we know the actual value */
|
||||
if( ( ret = mbedtls_dhm_calc_secret( &ssl->handshake->dhm_ctx,
|
||||
pms + 2, pms_end - ( pms + 2 ), &pms_len,
|
||||
ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_calc_secret", ret );
|
||||
return( ret );
|
||||
}
|
||||
MBEDTLS_PUT_UINT16_BE( pms_len, pms, 0 );
|
||||
pms += 2 + pms_len;
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: K ", &ssl->handshake->dhm_ctx.K );
|
||||
#else
|
||||
if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl,
|
||||
ciphersuite_info->key_exchange ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_psk_derive_premaster", ret );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
|
||||
@ -4175,40 +4158,6 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||
MBEDTLS_PUT_UINT16_BE( zlen, psm, 0 );
|
||||
psm += zlen_size + zlen;
|
||||
|
||||
const unsigned char *psk = NULL;
|
||||
size_t psk_len = 0;
|
||||
|
||||
/* In case of opaque psk skip writting psk to pms.
|
||||
* Opaque key will be handled later. */
|
||||
if( ssl_use_opaque_psk( ssl ) == 0 )
|
||||
{
|
||||
if( mbedtls_ssl_get_psk( ssl, &psk, &psk_len )
|
||||
== MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED )
|
||||
/*
|
||||
* This should never happen because the existence of a PSK is always
|
||||
* checked before calling this function
|
||||
*/
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
|
||||
/* opaque psk<0..2^16-1>; */
|
||||
if( (size_t)( psm_end - psm ) < ( 2 + psk_len ) )
|
||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
||||
|
||||
/* Write the PSK length as uint16 */
|
||||
MBEDTLS_PUT_UINT16_BE( psk_len, psm, 0 );
|
||||
psm += 2;
|
||||
|
||||
/* Write the PSK itself */
|
||||
memcpy( psm, psk, psk_len );
|
||||
psm += psk_len;
|
||||
|
||||
ssl->handshake->pmslen = psm - ssl->handshake->premaster;
|
||||
}
|
||||
else
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||
( "skip PMS generation for opaque ECDHE-PSK" ) );
|
||||
}
|
||||
#else /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 )
|
||||
{
|
||||
|
102
tests/ssl-opt.sh
102
tests/ssl-opt.sh
@ -6399,8 +6399,6 @@ run_test "PSK callback: opaque psk on client, no callback" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque PSK"\
|
||||
-S "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6414,8 +6412,6 @@ run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque PSK"\
|
||||
-S "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6429,8 +6425,6 @@ run_test "PSK callback: opaque psk on client, no callback, EMS" \
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque PSK"\
|
||||
-S "skip PMS generation for opaque PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6444,8 +6438,6 @@ run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque PSK"\
|
||||
-S "skip PMS generation for opaque PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6459,8 +6451,6 @@ run_test "PSK callback: opaque rsa-psk on client, no callback" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6474,8 +6464,6 @@ run_test "PSK callback: opaque rsa-psk on client, no callback, SHA-384" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6489,8 +6477,6 @@ run_test "PSK callback: opaque rsa-psk on client, no callback, EMS" \
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "skip PMS generation for opaque RSA-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6504,8 +6490,6 @@ run_test "PSK callback: opaque rsa-psk on client, no callback, SHA-384, EMS"
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "skip PMS generation for opaque RSA-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6519,8 +6503,6 @@ run_test "PSK callback: opaque ecdhe-psk on client, no callback" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6534,8 +6516,6 @@ run_test "PSK callback: opaque ecdhe-psk on client, no callback, SHA-384" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6549,8 +6529,6 @@ run_test "PSK callback: opaque ecdhe-psk on client, no callback, EMS" \
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6564,8 +6542,6 @@ run_test "PSK callback: opaque ecdhe-psk on client, no callback, SHA-384, EMS
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6579,8 +6555,6 @@ run_test "PSK callback: opaque dhe-psk on client, no callback" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA256 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6594,8 +6568,6 @@ run_test "PSK callback: opaque dhe-psk on client, no callback, SHA-384" \
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6609,8 +6581,6 @@ run_test "PSK callback: opaque dhe-psk on client, no callback, EMS" \
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "skip PMS generation for opaque DHE-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6624,8 +6594,6 @@ run_test "PSK callback: opaque dhe-psk on client, no callback, SHA-384, EMS"
|
||||
"$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123 psk_opaque=1" \
|
||||
0 \
|
||||
-c "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "skip PMS generation for opaque DHE-PSK"\
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6639,8 +6607,6 @@ run_test "PSK callback: raw psk on client, static opaque on server, no callba
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6654,8 +6620,6 @@ run_test "PSK callback: raw psk on client, static opaque on server, no callba
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6672,8 +6636,6 @@ run_test "PSK callback: raw psk on client, static opaque on server, no callba
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6688,8 +6650,6 @@ run_test "PSK callback: raw psk on client, static opaque on server, no callba
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6701,8 +6661,6 @@ run_test "PSK callback: raw rsa-psk on client, static opaque on server, no ca
|
||||
"$P_CLI extended_ms=0 debug_level=5 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6716,8 +6674,6 @@ run_test "PSK callback: raw rsa-psk on client, static opaque on server, no ca
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6734,8 +6690,6 @@ run_test "PSK callback: raw rsa-psk on client, static opaque on server, no ca
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6750,8 +6704,6 @@ run_test "PSK callback: raw rsa-psk on client, static opaque on server, no ca
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6763,8 +6715,6 @@ run_test "PSK callback: raw ecdhe-psk on client, static opaque on server, no
|
||||
"$P_CLI extended_ms=0 debug_level=5 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6778,8 +6728,6 @@ run_test "PSK callback: raw ecdhe-psk on client, static opaque on server, no
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6796,8 +6744,6 @@ run_test "PSK callback: raw ecdhe-psk on client, static opaque on server, no
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6812,8 +6758,6 @@ run_test "PSK callback: raw ecdhe-psk on client, static opaque on server, no
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6825,8 +6769,6 @@ run_test "PSK callback: raw dhe-psk on client, static opaque on server, no ca
|
||||
"$P_CLI extended_ms=0 debug_level=5 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6840,8 +6782,6 @@ run_test "PSK callback: raw dhe-psk on client, static opaque on server, no ca
|
||||
"$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=foo psk=abc123" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6858,8 +6798,6 @@ run_test "PSK callback: raw dhe-psk on client, static opaque on server, no ca
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6874,8 +6812,6 @@ run_test "PSK callback: raw dhe-psk on client, static opaque on server, no ca
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6887,8 +6823,6 @@ run_test "PSK callback: raw psk on client, no static PSK on server, opaque PS
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6902,8 +6836,6 @@ run_test "PSK callback: raw psk on client, no static PSK on server, opaque PS
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6920,8 +6852,6 @@ run_test "PSK callback: raw psk on client, no static PSK on server, opaque PS
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6936,8 +6866,6 @@ run_test "PSK callback: raw psk on client, no static PSK on server, opaque PS
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6949,8 +6877,6 @@ run_test "PSK callback: raw rsa-psk on client, no static RSA-PSK on server, o
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6964,8 +6890,6 @@ run_test "PSK callback: raw rsa-psk on client, no static RSA-PSK on server, o
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-RSA-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -6982,8 +6906,6 @@ run_test "PSK callback: raw rsa-psk on client, no static RSA-PSK on server, o
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -6998,8 +6920,6 @@ run_test "PSK callback: raw rsa-psk on client, no static RSA-PSK on server, o
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque RSA-PSK"\
|
||||
-s "skip PMS generation for opaque RSA-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -7011,8 +6931,6 @@ run_test "PSK callback: raw ecdhe-psk on client, no static ECDHE-PSK on serve
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7026,8 +6944,6 @@ run_test "PSK callback: raw ecdhe-psk on client, no static ECDHE-PSK on serve
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7044,8 +6960,6 @@ run_test "PSK callback: raw ecdhe-psk on client, no static ECDHE-PSK on serve
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -7060,8 +6974,6 @@ run_test "PSK callback: raw ecdhe-psk on client, no static ECDHE-PSK on serve
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-s "skip PMS generation for opaque ECDHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -7073,8 +6985,6 @@ run_test "PSK callback: raw dhe-psk on client, no static DHE-PSK on server, o
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7088,8 +6998,6 @@ run_test "PSK callback: raw dhe-psk on client, no static DHE-PSK on server, o
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-DHE-PSK-WITH-AES-256-CBC-SHA384 \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7106,8 +7014,6 @@ run_test "PSK callback: raw dhe-psk on client, no static DHE-PSK on server, o
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -7122,8 +7028,6 @@ run_test "PSK callback: raw dhe-psk on client, no static DHE-PSK on server, o
|
||||
0 \
|
||||
-c "session hash for extended master secret"\
|
||||
-s "session hash for extended master secret"\
|
||||
-C "skip PMS generation for opaque DHE-PSK"\
|
||||
-s "skip PMS generation for opaque DHE-PSK"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
-S "SSL - Unknown identity received" \
|
||||
-S "SSL - Verification of the message MAC failed"
|
||||
@ -7135,8 +7039,6 @@ run_test "PSK callback: raw psk on client, mismatching static raw PSK on serv
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7150,8 +7052,6 @@ run_test "PSK callback: raw psk on client, mismatching static opaque PSK on s
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-s "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7165,7 +7065,6 @@ run_test "PSK callback: raw psk on client, mismatching static opaque PSK on s
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
@ -7179,7 +7078,6 @@ run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on s
|
||||
"$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
|
||||
psk_identity=def psk=beef" \
|
||||
0 \
|
||||
-C "skip PMS generation for opaque PSK"\
|
||||
-C "session hash for extended master secret"\
|
||||
-S "session hash for extended master secret"\
|
||||
-S "SSL - The handshake negotiation failed" \
|
||||
|
@ -5310,6 +5310,7 @@ void test_multiple_psks()
|
||||
|
||||
mbedtls_ssl_config conf;
|
||||
|
||||
USE_PSA_INIT( );
|
||||
mbedtls_ssl_config_init( &conf );
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_conf_psk( &conf,
|
||||
@ -5323,6 +5324,8 @@ void test_multiple_psks()
|
||||
exit:
|
||||
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
|
||||
USE_PSA_DONE( );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user