random: Fix feature dependency usage

Code using sys_csrand_get should depend on CONFIG_CSPRNG_ENABLED symbol
and not in ENTROPY_HAS_DRIVER since they are not using the entropy
device directly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2023-09-22 14:28:08 -07:00 committed by Maureen Helm
commit 5d505c7b28
3 changed files with 4 additions and 5 deletions

View file

@ -12,7 +12,7 @@
LOG_MODULE_REGISTER(net_otPlat_entropy, CONFIG_OPENTHREAD_L2_LOG_LEVEL); LOG_MODULE_REGISTER(net_otPlat_entropy, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
#if !defined(CONFIG_ENTROPY_HAS_DRIVER) #if !defined(CONFIG_CSPRNG_ENABLED)
#error OpenThread requires an entropy source for a TRNG #error OpenThread requires an entropy source for a TRNG
#endif #endif

View file

@ -272,7 +272,7 @@ static int tls_ctr_drbg_random(void *ctx, unsigned char *buf, size_t len)
{ {
ARG_UNUSED(ctx); ARG_UNUSED(ctx);
#if defined(CONFIG_ENTROPY_HAS_DRIVER) #if defined(CONFIG_CSPRNG_ENABLED)
return sys_csrand_get(buf, len); return sys_csrand_get(buf, len);
#else #else
sys_rand_get(buf, len); sys_rand_get(buf, len);
@ -1681,7 +1681,7 @@ static int tls_opt_dtls_connection_id_set(struct tls_context *context,
context->options.dtls_cid.enabled = true; context->options.dtls_cid.enabled = true;
if (context->options.dtls_cid.cid_len == 0) { if (context->options.dtls_cid.cid_len == 0) {
/* generate random self cid */ /* generate random self cid */
#if defined(CONFIG_ENTROPY_HAS_DRIVER) #if defined(CONFIG_CSPRNG_ENABLED)
sys_csrand_get(context->options.dtls_cid.cid, sys_csrand_get(context->options.dtls_cid.cid,
MBEDTLS_SSL_CID_OUT_LEN_MAX); MBEDTLS_SSL_CID_OUT_LEN_MAX);
#else #else

View file

@ -22,8 +22,7 @@ static inline void z_vrfy_sys_rand_get(void *dst, size_t len)
} }
#include <syscalls/sys_rand_get_mrsh.c> #include <syscalls/sys_rand_get_mrsh.c>
#if defined(CONFIG_CTR_DRBG_CSPRNG_GENERATOR) || \ #ifdef CONFIG_CSPRNG_ENABLED
defined(CONFIG_HARDWARE_DEVICE_CS_GENERATOR)
static inline int z_vrfy_sys_csrand_get(void *dst, size_t len) static inline int z_vrfy_sys_csrand_get(void *dst, size_t len)
{ {
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(dst, len)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(dst, len));