Skip to content

Commit

Permalink
Adds changes to support mbedTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
brosahay authored and rosahay-silabs committed Oct 31, 2023
1 parent ef6a675 commit 9cc5813
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/platform/silabs/SiWx917/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ namespace DeviceLayer {
PlatformManagerImpl PlatformManagerImpl::sInstance;
#if defined(TINYCRYPT_PRIMITIVES)
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL;
#endif // TINYCRYPT_PRIMITIVES

#if defined(TINYCRYPT_PRIMITIVES)
int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)
{
int res;
Expand All @@ -64,7 +62,8 @@ int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)

return res;
}

#endif // TINYCRYPT_PRIMITIVES
#if (defined(TINYCRYPT_PRIMITIVES) || defined(CHIP_CRYPTO_MBEDTLS))
static void app_get_random(uint8_t * aOutput, size_t aLen)
{
size_t i;
Expand All @@ -82,7 +81,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s

return 0;
}
#endif // TINYCRYPT_PRIMITIVES
#endif // TINYCRYPT_PRIMITIVES || CHIP_CRYPTO_MBEDTLS

CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
{
Expand All @@ -99,10 +98,12 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)

ReturnErrorOnFailure(System::Clock::InitClock_RealTime());

#if defined(TINYCRYPT_PRIMITIVES)
#if (defined(TINYCRYPT_PRIMITIVES) || defined(CHIP_CRYPTO_MBEDTLS))
// 16 : Threshold value
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
#endif // TINYCRYPT_PRIMITIVES || CHIP_CRYPTO_MBEDTLS

#if defined(TINYCRYPT_PRIMITIVES)
/* Set RNG function for tinycrypt operations. */
err_t ret;
ret = sys_mutex_new(&rngMutexHandle);
Expand Down

0 comments on commit 9cc5813

Please sign in to comment.