summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYicheng Li <yichengli@chromium.org>2019-06-10 11:44:47 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-14 06:33:00 +0000
commitb5c6cf246deb0ade98bf3e84999984998b67267e (patch)
treed63d161ac18640d0cd07923ca714f2eca91da0d9 /common
parent2d62dee3a8f32499bab8f4b95b84a9eaeea919dc (diff)
downloadchrome-ec-b5c6cf246deb0ade98bf3e84999984998b67267e.tar.gz
fpsensor: Add unit test for derive_encryption_key().
Mock rollback_get_secret() and use it to test derive_encryption_key(). BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on nocturne DUT TEST=verified test key vectors by running boringSSL's HKDF (https://boringssl.googlesource.com/boringssl/+/c0b4c72b6d4c6f4828a373ec454bd646390017d4/crypto/hkdf/) locally Change-Id: Ie2f51e4f64788d938e43d0c5c18685d1cfdd001c Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652495 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/fpsensor/build.mk2
-rw-r--r--common/fpsensor/fpsensor_crypto.c2
-rw-r--r--common/rollback.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/common/fpsensor/build.mk b/common/fpsensor/build.mk
index c684dd01b9..14361588f6 100644
--- a/common/fpsensor/build.mk
+++ b/common/fpsensor/build.mk
@@ -8,7 +8,7 @@
_fpsensor_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)/fpsensor_state.o
+all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)/fpsensor_crypto.o
ifneq ($(CONFIG_SPI_FP_PORT),)
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)/fpsensor.o
-all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)/fpsensor_crypto.o
endif
diff --git a/common/fpsensor/fpsensor_crypto.c b/common/fpsensor/fpsensor_crypto.c
index 5c5715a462..7e31e3f923 100644
--- a/common/fpsensor/fpsensor_crypto.c
+++ b/common/fpsensor/fpsensor_crypto.c
@@ -16,7 +16,7 @@
#error "fpsensor requires AES, AES_GCM and ROLLBACK_SECRET_SIZE"
#endif
-int derive_encryption_key(uint8_t *out_key, uint8_t *salt)
+int derive_encryption_key(uint8_t *out_key, const uint8_t *salt)
{
int ret;
uint8_t key_buf[SHA256_DIGEST_SIZE];
diff --git a/common/rollback.c b/common/rollback.c
index 2f4ba88c1c..ef78146094 100644
--- a/common/rollback.c
+++ b/common/rollback.c
@@ -137,7 +137,7 @@ int32_t rollback_get_minimum_version(void)
}
#ifdef CONFIG_ROLLBACK_SECRET_SIZE
-int rollback_get_secret(uint8_t *secret)
+test_mockable int rollback_get_secret(uint8_t *secret)
{
struct rollback_data data;
uint8_t first;