← Commit list

e29706d6e2

Daniel Stenberg
Daniel Stenberg
2025-10-17
SUCCESS Duration: 505s

Subject

mbedtls: move the crypto init into the vtls init function

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/easy.c+0 -29
@@ -80,10 +80,6 @@
#include "easy_lock.h"
-#ifdef USE_MBEDTLS
-#include <psa/crypto.h>
-#endif
-
/* The last 2 #include files should be in this order */
#include "curl_memory.h"
#include "memdebug.h"
@@ -141,24 +137,6 @@ curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
static char *leakpointer;
#endif
-static CURLcode crypto_init(void)
-{
-#ifdef USE_MBEDTLS
- psa_status_t status;
- status = psa_crypto_init();
- if(status != PSA_SUCCESS)
- return CURLE_FAILED_INIT;
-#endif
- return CURLE_OK;
-}
-
-static void crypto_cleanup(void)
-{
-#ifdef USE_MBEDTLS
- mbedtls_psa_crypto_free();
-#endif
-}
-
/**
* curl_global_init() globally initializes curl given a bitwise set of the
* different features of what to initialize.
@@ -182,11 +160,6 @@ static CURLcode global_init(long flags, bool memoryfuncs)
goto fail;
}
- if(crypto_init()) {
- DEBUGF(curl_mfprintf(stderr, "Error: crypto_init failed\n"));
- goto fail;
- }
-
if(!Curl_ssl_init()) {
DEBUGF(curl_mfprintf(stderr, "Error: Curl_ssl_init failed\n"));
goto fail;
@@ -325,8 +298,6 @@ void curl_global_cleanup(void)
Curl_ssh_cleanup();
- crypto_cleanup();
-
#ifdef DEBUGBUILD
free(leakpointer);
#endif
lib/vtls/mbedtls.c+5 -0
@@ -1449,6 +1449,10 @@ static CURLcode mbedtls_connect(struct Curl_cfilter *cf,
*/
static int mbedtls_init(void)
{
+ psa_status_t status;
+ status = psa_crypto_init();
+ if(status != PSA_SUCCESS)
+ return 0;
if(!Curl_mbedtlsthreadlock_thread_setup())
return 0;
#if defined(CURL_MBEDTLS_DRBG) && defined(HAS_THREADING_SUPPORT)
@@ -1463,6 +1467,7 @@ static void mbedtls_cleanup(void)
entropy_cleanup_mutex(&ts_entropy);
#endif
(void)Curl_mbedtlsthreadlock_thread_cleanup();
+ mbedtls_psa_crypto_free();
}
static bool mbedtls_data_pending(struct Curl_cfilter *cf,