/ src / crypto / crypto_shared.cpp
crypto_shared.cpp
 1  #include "crypto_shared.h"
 2  
 3  #include "app_error.h"
 4  #include "nrf_crypto.h"
 5  
 6  #include "crypto_log_module.ii"
 7  
 8  namespace crypto
 9  {
10  	namespace
11  	{
12  		bool cryptoInitialized = false;
13  	}
14  
15  	void Initialize()
16  	{
17  		if (cryptoInitialized)
18  		{
19  			return;
20  		}
21  
22  		CryptoErrorCheck(nrf_crypto_init());
23  
24  		cryptoInitialized = true;
25  
26  		NRF_LOG_INFO("Initialized.");
27  	}
28  
29  	ret_code_t CryptoErrorCheck(ret_code_t retCode)
30  	{
31  		if (retCode != NRF_SUCCESS)
32  		{
33  			NRF_LOG_WARNING("Error: %s", nrf_crypto_error_string_get(retCode));
34  			APP_ERROR_CHECK(retCode);
35  		}
36  
37  		return retCode;
38  	}
39  }