diff options
author | Vadim Sukhomlinov <sukhomlinov@google.com> | 2021-08-17 11:45:23 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-19 04:39:29 +0000 |
commit | 4de87085a2da49887ac90aae9df571afa84168f6 (patch) | |
tree | d817284193e4687a47aa332073454b61789e2cdc /board/cr50/board.c | |
parent | 994efaeb57aaa023e38b547ceede69930ed687fc (diff) | |
download | chrome-ec-4de87085a2da49887ac90aae9df571afa84168f6.tar.gz |
cr50: refactor TRNG use, implement rand() using read_rand()
In preparation to switching from TRNG to DRBG, refactor to remove
duplicated code, reduce code size.
1. Isolate hardware-dependent code (trng.c) from platform-agnostic in
fips_rand.c. This will enable better host emulation for tests.
2. Change how read_rand() returns status to take advantage of ARM ABI.
Unfortunately any composite type on ARM is returned on stack. Use
uint64_t with combined validity flag in high bits and random in low
32 bits. This alone reduce code size around 100 bytes.
3. Avoid code duplication by implementing rand() using read_rand().
4. Drop use of common/trng.h to reduce dependency on code outside
boundary. To be completed with migration to DRBG.
BUG=b:138577416
TEST=make BOARD=cr50 CRYPTO_TEST=1; rand_perf and FIPS tests
Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com>
Change-Id: Ifdc42e7210414a4abeac8c132a684e451fbbc19c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3100489
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Diffstat (limited to 'board/cr50/board.c')
-rw-r--r-- | board/cr50/board.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c index dfa05b8ef9..96f90f6cee 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -13,6 +13,7 @@ #include "ec_version.h" #include "endian.h" #include "extension.h" +#include "fips_rand.h" #include "flash.h" #include "flash_config.h" #include "gpio.h" @@ -34,7 +35,6 @@ #include "system_chip.h" #include "task.h" #include "tpm_registers.h" -#include "trng.h" #include "uart_bitbang.h" #include "uartn.h" #include "usart.h" @@ -850,7 +850,7 @@ static void board_init(void) configure_board_specific_gpios(); init_pmu(); reset_wake_logic(); - init_trng(); + fips_init_trng(); maybe_trigger_ite_sync(); init_jittery_clock(1); |