summaryrefslogtreecommitdiff
path: root/board/cr50/build.mk
diff options
context:
space:
mode:
authorVadim Sukhomlinov <sukhomlinov@google.com>2021-09-01 14:37:25 -0700
committerCommit Bot <commit-bot@chromium.org>2021-09-14 23:36:32 +0000
commitd83a3c89d3733b8ca49f95b93a8c2e4c7db5689e (patch)
tree91138fdd132fa7ab3a29f3d8f1437b005b9b345a /board/cr50/build.mk
parent404fbff010c86aa27ec1d6ed3d030e71c1536ba7 (diff)
downloadchrome-ec-d83a3c89d3733b8ca49f95b93a8c2e4c7db5689e.tar.gz
cr50: make p256_int aligned - improve code size & performance
p256_int was defined as packed struct to allow in place processing of TPM2 commands. However, it is not practical to pad and reverse bytes in place, support for misaligned access results in bloated code, lower performance and side-channel leaks. With this change introduce p256_from_be_bin_size() function which handles all cases with conversion big-endian number into p256_int internal representation (little-endian for cr50) with skipping leading zeros if present in big-endian, checking of size and zero padding. Bonuses: - code size reduction 336 bytes - a bit higher performance for p256 - support for zero padded big-endian in TPM2 ECC, as well as more reliable checks for input parameters. BUG=none TEST=make BOARD=cr50 CRYPTO_TEST=1; test/tpm_test/tpmtest.py in console p256_test as unit test for padding function. ------------------------------ Test Result Summary ----------------------------- Test executed on: Tue Sep 14 15:13:11 2021 Performed Tests: 248 Passed Tests: 248 Failed Tests: 0 Errors: 0 Warnings: 0 ========================================================= Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: Idd04d4e8d30225398814650332fe9be7182a8966 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3138754 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Diffstat (limited to 'board/cr50/build.mk')
-rw-r--r--board/cr50/build.mk6
1 files changed, 5 insertions, 1 deletions
diff --git a/board/cr50/build.mk b/board/cr50/build.mk
index 4576e30c0e..b221c4f050 100644
--- a/board/cr50/build.mk
+++ b/board/cr50/build.mk
@@ -19,7 +19,7 @@ ifeq ($(BOARD_MK_INCLUDED_ONCE),)
# List of variables which can be defined in the environment or set in the make
# command line.
ENV_VARS := CR50_DEV CRYPTO_TEST H1_RED_BOARD U2F_TEST RND_TEST DRBG_TEST\
- ECDSA_TEST DCRYPTO_TEST
+ ECDSA_TEST DCRYPTO_TEST P256_BIN_TEST
ifneq ($(CRYPTO_TEST),)
CPPFLAGS += -DCRYPTO_TEST_SETUP
@@ -44,6 +44,10 @@ ifneq ($(DCRYPTO_TEST),)
CPPFLAGS += -DCRYPTO_TEST_CMD_DCRYPTO_TEST=1
endif
+ifneq ($(P256_BIN_TEST),)
+CPPFLAGS += -DP256_BIN_TEST=1
+endif
+
endif