Finalize PSA hash operations in TLS 1.3

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2022-01-07 22:09:01 +01:00
parent 4279bac965
commit f6893e11c7

View file

@ -7476,12 +7476,40 @@ int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl,
size_t dst_len,
size_t *olen )
{
((void) ssl);
((void) md);
((void) dst);
((void) dst_len);
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
psa_hash_operation_t *hash_operation_to_clone;
psa_hash_operation_t hash_operation = psa_hash_operation_init();
*olen = 0;
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE);
switch( md )
{
#if defined(MBEDTLS_SHA384_C)
case MBEDTLS_MD_SHA384:
hash_operation_to_clone = &ssl->handshake->fin_sha384_psa;
break;
#endif
#if defined(MBEDTLS_SHA256_C)
case MBEDTLS_MD_SHA256:
hash_operation_to_clone = &ssl->handshake->fin_sha256_psa;
break;
#endif
default:
goto exit;
}
status = psa_hash_clone( hash_operation_to_clone, &hash_operation );
if( status != PSA_SUCCESS )
goto exit;
status = psa_hash_finish( &hash_operation, dst, dst_len, olen );
if( status != PSA_SUCCESS )
goto exit;
exit:
return( ( status == PSA_SUCCESS ) ? 0 : MBEDTLS_ERR_ERROR_GENERIC_ERROR );
}
#else /* MBEDTLS_USE_PSA_CRYPTO */