mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-18 05:42:35 +00:00
Merge pull request #8741 from Ryan-Everett-arm/add-locking-macros
Add macros for locking/unlocking the key slot mutex
This commit is contained in:
commit
47c74a4773
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
#include "psa/crypto_se_driver.h"
|
#include "psa/crypto_se_driver.h"
|
||||||
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
#include "mbedtls/threading.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell if PSA is ready for this hash.
|
* Tell if PSA is ready for this hash.
|
||||||
@ -111,6 +114,49 @@ typedef struct {
|
|||||||
} key;
|
} key;
|
||||||
} psa_key_slot_t;
|
} psa_key_slot_t;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
|
|
||||||
|
/** Perform a mutex operation and return immediately upon failure.
|
||||||
|
*
|
||||||
|
* Returns PSA_ERROR_SERVICE_FAILURE if the operation fails
|
||||||
|
* and status was PSA_SUCCESS.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* psa_status_t status exists.
|
||||||
|
* f is a mutex operation which returns 0 upon success.
|
||||||
|
*/
|
||||||
|
#define PSA_THREADING_CHK_RET(f) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if ((f) != 0) { \
|
||||||
|
if (status == PSA_SUCCESS) { \
|
||||||
|
return PSA_ERROR_SERVICE_FAILURE; \
|
||||||
|
} \
|
||||||
|
return status; \
|
||||||
|
} \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
/** Perform a mutex operation and goto exit on failure.
|
||||||
|
*
|
||||||
|
* Sets status to PSA_ERROR_SERVICE_FAILURE if status was PSA_SUCCESS.
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* psa_status_t status exists.
|
||||||
|
* Label exit: exists.
|
||||||
|
* f is a mutex operation which returns 0 upon success.
|
||||||
|
*/
|
||||||
|
#define PSA_THREADING_CHK_GOTO_EXIT(f) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if ((f) != 0) { \
|
||||||
|
if (status == PSA_SUCCESS) { \
|
||||||
|
status = PSA_ERROR_SERVICE_FAILURE; \
|
||||||
|
} \
|
||||||
|
goto exit; \
|
||||||
|
} \
|
||||||
|
} while (0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A mask of key attribute flags used only internally.
|
/* A mask of key attribute flags used only internally.
|
||||||
* Currently there aren't any. */
|
* Currently there aren't any. */
|
||||||
#define PSA_KA_MASK_INTERNAL_ONLY ( \
|
#define PSA_KA_MASK_INTERNAL_ONLY ( \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user