diff options
author | Janos Follath <janos.follath@arm.com> | 2016-11-01 16:39:47 +0000 |
---|---|---|
committer | Andres AG <andres.amayagarcia@arm.com> | 2017-03-15 13:44:26 +0000 |
commit | 46315740b8583e8f3a27ae4dd9bf463c81626f91 (patch) | |
tree | 08b81bef4afc6ea434981cda7ddc2d105bd895d6 | |
parent | 3234681a822faa7df65da2e9a00dc9cfc2a7962a (diff) | |
download | mbedtls-46315740b8583e8f3a27ae4dd9bf463c81626f91.zip mbedtls-46315740b8583e8f3a27ae4dd9bf463c81626f91.tar.gz mbedtls-46315740b8583e8f3a27ae4dd9bf463c81626f91.tar.bz2 |
Add global mutex for asymmetric crypto accelerator
The primary use case behind providing an abstraction layer to enable
alternative Elliptic Curve Point arithmetic implementation, is making
use of cryptographic acceleration hardware if it is present.
To provide thread safety for the hardware accelerator we need a mutex
to guard it.
-rw-r--r-- | include/mbedtls/threading.h | 3 | ||||
-rw-r--r-- | library/threading.c | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/mbedtls/threading.h b/include/mbedtls/threading.h index b0c34ec..d2d79a1 100644 --- a/include/mbedtls/threading.h +++ b/include/mbedtls/threading.h @@ -97,6 +97,9 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex ); */ extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex; +#if defined(MBEDTLS_ECP_FUNCTION_ALT) +extern mbedtls_threading_mutex_t mbedtls_threading_cryptohw_asym_mutex; +#endif #endif /* MBEDTLS_THREADING_C */ #ifdef __cplusplus diff --git a/library/threading.c b/library/threading.c index 83ec01a..b0cebd1 100644 --- a/library/threading.c +++ b/library/threading.c @@ -113,6 +113,9 @@ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * mbedtls_mutex_init( &mbedtls_threading_readdir_mutex ); mbedtls_mutex_init( &mbedtls_threading_gmtime_mutex ); +#if defined(MBEDTLS_ECP_FUNCTION_ALT) + mbedtls_mutex_init( &mbedtls_threading_cryptohw_asym_mutex ); +#endif } /* @@ -122,6 +125,9 @@ void mbedtls_threading_free_alt( void ) { mbedtls_mutex_free( &mbedtls_threading_readdir_mutex ); mbedtls_mutex_free( &mbedtls_threading_gmtime_mutex ); +#if defined(MBEDTLS_ECP_FUNCTION_ALT) + mbedtls_mutex_free( &mbedtls_threading_cryptohw_asym_mutex ); +#endif } #endif /* MBEDTLS_THREADING_ALT */ @@ -133,5 +139,8 @@ void mbedtls_threading_free_alt( void ) #endif mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT; mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex MUTEX_INIT; +#if defined(MBEDTLS_ECP_FUNCTION_ALT) +mbedtls_threading_mutex_t mbedtls_threading_cryptohw_asym_mutex MUTEX_INIT; +#endif #endif /* MBEDTLS_THREADING_C */ |