kfsw-modules/radio-uhf/src/radio_crypto_host.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <errno.h> | ||
| 2 | #include <stddef.h> | ||
| 3 | #include <stdint.h> | ||
| 4 | #include <sys/random.h> | ||
| 5 | |||
| 6 | /* Built with host headers, not Zephyr's libc. native_sim's default entropy | ||
| 7 | * driver is a repeatable test generator. | ||
| 8 | */ | ||
| 9 | ✗ | int kfsw_radio_host_random(void *data, size_t size) | |
| 10 | { | ||
| 11 | ✗ | uint8_t *out = data; | |
| 12 | ✗ | while (size != 0U) { | |
| 13 | ✗ | ssize_t count = getrandom(out, size, 0); | |
| 14 | ✗ | if (count < 0 && errno == EINTR) { | |
| 15 | ✗ | continue; | |
| 16 | } | ||
| 17 | ✗ | if (count <= 0) { | |
| 18 | ✗ | return -1; | |
| 19 | } | ||
| 20 | ✗ | out += count; | |
| 21 | ✗ | size -= (size_t)count; | |
| 22 | } | ||
| 23 | ✗ | return 0; | |
| 24 | } | ||
| 25 |