summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2023-04-13 14:59:14 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-13 16:44:15 +0000
commit74e498c2647dcad68d46022abac34c8c5c6b96b3 (patch)
tree0f2b84c1cfe6e4e4d3328a0fa2d060291edb6cd9
parentcd7559374de5d6c6ef0f5b26afac1913ba871592 (diff)
downloadchrome-ec-74e498c2647dcad68d46022abac34c8c5c6b96b3.tar.gz
trng: Drop trng_rand() function
The function is not used anywhere except test/rng_benchmark.cc, so we will have a problem with code coverage when implementing the function using Zephyr API. The RNG benchmark was modified to use trng_rand_bytes() function. BUG=b:277029648 BRANCH=none TEST=./test/run_device_tests.py --board bloonchipper -t rng_benchmark Change-Id: Ic6cf7e511b2e8fe88a08e9e1c4354f7afa9ae425 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4423151 Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--chip/stm32/trng.c2
-rw-r--r--include/trng.h7
-rw-r--r--test/rng_benchmark.cc4
3 files changed, 3 insertions, 10 deletions
diff --git a/chip/stm32/trng.c b/chip/stm32/trng.c
index aafc0e89c1..67d3700cf1 100644
--- a/chip/stm32/trng.c
+++ b/chip/stm32/trng.c
@@ -16,7 +16,7 @@
#include "trng.h"
#include "util.h"
-uint32_t trng_rand(void)
+static uint32_t trng_rand(void)
{
int tries = 300;
/* Wait for a valid random number */
diff --git a/include/trng.h b/include/trng.h
index 3b28796ed0..21ae041156 100644
--- a/include/trng.h
+++ b/include/trng.h
@@ -28,13 +28,6 @@ void trng_init(void);
void trng_exit(void);
/**
- * Retrieve a 32 bit random value.
- *
- * Not supported on all platforms.
- **/
-uint32_t trng_rand(void);
-
-/**
* Output len random bytes into buffer.
*
* Not supported on all platforms.
diff --git a/test/rng_benchmark.cc b/test/rng_benchmark.cc
index c086ff2cb0..10716f863d 100644
--- a/test/rng_benchmark.cc
+++ b/test/rng_benchmark.cc
@@ -31,7 +31,7 @@ test_static int test_rng()
trng_init();
auto result = benchmark.run("trng", [&trng_out]() {
static int i = 0;
- trng_out[i++] = trng_rand();
+ trng_rand_bytes(&trng_out[i++], sizeof(uint32_t));
});
trng_exit();
@@ -46,7 +46,7 @@ test_static int test_rng()
result = benchmark.run("trng_on_off", [&trng_out]() {
trng_init();
static int i = 0;
- trng_out[i++] = trng_rand();
+ trng_rand_bytes(&trng_out[i++], sizeof(uint32_t));
trng_exit();
});