summaryrefslogtreecommitdiff
path: root/include/rollback.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-05-31 12:12:12 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-06-06 08:52:16 -0700
commit39db721f9ace13cc210278c88c3f364b5d67b5b8 (patch)
tree6a0ca910942bf8c41560e91b73a8a58d04bc146c /include/rollback.h
parent2f436f4cc9bd026ed83511401ab17d68f5f8e5a3 (diff)
downloadchrome-ec-39db721f9ace13cc210278c88c3f364b5d67b5b8.tar.gz
hammer: Add board_get_entropy function (and test)
This function will be used to generate some entropy using the Clock Recovery System. 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 TEST=Test fails when no USB connection is active TEST=Test passes when USB connection is active TEST=Pasting the values into: tr ';' '\n' | awk 'BEGIN { e = 0; tot=16384.0 } { p = $1/tot; if (p > 0) { e -= p*log(p)/log(2) } } END { print e }' shows an entropy > 4 bits per sample. Change-Id: I2363c7bce42c72c33ef0bf3f099d709ee9c13d13 Reviewed-on: https://chromium-review.googlesource.com/518608 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/rollback.h')
-rw-r--r--include/rollback.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/rollback.h b/include/rollback.h
index e33403b330..51f945e089 100644
--- a/include/rollback.h
+++ b/include/rollback.h
@@ -44,6 +44,19 @@ int rollback_add_entropy(uint8_t *data, unsigned int len);
*/
int rollback_lock(void);
+/**
+ * Obtain some weak entropy (i.e. not guaranteed to be high quality), based on
+ * sensors or timing events.
+ *
+ * Must be defined if CONFIG_ROLLBACK_SECRET_SIZE is set. May sleep.
+ *
+ * @param buffer Buffer to fill with entropy.
+ * @param len Buffer length.
+ *
+ * @return true if the buffer was filled, false on error.
+ */
+int board_get_entropy(void *buffer, int len);
+
#endif
#endif /* __CROS_EC_ROLLBACK_H */