diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c index 01e956fbd..c11ad2881 100644 --- a/library/ssl_tls13_keys.c +++ b/library/ssl_tls13_keys.c @@ -1567,12 +1567,12 @@ cleanup: return( ret ); } - +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) int mbedtls_ssl_tls13_export_handshake_psk( mbedtls_ssl_context *ssl, unsigned char **psk, size_t *psk_len ) { -#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) + #if defined(MBEDTLS_USE_PSA_CRYPTO) psa_key_attributes_t key_attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status; @@ -1581,7 +1581,7 @@ int mbedtls_ssl_tls13_export_handshake_psk( mbedtls_ssl_context *ssl, *psk = NULL; if( mbedtls_svc_key_id_is_null( ssl->handshake->psk_opaque ) ) - return( 0 ); + return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); status = psa_get_key_attributes( ssl->handshake->psk_opaque, &key_attributes ); if( status != PSA_SUCCESS ) @@ -1612,14 +1612,8 @@ int mbedtls_ssl_tls13_export_handshake_psk( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED ); return( 0 ); #endif /* !MBEDTLS_USE_PSA_CRYPTO */ -#else /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ - ((void) ssl); - *psk = NULL; - *psk_len = 0; - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); -#endif /* !MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ - } +#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */ diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h index 34c00a479..ea553e35d 100644 --- a/library/ssl_tls13_keys.h +++ b/library/ssl_tls13_keys.h @@ -692,21 +692,22 @@ int mbedtls_ssl_tls13_compute_handshake_transform( mbedtls_ssl_context *ssl ); MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_ssl_tls13_compute_application_transform( mbedtls_ssl_context *ssl ); +#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) /** * \brief Export TLS 1.3 PSK from handshake context * - * \param ssl The SSL context to operate on. - * \param psk PSK output pointer. - * \param psk_len - * Length of PSK. + * \param[in] ssl The SSL context to operate on. + * \param[out] psk PSK output pointer. + * \param[out] psk_len Length of PSK. * - * \returns \c 0 on success. + * \returns \c 0 if there is configured PSK and exported success. * \returns A negative error code on failure. */ MBEDTLS_CHECK_RETURN_CRITICAL int mbedtls_ssl_tls13_export_handshake_psk( mbedtls_ssl_context *ssl, unsigned char **psk, size_t *psk_len ); +#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */