Skip to content

Commit ccb0ab5

Browse files
duda-patrykChromeos LUCI
authored andcommitted
boringssl: Switch to Zephyr implementation of getentropy()
Since we have support for getentropy() in Zephyr[1], we can remove the EC/Zephyr implementation. The tests were also upstreamed, so we will remove them here. Now the getentropy() tests can be found at zephyr/main/tests/posix/getentropy. [1] zephyrproject-rtos/zephyr#71862 BUG=b:321092852 TEST=twister -T ../../third_party/zephyr/main/tests/posix/getentropy TEST=twister -v -i -T zephyr/test/ --test boringssl.selftest Cq-Depend: chromium:5497107 Change-Id: I5e0cc9e776cc2f1ebdf6a41a0edbb1f8f5dcd0f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/5490419 Code-Coverage: Zoss <[email protected]> Reviewed-by: Tom Hughes <[email protected]> Commit-Queue: Patryk Duda <[email protected]> Tested-by: Patryk Duda <[email protected]>
1 parent 83c4711 commit ccb0ab5

File tree

6 files changed

+4
-83
lines changed

6 files changed

+4
-83
lines changed

third_party/boringssl/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
if(CONFIG_BORINGSSL_CRYPTO)
66

7-
zephyr_library_named(boringssl)
7+
zephyr_interface_library_named(boringssl)
88

99
# Currently BoringSSL is not as a module, so we need to provide a path to
1010
# sources.
@@ -60,10 +60,6 @@ add_subdirectory(${BORINGSSL_SOURCES} build EXCLUDE_FROM_ALL)
6060
# Link 'crypto' library into boringssl library.
6161
zephyr_library_link_libraries(crypto)
6262

63-
# Provide implementation of getentropy() using Zephyr Entropy Device.
64-
zephyr_library_sources_ifdef(CONFIG_BORINGSSL_HARDWARE_ENTROPY
65-
common/getentropy_zephyr.c)
66-
6763
# Add compile options required by BoringSSL.
6864
# -D_POSIX_C_SOURCE=200809L is needed because BoringSSL uses strdup() function
6965
# is guarded by __POSIX_VISIBLE >=200809 in Newlib's string.h file.

third_party/boringssl/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if BORINGSSL_CRYPTO
1515
config BORINGSSL_HARDWARE_ENTROPY
1616
bool "Provide entropy from hardware RNG"
1717
default y
18-
depends on ENTROPY_GENERATOR
18+
depends on GETENTROPY
1919
help
2020
This option enables support for providing entropy to BoringSSL.
2121
Entropy comes from hardware RNG selected in DTS.

third_party/boringssl/common/getentropy_zephyr.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

zephyr/program/fpmcu/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ CONFIG_PTHREAD=y
9999
CONFIG_PTHREAD_IPC=y
100100
CONFIG_PTHREAD_KEY=y
101101
CONFIG_PTHREAD_MUTEX=y
102+
CONFIG_GETENTROPY=y
102103
# Disable unused part of the POSIX API.
103104
CONFIG_POSIX_CONFSTR=n
104105
CONFIG_POSIX_MQUEUE=n

zephyr/test/boringssl/main.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,3 @@ ZTEST(boringssl_crypto, test_rand_large_request)
5050
CRYPTO_sysrand(buffer, buf_size);
5151
zassert_true(memcmp(buffer, zeroes, buf_size) != 0);
5252
}
53-
54-
ZTEST(boringssl_crypto, test_getentropy_too_large)
55-
{
56-
uint8_t buf[256 + 1] = { 0 };
57-
58-
int ret = getentropy(buf, sizeof(buf));
59-
zassert_equal(ret, -1);
60-
zassert_equal(errno, EIO);
61-
}
62-
63-
ZTEST(boringssl_crypto, test_getentropy_null_buffer)
64-
{
65-
int ret = getentropy(NULL, 0);
66-
zassert_equal(ret, -1);
67-
zassert_equal(errno, EFAULT);
68-
}
69-
70-
ZTEST(boringssl_crypto, test_getentropy)
71-
{
72-
uint8_t zero[256] = { 0 };
73-
uint8_t buf1[256];
74-
uint8_t buf2[256];
75-
76-
int ret = getentropy(buf1, sizeof(buf1));
77-
zassert_equal(ret, 0);
78-
79-
ret = getentropy(buf2, sizeof(buf2));
80-
zassert_equal(ret, 0);
81-
82-
zassert_true(memcmp(buf1, zero, sizeof(zero)) != 0);
83-
zassert_true(memcmp(buf2, zero, sizeof(zero)) != 0);
84-
zassert_true(memcmp(buf1, buf2, sizeof(buf1)) != 0);
85-
}

zephyr/test/boringssl/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ CONFIG_BORINGSSL_HARDWARE_ENTROPY=y
88
CONFIG_COMMON_LIBC_MALLOC=y
99
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131070
1010
CONFIG_ENTROPY_GENERATOR=y
11+
CONFIG_GETENTROPY=y

0 commit comments

Comments
 (0)