diff options
author | Ivan Chen <yulunchen@google.com> | 2023-05-17 03:32:45 +0000 |
---|---|---|
committer | Ivan Chen <yulunchen@google.com> | 2023-05-17 03:32:45 +0000 |
commit | d7c9c6beb03ee5725232b9ac3bfe4825e1e227cb (patch) | |
tree | 3a0d6776c0e76e325d1b087cd51a850cb871358e /chip/stm32 | |
parent | 8641442366bd7c2c133e302a57f904dfac3c896b (diff) | |
parent | b34dc2ae9022e2fbb57ae6477891ff32954c62fd (diff) | |
download | chrome-ec-firmware-brya-14505.B-main.tar.gz |
Merge remote-tracking branch cros/main into firmware-brya-14505.B-mainfirmware-brya-14505.B-main
Generated by: util/update_release_branch.py --board brya firmware-brya-14505.B-main
Relevant changes:
git log --oneline 8641442366..b34dc2ae90 -- board/brya board/brya
util/getversion.sh
BRANCH=None
TEST=`make -j buildall`
Force-Relevant-Builds: all
Change-Id: I63149b4c1782b3ed57f2556755901c21f5f1e3e9
Signed-off-by: Ivan Chen <yulunchen@google.com>
Diffstat (limited to 'chip/stm32')
-rw-r--r-- | chip/stm32/trng.c | 71 |
1 files changed, 1 insertions, 70 deletions
diff --git a/chip/stm32/trng.c b/chip/stm32/trng.c index 67d3700cf1..63641741d3 100644 --- a/chip/stm32/trng.c +++ b/chip/stm32/trng.c @@ -16,7 +16,7 @@ #include "trng.h" #include "util.h" -static uint32_t trng_rand(void) +uint32_t trng_rand(void) { int tries = 300; /* Wait for a valid random number */ @@ -29,25 +29,6 @@ static uint32_t trng_rand(void) return STM32_RNG_DR; } -test_mockable void trng_rand_bytes(void *buffer, size_t len) -{ - while (len) { - uint32_t number = trng_rand(); - size_t cnt = 4; - /* deal with the lack of alignment guarantee in the API */ - uintptr_t align = (uintptr_t)buffer & 3; - - if (len < 4 || align) { - cnt = MIN(4 - align, len); - memcpy(buffer, &number, cnt); - } else { - *(uint32_t *)buffer = number; - } - len -= cnt; - buffer += cnt; - } -} - test_mockable void trng_init(void) { #ifdef CHIP_FAMILY_STM32L4 @@ -97,53 +78,3 @@ test_mockable void trng_exit(void) /* Nothing to do */ #endif } - -#if defined(CONFIG_CMD_RAND) -/* - * We want to avoid accidentally exposing debug commands in RO since we can't - * update RO once in production. - */ -#if defined(SECTION_IS_RW) -static int command_rand(int argc, const char **argv) -{ - uint8_t data[32]; - char str_buf[hex_str_buf_size(sizeof(data))]; - - trng_init(); - trng_rand_bytes(data, sizeof(data)); - trng_exit(); - - snprintf_hex_buffer(str_buf, sizeof(str_buf), - HEX_BUF(data, sizeof(data))); - ccprintf("rand %s\n", str_buf); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(rand, command_rand, NULL, - "Output random bytes to console."); - -static enum ec_status host_command_rand(struct host_cmd_handler_args *args) -{ - const struct ec_params_rand_num *p = args->params; - struct ec_response_rand_num *r = args->response; - uint16_t num_rand_bytes = p->num_rand_bytes; - - if (system_is_locked()) - return EC_RES_ACCESS_DENIED; - - if (num_rand_bytes > args->response_max) - return EC_RES_OVERFLOW; - - trng_init(); - trng_rand_bytes(r->rand, num_rand_bytes); - trng_exit(); - - args->response_size = num_rand_bytes; - - return EC_SUCCESS; -} - -DECLARE_HOST_COMMAND(EC_CMD_RAND_NUM, host_command_rand, - EC_VER_MASK(EC_VER_RAND_NUM)); -#endif /* SECTION_IS_RW */ -#endif /* CONFIG_CMD_RAND */ |