From 585c89c61f789eda8172aa6e4ab5ee30e92df206 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 4 Aug 2017 16:26:05 +0200 Subject: cr50: fix saving the U2F seed to flash We need to ensure that the NVMEM variable containing the seed is properly saved to flash, so we can restore it later whatever happens. Add a call to writevars() which triggers the NVMEM commit rather than accidentally waiting for it. Signed-off-by: Vincent Palatin BRANCH=cr50 BUG=b:35545754 TEST=run twice 'trunks_send --u2f_cert --crt=/tmp/mycert.crt' and hard-reboot the cr50 in between and see both certificates are fully identical. Change-Id: Iea4f9fdede4c0a2eeae1c59633caa16dbf70a66f Reviewed-on: https://chromium-review.googlesource.com/602241 Commit-Ready: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Vadim Bendebury (cherry picked from commit b7e4d50cfe9fe6c1a847727153f3677b9a3630e2) Reviewed-on: https://chromium-review.googlesource.com/622234 Tested-by: Vadim Bendebury Commit-Queue: Vadim Bendebury --- board/cr50/u2f.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/board/cr50/u2f.c b/board/cr50/u2f.c index 26fc3c10ce..633b9f60d3 100644 --- a/board/cr50/u2f.c +++ b/board/cr50/u2f.c @@ -79,6 +79,8 @@ static int load_state(void) if (setvar(&k_salt, sizeof(k_salt), (const uint8_t *)salt, sizeof(salt))) return 0; + /* really save the new variable to flash */ + writevars(); } else { memcpy(salt, tuple_val(t_salt), sizeof(salt)); } -- cgit v1.2.1