From e73664bdf5e584841fc2eb1ea2c1c5744f4206a0 Mon Sep 17 00:00:00 2001 From: Apprentice-Alchemist <53486764+Apprentice-Alchemist@users.noreply.github.com> Date: Wed, 1 May 2024 12:12:54 +0200 Subject: [PATCH] [ssl] Initialize PSA crypto when it is present. In mbedtls 3.6 TLS 1.3 support is turned on by default which uses PSA crypto See https://github.com/HaxeFoundation/hashlink/pull/681 --- libs/ssl/ssl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/ssl/ssl.c b/libs/ssl/ssl.c index 29222743..651980c1 100644 --- a/libs/ssl/ssl.c +++ b/libs/ssl/ssl.c @@ -35,6 +35,10 @@ typedef int SOCKET; #include "mbedtls/x509_crt.h" #include "mbedtls/ssl.h" +#ifdef MBEDTLS_PSA_CRYPTO_C +#include +#endif + #define val_ssl(o) (mbedtls_ssl_context*)val_data(o) #define val_conf(o) (mbedtls_ssl_config*)val_data(o) #define val_cert(o) (mbedtls_x509_crt*)val_data(o) @@ -807,6 +811,10 @@ void ssl_main() { mbedtls_entropy_init( &entropy ); mbedtls_ctr_drbg_init( &ctr_drbg ); mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0 ); + +#ifdef MBEDTLS_PSA_CRYPTO_C + psa_crypto_init(); +#endif } DEFINE_PRIM( ssl_new, 1 );