mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-19 05:10:40 +00:00
altcp: mbedtls: no need for SYS_ARCH locking
This commit is contained in:
parent
33f2b313c7
commit
34352e9649
@ -720,8 +720,8 @@ altcp_mbedtls_debug(void *ctx, int level, const char *file, int line, const char
|
|||||||
static err_t
|
static err_t
|
||||||
altcp_mbedtls_ref_entropy(void)
|
altcp_mbedtls_ref_entropy(void)
|
||||||
{
|
{
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
SYS_ARCH_PROTECT(old_level);
|
|
||||||
if (!altcp_tls_entropy_rng) {
|
if (!altcp_tls_entropy_rng) {
|
||||||
altcp_tls_entropy_rng = (struct altcp_tls_entropy_rng *)altcp_mbedtls_alloc_config(sizeof(struct altcp_tls_entropy_rng));
|
altcp_tls_entropy_rng = (struct altcp_tls_entropy_rng *)altcp_mbedtls_alloc_config(sizeof(struct altcp_tls_entropy_rng));
|
||||||
if (altcp_tls_entropy_rng) {
|
if (altcp_tls_entropy_rng) {
|
||||||
@ -739,29 +739,25 @@ altcp_mbedtls_ref_entropy(void)
|
|||||||
mbedtls_entropy_free(&altcp_tls_entropy_rng->entropy);
|
mbedtls_entropy_free(&altcp_tls_entropy_rng->entropy);
|
||||||
altcp_mbedtls_free_config(altcp_tls_entropy_rng);
|
altcp_mbedtls_free_config(altcp_tls_entropy_rng);
|
||||||
altcp_tls_entropy_rng = NULL;
|
altcp_tls_entropy_rng = NULL;
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
|
||||||
return ERR_ARG;
|
return ERR_ARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
altcp_tls_entropy_rng->ref++;
|
altcp_tls_entropy_rng->ref++;
|
||||||
}
|
}
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
altcp_mbedtls_unref_entropy(void)
|
altcp_mbedtls_unref_entropy(void)
|
||||||
{
|
{
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
SYS_ARCH_PROTECT(old_level);
|
|
||||||
if (altcp_tls_entropy_rng && altcp_tls_entropy_rng->ref) {
|
if (altcp_tls_entropy_rng && altcp_tls_entropy_rng->ref) {
|
||||||
altcp_tls_entropy_rng->ref--;
|
altcp_tls_entropy_rng->ref--;
|
||||||
}
|
}
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create new TLS configuration
|
/** Create new TLS configuration
|
||||||
@ -1053,15 +1049,14 @@ altcp_tls_free_config(struct altcp_tls_config *conf)
|
|||||||
void
|
void
|
||||||
altcp_tls_free_entropy(void)
|
altcp_tls_free_entropy(void)
|
||||||
{
|
{
|
||||||
SYS_ARCH_DECL_PROTECT(old_level);
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
SYS_ARCH_PROTECT(old_level);
|
|
||||||
if (altcp_tls_entropy_rng && altcp_tls_entropy_rng->ref == 0) {
|
if (altcp_tls_entropy_rng && altcp_tls_entropy_rng->ref == 0) {
|
||||||
mbedtls_ctr_drbg_free(&altcp_tls_entropy_rng->ctr_drbg);
|
mbedtls_ctr_drbg_free(&altcp_tls_entropy_rng->ctr_drbg);
|
||||||
mbedtls_entropy_free(&altcp_tls_entropy_rng->entropy);
|
mbedtls_entropy_free(&altcp_tls_entropy_rng->entropy);
|
||||||
altcp_mbedtls_free_config(altcp_tls_entropy_rng);
|
altcp_mbedtls_free_config(altcp_tls_entropy_rng);
|
||||||
altcp_tls_entropy_rng = NULL;
|
altcp_tls_entropy_rng = NULL;
|
||||||
}
|
}
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "virtual" functions */
|
/* "virtual" functions */
|
||||||
|
Loading…
Reference in New Issue
Block a user