Skip to content

Commit 34b6b3d

Browse files
cvinayaknashif
authored andcommitted
Bluetooth: Controller: Support FAKE_ENTROPY_NATIVE_POSIX
Add support for use of FAKE_ENTROPY_NATIVE_POSIX as entropy driver for the Controller on BOARD_NRF54L15BSIM. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 7e35800 commit 34b6b3d

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

subsys/bluetooth/controller/Kconfig

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
# The following symbols are enabled depending if the controller actually
77
# supports the respective features.
88

9+
config BT_CTLR_ENTROPY_SUPPORT
10+
bool
11+
912
config BT_CTLR_CRYPTO_SUPPORT
13+
depends on BT_CTLR_ENTROPY_SUPPORT
1014
bool
1115

1216
config BT_CTLR_LE_ENC_SUPPORT
@@ -147,15 +151,42 @@ config BT_CTLR_HCI
147151

148152
comment "BLE Controller configuration"
149153

154+
config BT_CTLR_ENTROPY
155+
bool "Random number generation in Controller"
156+
depends on BT_CTLR_ENTROPY_SUPPORT
157+
select ENTROPY_GENERATOR
158+
default y
159+
help
160+
Use random number generation provided by the Controller.
161+
162+
Bluetooth Core Specification mandates a use of random number generator
163+
compliant with FIPS PUB 140-2.
164+
165+
This option allows for Controller implementation that do not use true
166+
random number generation and hence making the implementation as
167+
experimental.
168+
169+
Controller implementations can provide custom bare-metal random number
170+
implementation without any support in Zephyr driver, i.e. there is no
171+
ENTROPY_HAS_DRIVER enabled.
172+
150173
config BT_CTLR_CRYPTO
151174
bool "Crypto functions in Controller"
152175
depends on BT_CTLR_CRYPTO_SUPPORT
153-
select ENTROPY_GENERATOR
154176
default y
155177
help
156178
Use random number generation and AES encryption support functions
157179
provided by the controller.
158180

181+
Support for HCI LE Rand and HCI LE Encrypt commands are mandatory
182+
by Bluetooth Core Specification.
183+
184+
In an Application/Host and Controller split (using a HCI transport) or
185+
combined builds for single CPU SoCs, applications can use its own
186+
FIPS-197 compliant cryptographic implementations. In this case the
187+
Controller cryptographic implementations can be disabled to save flash
188+
and RAM usage.
189+
159190
config BT_CTLR_HCI_VS_BUILD_INFO
160191
string "Zephyr HCI VS Build Info string"
161192
default ""

subsys/bluetooth/controller/Kconfig.ll_sw_split

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ config BT_LLL_VENDOR_NORDIC
1111
depends on !$(dt_nodelabel_enabled,timer0)
1212
depends on !$(dt_nodelabel_enabled,rtc0)
1313

14-
select ENTROPY_NRF5_RNG if BT_CTLR_CRYPTO
14+
select BT_CTLR_ENTROPY_SUPPORT if !SOC_COMPATIBLE_NRF54LX || BOARD_NRF54L15BSIM
15+
select FAKE_ENTROPY_NATIVE_POSIX if BT_CTLR_ENTROPY && BOARD_NRF54L15BSIM
16+
select ENTROPY_NRF5_RNG if BT_CTLR_ENTROPY && !SOC_COMPATIBLE_NRF54LX
1517
select ENTROPY_NRF5_BIAS_CORRECTION if ENTROPY_NRF5_RNG
18+
select EXPERIMENTAL if !ENTROPY_HAS_DRIVER || FAKE_ENTROPY_NATIVE_POSIX
1619

1720
select BT_HAS_HCI_VS
1821
select BT_CTLR_CRYPTO_SUPPORT if !SOC_COMPATIBLE_NRF54LX
@@ -69,7 +72,9 @@ config BT_LLL_VENDOR_NORDIC
6972
config BT_LLL_VENDOR_OPENISA
7073
bool "Use OpenISA LLL"
7174
depends on SOC_OPENISA_RV32M1
75+
7276
select BT_HAS_HCI_VS
77+
select BT_CTLR_ENTROPY_SUPPORT
7378
select BT_CTLR_CRYPTO_SUPPORT
7479
select BT_CTLR_LE_ENC_SUPPORT if BT_CTLR_CRYPTO_SUPPORT && \
7580
!BT_CTLR_DATA_LENGTH_CLEAR

subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static struct {
5858
} event;
5959

6060
/* Entropy device */
61-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
61+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
6262
static const struct device *const dev_entropy = DEVICE_DT_GET(DT_NODELABEL(rng));
63-
#endif /* CONFIG_ENTROPY_NRF5_RNG */
63+
#endif /* CONFIG_ENTROPY_HAS_DRIVER */
6464

6565
static int init_reset(void);
6666
#if defined(CONFIG_BT_CTLR_LOW_LAT_ULL_DONE)
@@ -179,12 +179,12 @@ int lll_init(void)
179179
{
180180
int err;
181181

182-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
182+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
183183
/* Get reference to entropy device */
184184
if (!device_is_ready(dev_entropy)) {
185185
return -ENODEV;
186186
}
187-
#endif /* CONFIG_ENTROPY_NRF5_RNG */
187+
#endif /* CONFIG_ENTROPY_HAS_DRIVER */
188188

189189
/* Initialise LLL internals */
190190
event.curr.abort_cb = NULL;
@@ -327,54 +327,54 @@ int lll_deinit(void)
327327

328328
int lll_csrand_get(void *buf, size_t len)
329329
{
330-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
330+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
331331
return entropy_get_entropy(dev_entropy, buf, len);
332-
#else
332+
#else /* !CONFIG_ENTROPY_HAS_DRIVER */
333333
/* FIXME: No suitable entropy device available yet.
334334
* It is required by Controller to use random numbers.
335335
* Hence, return uninitialized buf contents, for now.
336336
*/
337337
return 0;
338-
#endif
338+
#endif /* !CONFIG_ENTROPY_HAS_DRIVER */
339339
}
340340

341341
int lll_csrand_isr_get(void *buf, size_t len)
342342
{
343-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
343+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
344344
return entropy_get_entropy_isr(dev_entropy, buf, len, 0);
345-
#else
345+
#else /* !CONFIG_ENTROPY_HAS_DRIVER */
346346
/* FIXME: No suitable entropy device available yet.
347347
* It is required by Controller to use random numbers.
348348
* Hence, return uninitialized buf contents, for now.
349349
*/
350350
return 0;
351-
#endif
351+
#endif /* !CONFIG_ENTROPY_HAS_DRIVER */
352352
}
353353

354354
int lll_rand_get(void *buf, size_t len)
355355
{
356-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
356+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
357357
return entropy_get_entropy(dev_entropy, buf, len);
358-
#else
358+
#else /* !CONFIG_ENTROPY_HAS_DRIVER */
359359
/* FIXME: No suitable entropy device available yet.
360360
* It is required by Controller to use random numbers.
361361
* Hence, return uninitialized buf contents, for now.
362362
*/
363363
return 0;
364-
#endif
364+
#endif /* !CONFIG_ENTROPY_HAS_DRIVER */
365365
}
366366

367367
int lll_rand_isr_get(void *buf, size_t len)
368368
{
369-
#if defined(CONFIG_ENTROPY_NRF5_RNG)
369+
#if defined(CONFIG_ENTROPY_HAS_DRIVER)
370370
return entropy_get_entropy_isr(dev_entropy, buf, len, 0);
371-
#else
371+
#else /* !CONFIG_ENTROPY_HAS_DRIVER */
372372
/* FIXME: No suitable entropy device available yet.
373373
* It is required by Controller to use random numbers.
374374
* Hence, return uninitialized buf contents, for now.
375375
*/
376376
return 0;
377-
#endif
377+
#endif /* !CONFIG_ENTROPY_HAS_DRIVER */
378378
}
379379

380380
int lll_reset(void)

0 commit comments

Comments
 (0)