30
30
#include < platform/PlatformManager.h>
31
31
#include < platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp>
32
32
#include < platform/silabs/DiagnosticDataProviderImpl.h>
33
+
33
34
#if defined(TINYCRYPT_PRIMITIVES)
34
35
#include " tinycrypt/ecc.h"
35
36
#endif
39
40
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
40
41
41
42
#include " AppConfig.h"
42
- #include " FreeRTOS.h"
43
43
44
44
using namespace chip ::DeviceLayer::Internal;
45
45
46
46
namespace chip {
47
47
namespace DeviceLayer {
48
48
49
49
PlatformManagerImpl PlatformManagerImpl::sInstance ;
50
+
51
+ #if SLI_SI91X_MCU_INTERFACE
50
52
#if defined(TINYCRYPT_PRIMITIVES)
51
53
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL ;
52
- #endif
53
54
54
- #if defined(TINYCRYPT_PRIMITIVES)
55
55
int PlatformManagerImpl::uECC_RNG_Function (uint8_t * dest, unsigned int size)
56
56
{
57
- int res;
58
-
59
57
sys_mutex_lock (&rngMutexHandle);
60
- res = (chip::Crypto::DRBG_get_bytes (dest, size) == CHIP_NO_ERROR) ? size : 0 ;
58
+ int res = (chip::Crypto::DRBG_get_bytes (dest, size) == CHIP_NO_ERROR) ? size : 0 ;
61
59
sys_mutex_unlock (&rngMutexHandle);
62
60
63
61
return res;
64
62
}
65
- #endif
63
+ #endif // TINYCRYPT_PRIMITIVES
66
64
67
65
static void app_get_random (uint8_t * aOutput, size_t aLen)
68
66
{
69
- size_t i;
70
-
71
- for (i = 0 ; i < aLen; i++)
67
+ VerifyOrReturn (aOutput != nullptr );
68
+ for (size_t i = 0 ; i < aLen; i++)
72
69
{
73
70
aOutput[i] = rand ();
74
71
}
@@ -81,6 +78,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s
81
78
82
79
return 0 ;
83
80
}
81
+ #endif // SLI_SI91X_MCU_INTERFACE
84
82
85
83
CHIP_ERROR PlatformManagerImpl::_InitChipStack (void )
86
84
{
@@ -97,16 +95,15 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
97
95
98
96
ReturnErrorOnFailure (System::Clock::InitClock_RealTime ());
99
97
100
- // 16 : Threshold value
101
- ReturnErrorOnFailure (chip::Crypto::add_entropy_source (app_entropy_source, NULL , 16 ));
98
+ # if SLI_SI91X_MCU_INTERFACE
99
+ ReturnErrorOnFailure (chip::Crypto::add_entropy_source (app_entropy_source, NULL , 16 /* Threshold value */ ));
102
100
103
101
#if defined(TINYCRYPT_PRIMITIVES)
104
102
/* Set RNG function for tinycrypt operations. */
105
- err_t ret;
106
- ret = sys_mutex_new (&rngMutexHandle);
107
- VerifyOrExit ((ERR_OK == ret), err = CHIP_ERROR_NO_MEMORY);
103
+ VerifyOrExit (sys_mutex_new (&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY);
108
104
uECC_set_rng (PlatformManagerImpl::uECC_RNG_Function);
109
- #endif
105
+ #endif // TINYCRYPT_PRIMITIVES
106
+ #endif // SLI_SI91X_MCU_INTERFACE
110
107
111
108
// Call _InitChipStack() on the generic implementation base class
112
109
// to finish the initialization process.
@@ -139,6 +136,7 @@ void PlatformManagerImpl::_Shutdown()
139
136
{
140
137
Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>::_Shutdown ();
141
138
}
139
+
142
140
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
143
141
void PlatformManagerImpl::HandleWFXSystemEvent (wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData)
144
142
{
@@ -206,7 +204,7 @@ void PlatformManagerImpl::HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wf
206
204
207
205
(void ) sInstance .PostEvent (&event);
208
206
}
209
- #endif
207
+ #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
210
208
211
209
} // namespace DeviceLayer
212
210
} // namespace chip
0 commit comments