diff options
author | Yi Chou <yich@google.com> | 2023-05-02 15:18:58 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-16 12:34:55 +0000 |
commit | 28939ffb30bdb1d9e6386cf390c982922ea9253d (patch) | |
tree | 814d3fcf3689238b4e32c3d4085db23f3dd310a2 /test/boringssl_crypto.cc | |
parent | 9ab5743831f081d1b4d161fe28be711ef2d01d4c (diff) | |
download | chrome-ec-28939ffb30bdb1d9e6386cf390c982922ea9253d.tar.gz |
boringssl: Implement sysrand from TRNG
The boringssl doesn't include the TRNG implementation, we need our own
CRYPTO_sysrand.
BUG=b:248508087
TEST=make V=1 BOARD=bloonchipper -j
TEST=./test/run_device_tests.py --board bloonchipper -t boringssl_crypto
=> PASS
TEST=./test/run_device_tests.py --board dartmonkey -t boringssl_crypto
=> PASS
Change-Id: I3136bcc96e09f674278bf338297d7bc0576e174c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4496289
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Yi Chou <yich@google.com>
Tested-by: Yi Chou <yich@google.com>
Diffstat (limited to 'test/boringssl_crypto.cc')
-rw-r--r-- | test/boringssl_crypto.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/boringssl_crypto.cc b/test/boringssl_crypto.cc new file mode 100644 index 0000000000..bc7bd5dffe --- /dev/null +++ b/test/boringssl_crypto.cc @@ -0,0 +1,35 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "openssl/bn.h" +#include "openssl/ec.h" +#include "openssl/mem.h" +#include "openssl/obj_mac.h" +#include "openssl/rand.h" +#include "test_util.h" +#include "util.h" + +test_static enum ec_error_list test_rand(void) +{ + constexpr uint8_t zero[256] = { 0 }; + uint8_t buf1[256]; + uint8_t buf2[256]; + + RAND_bytes(buf1, sizeof(buf1)); + RAND_bytes(buf2, sizeof(buf2)); + + TEST_ASSERT_ARRAY_NE(buf1, zero, sizeof(zero)); + TEST_ASSERT_ARRAY_NE(buf2, zero, sizeof(zero)); + TEST_ASSERT_ARRAY_NE(buf1, buf2, sizeof(buf1)); + + return EC_SUCCESS; +} + +extern "C" void run_test(int argc, const char **argv) +{ + RUN_TEST(test_rand); + test_print_result(); +} |