From 72a3dd167c24a20a6df568d0c84c77dd45a6d2cf Mon Sep 17 00:00:00 2001 From: Yicheng Li Date: Mon, 4 Jan 2021 14:49:19 -0800 Subject: cr50_stab: Add unittests for u2f The u2f functionality had no unittests at all. This change is more of a setup (in terms of build dependencies) so that u2f tests can be easily added in the future. This change comes with a few simple tests for u2f_generate. The basic idea here is to use board/host/dcrypto.h to mock the dcrypto functionalities. Since board/host/dcrypto.h includes an alternative to cryptoc's sha256 definitions, we need to exclude cryptoc/sha256.h in the test builds. BUG=b:172971998 TEST=make -j run-u2f TEST=make CR50_DEV=1 BOARD=cr50 -j Signed-off-by: Yicheng Li Change-Id: Idae6f55f599a017aedcaf0fe4cdb6c0506e72712 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2610133 Reviewed-by: Mary Ruthven --- include/u2f_impl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/u2f_impl.h') diff --git a/include/u2f_impl.h b/include/u2f_impl.h index fd2cc05ba1..a2f2cfaa97 100644 --- a/include/u2f_impl.h +++ b/include/u2f_impl.h @@ -9,7 +9,13 @@ #define __CROS_EC_U2F_IMPL_H #include "common.h" + +#ifdef TEST_BUILD +#include "board/host/dcrypto.h" +#endif + #include "cryptoc/p256.h" +#include "tpm_vendor_cmds.h" #include "u2f.h" /* ---- Physical presence ---- */ @@ -132,4 +138,11 @@ int u2f_gen_kek_seed(int commit); */ int g2f_attestation_cert(uint8_t *buf); +/** + * U2F_GENERATE command handler. Generates a key handle according to input + * parameters. + */ +enum vendor_cmd_rc u2f_generate(enum vendor_cmd_cc code, void *buf, + size_t input_size, size_t *response_size); + #endif /* __CROS_EC_U2F_IMPL_H */ -- cgit v1.2.1