diff options
author | Yicheng Li <yichengli@chromium.org> | 2019-06-11 14:38:00 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-21 00:08:39 +0000 |
commit | 8fd4f4548eba5f2ad1d22ebd1b345f7cbce68579 (patch) | |
tree | 0acbec89e82bb276e0cbf7dd4d4f98a35d472049 | |
parent | 03f7c5caeb89fb707cc78565b2aec81100ee2f39 (diff) | |
download | chrome-ec-8fd4f4548eba5f2ad1d22ebd1b345f7cbce68579.tar.gz |
trng: make init_trng(), exit_trng() and rand_bytes() test_mockable.
Make these functions test_mockable so that crypto-related functions
that use them can be unit-tested.
BRANCH=nocturne
BUG=chromium:927095
TEST=make -j buildall
Change-Id: Ie59c232077fa14420ca9686409159173815f0d26
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652626
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
-rw-r--r-- | chip/stm32/trng.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/chip/stm32/trng.c b/chip/stm32/trng.c index 8ef7b891a7..94cfab995e 100644 --- a/chip/stm32/trng.c +++ b/chip/stm32/trng.c @@ -26,7 +26,7 @@ uint32_t rand(void) return STM32_RNG_DR; } -void rand_bytes(void *buffer, size_t len) +test_mockable void rand_bytes(void *buffer, size_t len) { while (len) { uint32_t number = rand(); @@ -45,7 +45,7 @@ void rand_bytes(void *buffer, size_t len) } } -void init_trng(void) +test_mockable void init_trng(void) { #ifdef CHIP_FAMILY_STM32L4 /* Enable the 48Mhz internal RC oscillator */ @@ -82,7 +82,7 @@ void init_trng(void) STM32_RNG_CR |= STM32_RNG_CR_RNGEN; } -void exit_trng(void) +test_mockable void exit_trng(void) { STM32_RNG_CR &= ~STM32_RNG_CR_RNGEN; STM32_RCC_AHB2ENR &= ~STM32_RCC_AHB2ENR_RNGEN; |