mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-30 00:46:22 -04:00
Protect PSA drivers_initialized with mutex
Writes to this in psa_crypto_init() were again already covered. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
8e15153637
commit
358165246b
@ -119,6 +119,23 @@ static uint8_t psa_get_initialized(void)
|
|||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t psa_get_drivers_initialized(void)
|
||||||
|
{
|
||||||
|
uint8_t initialized;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
mbedtls_mutex_lock(&mbedtls_threading_psa_globaldata_mutex);
|
||||||
|
#endif /* defined(MBEDTLS_THREADING_C) */
|
||||||
|
|
||||||
|
initialized = global_data.drivers_initialized;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
mbedtls_mutex_unlock(&mbedtls_threading_psa_globaldata_mutex);
|
||||||
|
#endif /* defined(MBEDTLS_THREADING_C) */
|
||||||
|
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
#define GUARD_MODULE_INITIALIZED \
|
#define GUARD_MODULE_INITIALIZED \
|
||||||
if (psa_get_initialized() == 0) \
|
if (psa_get_initialized() == 0) \
|
||||||
return PSA_ERROR_BAD_STATE;
|
return PSA_ERROR_BAD_STATE;
|
||||||
@ -126,14 +143,14 @@ static uint8_t psa_get_initialized(void)
|
|||||||
int psa_can_do_hash(psa_algorithm_t hash_alg)
|
int psa_can_do_hash(psa_algorithm_t hash_alg)
|
||||||
{
|
{
|
||||||
(void) hash_alg;
|
(void) hash_alg;
|
||||||
return global_data.drivers_initialized;
|
return psa_get_drivers_initialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
int psa_can_do_cipher(psa_key_type_t key_type, psa_algorithm_t cipher_alg)
|
int psa_can_do_cipher(psa_key_type_t key_type, psa_algorithm_t cipher_alg)
|
||||||
{
|
{
|
||||||
(void) key_type;
|
(void) key_type;
|
||||||
(void) cipher_alg;
|
(void) cipher_alg;
|
||||||
return global_data.drivers_initialized;
|
return psa_get_drivers_initialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user