123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #include "sdk_common.h"
- #if NRF_MODULE_ENABLED(NRF_CRYPTO) && NRF_MODULE_ENABLED(NRF_CRYPTO_BACKEND_CC310)
- #include "nrf.h"
- #include "nrf_crypto_init.h"
- #include "cc310_backend_shared.h"
- #include "sns_silib.h"
- #include "cc310_backend_mutex.h"
- #include "nrf_crypto_rng.h"
- static uint32_t init_result_get(uint32_t crys_error)
- {
- uint32_t ret_val = NRF_ERROR_INTERNAL;
- switch (crys_error)
- {
- case CRYS_OK:
- ret_val = NRF_SUCCESS;
- break;
- default:
- ret_val = NRF_ERROR_INTERNAL;
- break;
- }
- return ret_val;
- }
- static ret_code_t cc310_backend_init(void)
- {
- uint32_t ret_val;
- CRYSError_t crys_error;
- cc310_backend_mutex_init();
-
- crys_error = SaSi_LibInit();
- ret_val = init_result_get(crys_error);
- VERIFY_SUCCESS(ret_val);
- #if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1)
- ret_val = nrf_crypto_rng_init(NULL, NULL);
- VERIFY_SUCCESS(ret_val);
- #elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0)
-
- #else
- #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?).
- #endif
- return ret_val;
- }
- static ret_code_t cc310_backend_uninit(void)
- {
- #if defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 1)
- uint32_t ret_val;
- ret_val = nrf_crypto_rng_init(NULL, NULL);
- VERIFY_SUCCESS(ret_val);
- #elif defined(NRF_CRYPTO_RNG_AUTO_INIT_ENABLED) && (NRF_CRYPTO_RNG_AUTO_INIT_ENABLED == 0)
-
- #else
- #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?).
- #endif
- SaSi_LibFini();
- return NRF_SUCCESS;
- }
- CRYPTO_BACKEND_REGISTER(nrf_crypto_backend_info_t const cc310_backend) =
- {
- .init_fn = cc310_backend_init,
- .uninit_fn = cc310_backend_uninit,
- };
- #endif
|