mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-23 05:31:02 +00:00
Merge remote-tracking branch 'origin/pr/2798' into development
* origin/pr/2798: Update the crypto submodule Use multipart PSA key derivation API
This commit is contained in:
commit
cfc9c8cdb8
2
crypto
2
crypto
|
@ -1 +1 @@
|
||||||
Subproject commit 89e76556910c2704313fe23b174f2742702a3a29
|
Subproject commit 21db2a94a482689e4e4f4e5473d4b5723c5394e4
|
|
@ -689,6 +689,52 @@ exit:
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
|
||||||
|
static psa_status_t setup_psa_key_derivation( psa_key_derivation_operation_t* derivation,
|
||||||
|
psa_key_handle_t slot,
|
||||||
|
psa_algorithm_t alg,
|
||||||
|
const unsigned char* seed, size_t seed_length,
|
||||||
|
const unsigned char* label, size_t label_length,
|
||||||
|
size_t capacity )
|
||||||
|
{
|
||||||
|
psa_status_t status;
|
||||||
|
|
||||||
|
status = psa_key_derivation_setup( derivation, alg );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
return( status );
|
||||||
|
|
||||||
|
if( PSA_ALG_IS_TLS12_PRF( alg ) || PSA_ALG_IS_TLS12_PSK_TO_MS( alg ) )
|
||||||
|
{
|
||||||
|
status = psa_key_derivation_input_bytes( derivation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_SEED,
|
||||||
|
seed, seed_length );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
return( status );
|
||||||
|
|
||||||
|
status = psa_key_derivation_input_key( derivation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||||
|
slot );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
return( status );
|
||||||
|
|
||||||
|
status = psa_key_derivation_input_bytes( derivation,
|
||||||
|
PSA_KEY_DERIVATION_INPUT_LABEL,
|
||||||
|
label, label_length );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
return( status );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
}
|
||||||
|
|
||||||
|
status = psa_key_derivation_set_capacity( derivation, capacity );
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
return( status );
|
||||||
|
|
||||||
|
return( PSA_SUCCESS );
|
||||||
|
}
|
||||||
|
|
||||||
static int tls_prf_generic( mbedtls_md_type_t md_type,
|
static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||||
const unsigned char *secret, size_t slen,
|
const unsigned char *secret, size_t slen,
|
||||||
const char *label,
|
const char *label,
|
||||||
|
@ -716,7 +762,7 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
|
|
||||||
status = psa_key_derivation( &derivation,
|
status = setup_psa_key_derivation( &derivation,
|
||||||
master_slot, alg,
|
master_slot, alg,
|
||||||
random, rlen,
|
random, rlen,
|
||||||
(unsigned char const *) label,
|
(unsigned char const *) label,
|
||||||
|
@ -1695,7 +1741,7 @@ static int ssl_compute_master( mbedtls_ssl_handshake_params *handshake,
|
||||||
else
|
else
|
||||||
alg = PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_256);
|
alg = PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_256);
|
||||||
|
|
||||||
status = psa_key_derivation( &derivation, psk, alg,
|
status = setup_psa_key_derivation( &derivation, psk, alg,
|
||||||
salt, salt_len,
|
salt, salt_len,
|
||||||
(unsigned char const *) lbl,
|
(unsigned char const *) lbl,
|
||||||
(size_t) strlen( lbl ),
|
(size_t) strlen( lbl ),
|
||||||
|
|
Loading…
Reference in a new issue