int crypto_platform_setup( crypto_platform_ctx *ctx ) { NRF_CRYPTOCELL->ENABLE = 1; if( SaSi_LibInit( &ctx->rndState, &rndWorkBuff ) != 0 ) return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED ); return ( 0 ); }
int main(void) { int ret = 0; /*Perform memory mapping*/ ret = integration_tests_setup(); if (ret != 0) { INTEG_TEST_PRINT("integration_tests_setup failed\n"); return ret; } /*Init SaSi library*/ ret = SaSi_LibInit(rndContext_ptr, rndWorkBuff_ptr); if (ret != SA_SILIB_RET_OK) { INTEG_TEST_PRINT("Failed SaSi_SiLibInit - ret = 0x%x\n", ret); goto exit_1; } /*Call ecc test*/ ret = rnd_tests(); if (ret != SA_SILIB_RET_OK) { INTEG_TEST_PRINT("Failure in rnd_test,ret = 0x%x\n", ret); goto exit_0; } INTEG_TEST_PRINT("All tests passed \n"); exit_0: /*Finish SaSi library*/ SaSi_LibFini(rndContext_ptr); exit_1: /*Unmap memory*/ integration_tests_clear(); return ret; }
static ret_code_t cc310_backend_init(void) { uint32_t ret_val; CRYSError_t crys_error; cc310_backend_mutex_init(); // Enable the CC310 HW. NRF_CRYPTOCELL->ENABLE = 1; // Initialize the CC310 run-time library crys_error = SaSi_LibInit(); // Shut down CC310 after initialization. NRF_CRYPTOCELL->ENABLE = 0; 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) // Do nothing #else #warning NRF_CRYPTO_RNG_AUTO_INIT_ENABLED define not found in sdk_config.h (Is the sdk_config.h valid?). #endif // NRF_CRYPTO_RNG_AUTO_INIT_ENABLED return ret_val; }