From d3b1de5a1e233787e8e1128a64237f4d09955ff5 Mon Sep 17 00:00:00 2001 From: Vadim Sukhomlinov Date: Fri, 8 Oct 2021 16:43:53 -0700 Subject: cr50: fix test/tpm_test makefile to build bn_test test/tpm_test Makefile doesn't build bn_test properly. Need to add handling of difference between Cr50 and Chip/g dcrypto. Also, Cr50 code use __always_inline for some functions which itself requires compiler optimization to turn on. Adding -O2 to CFLAGS. BUG=None TEST=make -C test/tpm_test clean make -C test/tpm_test make -C test/tpm_test clean make -C test/tpm_test CR50=1 Signed-off-by: Vadim Sukhomlinov Change-Id: I08749ebaa930fd4f71d7406ed289bf480b5a8510 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3215057 Reviewed-by: Vadim Sukhomlinov Reviewed-by: Vadim Bendebury Tested-by: Vadim Sukhomlinov Auto-Submit: Vadim Sukhomlinov Commit-Queue: Vadim Sukhomlinov --- test/tpm_test/Makefile | 3 ++- test/tpm_test/bn_test.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/tpm_test/Makefile b/test/tpm_test/Makefile index 985e0fffcb..95c407c03f 100644 --- a/test/tpm_test/Makefile +++ b/test/tpm_test/Makefile @@ -30,9 +30,10 @@ else # Use BOARD=cr50 specific implementation vpath %c $(src) ../../board/cr50/dcrypto $(src)/testlib CFLAGS += -I../../board/cr50/dcrypto +CFLAGS += -DCR50_DCRYPTO endif -CFLAGS += -fPIC +CFLAGS += -O2 -fPIC CFLAGS += -I ${PYTHON_INCLUDE} CFLAGS += -I../../../../third_party/cryptoc/include CFLAGS += -I../../board/cr50 diff --git a/test/tpm_test/bn_test.c b/test/tpm_test/bn_test.c index 78268d9ba7..01a2119daa 100644 --- a/test/tpm_test/bn_test.c +++ b/test/tpm_test/bn_test.c @@ -2,7 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#ifdef CR50_DCRYPTO +/* some of the functions became internal in CR50 */ #include "internal.h" +#else +#include "dcrypto.h" +#endif #include #include @@ -403,6 +408,8 @@ void watchdog_reload(void) { } +#ifdef CR50_DCRYPTO +/* For CR50 we need to mock additional functions. */ bool fips_rand_bytes(void *buffer, size_t len) { uint8_t *b, *end; @@ -425,6 +432,7 @@ uint64_t fips_trng_rand32(void) return (uint64_t)(rand_r(&seed) & 0xffffffff) | (1ULL << 32); } +#endif int main(void) { -- cgit v1.2.1