[Nuvoton] Fix crypto AC management
1. For SHA AC, use atomic flag to manage its ownership. (1) Nuvoton SHA AC doesn't support SHA context save & restore, so S/W SHA fallback has been supported before. To make non-blocking 'acquire' semantics clearer, introduce 'try_acquire' to substitute for 'acquire'. (2) No biting CPU due to mechanism above. (3) No deadlock due to mechanism above. 2. For AES/DES/ECC AC, change to mutex to manage their ownership. (1) Change crypto-misc.c to crypto-misc.cpp to utilize C++ SingletonPtr which guarantees thread-safe mutex construct-on-first-use. (2) With change to crypto-misc.cpp, add 'extern "C"' modifier to CRYPTO_IRQHandler() to avoid name mangling in C++. (3) No priority inversion because mutex has osMutexPrioInherit attribute bit set. (4) No deadlock because these AC are all locked for a short sequence of operations rather than the whole lifetime of mbedtls context. (5) For double mbedtls_internal_ecp_init() issue, it has been fixed in upper mbedtls layer. So no need to change ecc init/free flow. |
---|
|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/aes/aes_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/sha/sha1_alt.c |
---|
features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/sha/sha256_alt.c |
---|
targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.c 100644 → 0 |
---|
targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.cpp 0 → 100644 |
---|
targets/TARGET_NUVOTON/TARGET_M480/crypto/crypto-misc.h |
---|
targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.c 100644 → 0 |
---|
targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.cpp 0 → 100644 |
---|
targets/TARGET_NUVOTON/TARGET_NUC472/crypto/crypto-misc.h |
---|