diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-06-01 16:41:26 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-13 05:23:33 -0700 |
commit | 9ebcc894be1f3cc0c48f52ed203affb66e01f1dd (patch) | |
tree | 7d9ac1d229658d1de3bd024131b773e06adc28dc /board/host | |
parent | c4f465185231cd3e0ed92d3c45c18915c2adc6df (diff) | |
download | chrome-ec-9ebcc894be1f3cc0c48f52ed203affb66e01f1dd.tar.gz |
test/entropy: Add host test and compute entropy
Check that added entropy is at least somewhat acceptable.
BRANCH=none
BUG=b:38486828
TEST=make BOARD=hammer -j tests
./util/flash_ec --board=hammer --image=build/hammer/test-entropy.bin
EC console: runtest, get around 4000/1000 (=4) bits of entropy, value
matches (roughly) the value obtained using the awk script.
TEST=make run-entropy
Change-Id: I88d0e9ec0e38ab3ec70d3e8163b8ac1556df978d
Reviewed-on: https://chromium-review.googlesource.com/523482
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/host')
-rw-r--r-- | board/host/board.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/board/host/board.c b/board/host/board.c index 408bfdcf0b..b29f6e9230 100644 --- a/board/host/board.c +++ b/board/host/board.c @@ -67,3 +67,20 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); #endif + +#ifdef TEST_BUILD +/* Poor source of entropy for testing purpose. */ +int board_get_entropy(void *buffer, int len) +{ + static uint32_t seed = 0xcafecafe; + int i = 0; + uint8_t *data = buffer; + + for (i = 0; i < len; i++) { + seed *= 7; + data[i] = seed + (seed >> 24); + } + + return 1; +} +#endif |