Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions tests/pkg_mbedtls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ include ../Makefile.tests_common
USEPKG += mbedtls
USEMODULE += mbedtls_entropy

# entropy test keeps failing on this board due to low entropy
TEST_ON_CI_BLACKLIST += samr21-xpro

# Increase stack size of main thread.
CFLAGS += -DTHREAD_STACKSIZE_MAIN=THREAD_STACKSIZE_LARGE

Expand Down
25 changes: 22 additions & 3 deletions tests/pkg_mbedtls/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,35 @@ int main(void)
{
puts("mbedtls test\n");

/* Execute built-in tests */
/* Execute built-in tests SHA-2xx tests */
mbedtls_sha256_self_test(1);

bool adc_noise_single_entropy = false;
/* NOTE, the following express needs adjustment when further entropy
sources added by RIOT */
#if IS_USED(MODULE_MBEDTLS_ENTROPY_SOURCE_ADC) && !IS_USED(MODULE_MBEDTLS_ENTROPY_SOURCE_HWRNG)
/* If the adc noise entropy source is compiled and is the only source
utilized with the mbedtls entropy module, indicate it */
adc_noise_single_entropy = true;
#endif
/* Used by the testrunner to ignore potential test failures it the case of
a single adc noise entropy source */
printf("adc_noise_single_entropy: %d\n", adc_noise_single_entropy);

/* Initializes available entropy sources */
entropy_mbedtls_riot_init();

/* Execute mbedtls built-in entropy tests*/
mbedtls_entropy_self_test(1);

/* Execute convenience functions */
/* Execute convenience entropy functions */
unsigned char out[4];
entropy_mbedtls_riot_init();
/* This function requires entropy_mbedtls_riot_init() beforehand */
entropy_mbedtls_riot_retrieve(out, sizeof(out));
/* Clears the internal context again */
entropy_mbedtls_riot_uninit();

/* This function does not require initialization */
entropy_mbedtls_riot_get(out, sizeof(out));

return 0;
Expand Down
11 changes: 10 additions & 1 deletion tests/pkg_mbedtls/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ def testfunc(child):
child.expect_exact('SHA-256 test #1: passed')
child.expect_exact('SHA-256 test #2: passed')
child.expect_exact('SHA-256 test #3: passed')
child.expect_exact('ENTROPY test: passed')

# If the adc noise module is not a single entropy source, the ENTROPY test
# should succeed. Otherwise, if the adc noise module is the only entropy
# source, ignore a test failure which might be introduced by improver ADC
# configurations or properties. This still allows us to execute this test
# regardless of configuration specifics.
child.expect(r'adc_noise_single_entropy: (\d+)\r\n')
adc_noise_single_entropy = int(child.match.group(1))
if adc_noise_single_entropy == 0:
child.expect_exact('ENTROPY test: passed')


if __name__ == "__main__":
Expand Down