#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"
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.
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;
Curl_ssh_cleanup();
- crypto_cleanup();
-
#ifdef DEBUGBUILD
free(leakpointer);
#endif
*/
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)
entropy_cleanup_mutex(&ts_entropy);
#endif
(void)Curl_mbedtlsthreadlock_thread_cleanup();
+ mbedtls_psa_crypto_free();
}
static bool mbedtls_data_pending(struct Curl_cfilter *cf,