From 9cc5813407700ee86d43c02ddd8f75c52c7d8ca7 Mon Sep 17 00:00:00 2001 From: Rohan S <3526930+brosahay@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:23:29 +0530 Subject: [PATCH] Adds changes to support mbedTLS --- src/platform/silabs/SiWx917/PlatformManagerImpl.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platform/silabs/SiWx917/PlatformManagerImpl.cpp b/src/platform/silabs/SiWx917/PlatformManagerImpl.cpp index c49b205c062d35..86d3f43eeaf17c 100644 --- a/src/platform/silabs/SiWx917/PlatformManagerImpl.cpp +++ b/src/platform/silabs/SiWx917/PlatformManagerImpl.cpp @@ -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; @@ -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; @@ -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) { @@ -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);