mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/pkg_mbedtls: improve entropy test case and doc
This commit is contained in:
parent
9b95605f78
commit
02cbea0e67
@ -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;
|
||||
|
@ -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__":
|
||||
|
Loading…
Reference in New Issue
Block a user