diff options
author | Vadim Sukhomlinov <sukhomlinov@google.com> | 2021-09-23 18:00:14 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-24 20:22:45 +0000 |
commit | 24c5d1beb44ad229e962a9178e98468b8fe9705f (patch) | |
tree | 5dae3e140d140ed30e4e7d3e3da24d54a5b96766 /test | |
parent | 5044b81a4c797a058a21e95349437f04ab33e2ed (diff) | |
download | chrome-ec-24c5d1beb44ad229e962a9178e98468b8fe9705f.tar.gz |
cr50: Fix sign comparison warnings (-Wsign-compare)
For crypto code we care about possible concerns during review, so add
more strict warnings. Fix all uses int to uint32_t/size_t comparisons,
make consistent use of size_t vs. uint32_t in crypto code.
Update test/tpm_test/bn_test.c to compile for checking big number
functions correctness.
BUG=none
TEST=make BOARD=cr50 CRYPTO_TEST=1; test/tpm_test/tpmtest.py
TCG tests:
---------------------- Test Result Summary -----------------------------
Test executed on: Thu Sep 23 17:45:19 2021
Performed Tests: 248
Passed Tests: 248
Failed Tests: 0
Errors: 0
Warnings: 0
========================================================================
Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com>
Change-Id: I47e5de3d180d3aebb13b3feef4c1da87c9f6a174
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3180279
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/tpm_test/Makefile | 6 | ||||
-rw-r--r-- | test/tpm_test/bn_test.c | 25 |
2 files changed, 29 insertions, 2 deletions
diff --git a/test/tpm_test/Makefile b/test/tpm_test/Makefile index 29d3e229bc..985e0fffcb 100644 --- a/test/tpm_test/Makefile +++ b/test/tpm_test/Makefile @@ -37,6 +37,7 @@ CFLAGS += -I ${PYTHON_INCLUDE} CFLAGS += -I../../../../third_party/cryptoc/include CFLAGS += -I../../board/cr50 CFLAGS += -I../../chip/g +CFLAGS += -I../../core/host CFLAGS += -I../../fuzz CFLAGS += -I../../include CFLAGS += -I.. @@ -46,6 +47,8 @@ CFLAGS += -Itestlib CFLAGS += -DLIBFTDI1=1 CFLAGS += -c CFLAGS += -DCR50_NO_BN_ASM +CFLAGS += -DBOARD_HOST +CFLAGS += -DBOARD_TASKFILE="ec.tasklist" CFLAGS += -I../../fuzz TARGET = ftdi_spi_tpm @@ -68,7 +71,8 @@ $(obj)/%.o: $(obj)/%.c $(obj)/%.o: %.c $(call echo," CC $(notdir $@)") - $(Q)gcc $(CFLAGS) -Wall -Werror -MMD -MF $@.d -MT $@ -o $@ $< + $(Q)gcc $(CFLAGS) -Wall -Werror -Wno-error=deprecated-declarations\ + -Wno-error=unused-variable -MMD -MF $@.d -MT $@ -o $@ $< $(obj)/_$(TARGET).so: $(OBJS) $(obj)/$(TARGET).py $(call echo," LD $(notdir $@)") diff --git a/test/tpm_test/bn_test.c b/test/tpm_test/bn_test.c index db06ee93d4..78268d9ba7 100644 --- a/test/tpm_test/bn_test.c +++ b/test/tpm_test/bn_test.c @@ -2,7 +2,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "dcrypto.h" +#include "internal.h" #include <assert.h> #include <stdio.h> @@ -403,6 +403,29 @@ void watchdog_reload(void) { } +bool fips_rand_bytes(void *buffer, size_t len) +{ + uint8_t *b, *end; + static unsigned int seed = 1; + + for (b = buffer, end = b+len; b != end; b++) + *b = (uint8_t)rand_r(&seed); + return true; +} + +const struct fips_vtable *fips_vtable; + +void fips_throw_err(enum fips_status err) +{ +} + +uint64_t fips_trng_rand32(void) +{ + static unsigned int seed = 100; + + return (uint64_t)(rand_r(&seed) & 0xffffffff) | (1ULL << 32); +} + int main(void) { assert(test_bn_modinv() == 0); |