diff options
author | Yicheng Li <yichengli@chromium.org> | 2021-01-04 14:49:19 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-12 20:55:51 +0000 |
commit | 72a3dd167c24a20a6df568d0c84c77dd45a6d2cf (patch) | |
tree | 1d1c66467f1ce5e5b0117438c1c104b51f954f5d /board/host/dcrypto.h | |
parent | ec643f0d99397eafa09ab39b2d7dd6b968bd70d8 (diff) | |
download | chrome-ec-stabilize-quickfix-13729.84.B-cr50_stab.tar.gz |
cr50_stab: Add unittests for u2fstabilize-quickfix-13729.84.B-cr50_stabstabilize-quickfix-13729.73.B-cr50_stabstabilize-quickfix-13729.60.B-cr50_stabstabilize-13729.72.B-cr50_stabstabilize-13729.57.B-cr50_stabstabilize-13729.56.B-cr50_stabstabilize-13729.49.B-cr50_stabstabilize-13729.45.B-cr50_stabstabilize-13729.16.B-cr50_stabrelease-R89-13729.B-cr50_stab
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 <yichengli@chromium.org>
Change-Id: Idae6f55f599a017aedcaf0fe4cdb6c0506e72712
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2610133
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'board/host/dcrypto.h')
-rw-r--r-- | board/host/dcrypto.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/board/host/dcrypto.h b/board/host/dcrypto.h index 31f04e51aa..ce924e64fa 100644 --- a/board/host/dcrypto.h +++ b/board/host/dcrypto.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* Provides the minimal declarations needed by pinweaver to build on +/* Provides the minimal declarations needed by pinweaver and u2f to build on * CHIP_HOST. While it might be preferable to simply use the original dcrypto.h, * That would require incorporating additional headers / dependencies such as * cryptoc. @@ -73,6 +73,29 @@ void DCRYPTO_appkey_finish(struct APPKEY_CTX *ctx); int DCRYPTO_appkey_derive(enum dcrypto_appid appid, const uint32_t input[8], uint32_t output[8]); +#include "cryptoc/p256.h" + +int DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x, + const p256_int *pk_y, const p256_int *serial, + const char *name, uint8_t *cert, + const int n); + +int DCRYPTO_ladder_random(void *output); + +#define SHA256_DIGEST_WORDS (SHA256_DIGEST_SIZE / sizeof(uint32_t)) + +struct drbg_ctx { + uint32_t k[SHA256_DIGEST_WORDS]; + uint32_t v[SHA256_DIGEST_WORDS]; + uint32_t reseed_counter; +}; + +int dcrypto_p256_ecdsa_sign(struct drbg_ctx *drbg, const p256_int *key, + const p256_int *message, p256_int *r, p256_int *s); + +void hmac_drbg_init_rfc6979(struct drbg_ctx *ctx, const p256_int *key, + const p256_int *message); + #endif /* CONFIG_DCRYPTO_MOCK */ #endif /* __CROS_EC_HOST_DCRYPTO_H */ |