summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Sukhomlinov <sukhomlinov@google.com>2021-10-08 16:43:53 -0700
committerCommit Bot <commit-bot@chromium.org>2021-10-09 04:30:02 +0000
commitd3b1de5a1e233787e8e1128a64237f4d09955ff5 (patch)
tree48266c63badb78b9d27b7aa135daed020119a9f8
parent713045974620ec3f3757fa37865edf9b25da8cc3 (diff)
downloadchrome-ec-d3b1de5a1e233787e8e1128a64237f4d09955ff5.tar.gz
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 <sukhomlinov@google.com> Change-Id: I08749ebaa930fd4f71d7406ed289bf480b5a8510 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3215057 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 Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r--test/tpm_test/Makefile3
-rw-r--r--test/tpm_test/bn_test.c8
2 files changed, 10 insertions, 1 deletions
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 <assert.h>
#include <stdio.h>
@@ -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)
{