diff --git a/tests/periph_random/Makefile b/tests/periph_hwrng/Makefile similarity index 57% rename from tests/periph_random/Makefile rename to tests/periph_hwrng/Makefile index 3ad07f517f..ce770527f4 100644 --- a/tests/periph_random/Makefile +++ b/tests/periph_hwrng/Makefile @@ -1,7 +1,7 @@ -export APPLICATION = periph_random +export APPLICATION = periph_hwrng include ../Makefile.tests_common -FEATURES_REQUIRED = periph_random +FEATURES_REQUIRED = periph_hwrng USEMODULE += xtimer diff --git a/tests/periph_hwrng/README.md b/tests/periph_hwrng/README.md new file mode 100644 index 0000000000..a7132bf3bb --- /dev/null +++ b/tests/periph_hwrng/README.md @@ -0,0 +1,9 @@ +Expected result +=============== +This test outputs a sequence of random bytes, starting with one, then two and so +on, until 20 random bytes are printed. Then the application sleeps for a second +and starts over. + +Background +========== +Test the functionality of a platforms HWRNG implementation. diff --git a/tests/periph_random/main.c b/tests/periph_hwrng/main.c similarity index 71% rename from tests/periph_random/main.c rename to tests/periph_hwrng/main.c index 36e30d3434..364f63f2bf 100644 --- a/tests/periph_random/main.c +++ b/tests/periph_hwrng/main.c @@ -22,19 +22,20 @@ #include #include "xtimer.h" -#include "periph/random.h" +#include "periph/hwrng.h" #define LIMIT (20U) int main(void) { - char buf[LIMIT]; + uint8_t buf[LIMIT]; - puts("\nRandom number generator low-level driver test\n"); - printf("This test will print from 1 to %i random bytes about every second\n\n", LIMIT); + puts("\nHWRNG peripheral driver test\n"); + printf("This test will print from 1 to %i random bytes about every" + "second\n\n", LIMIT); - puts("Initializing Random Number Generator driver.\n"); - random_init(); + puts("Initializing the HWRNG driver.\n"); + hwrng_init(); while (1) { /* zero out buffer */ @@ -43,12 +44,7 @@ int main(void) /* create random numbers */ for (unsigned i = 1; i <= LIMIT; i++) { printf("generating %u random byte(s)\n", i); - unsigned count = random_read(buf, i); - - if (count != i) { - printf("Error generating random bytes, got %u instead of %u", count, i); - return 0; - } + hwrng_read(buf, i); printf("Got:"); for (unsigned j = 0; j < i; j++) { diff --git a/tests/periph_random/README.md b/tests/periph_random/README.md deleted file mode 100644 index 26d7b93954..0000000000 --- a/tests/periph_random/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Expected result -=============== -This test outputs a sequence of random bytes, starting with one, then two and so on, until 20 random bytes are printed. Then the application sleeps for a second and starts over. - -Background -========== -This test was introduced to test the implementation of the low-level random number generator driver. For most platforms the implementation is based on hardware CPU peripherals. diff --git a/tests/pkg_micro-ecc/Makefile b/tests/pkg_micro-ecc/Makefile index 6f9dd7a87b..4e0a9aae58 100644 --- a/tests/pkg_micro-ecc/Makefile +++ b/tests/pkg_micro-ecc/Makefile @@ -1,7 +1,7 @@ APPLICATION = micro-ecc include ../Makefile.tests_common -FEATURES_REQUIRED = periph_random +FEATURES_REQUIRED = periph_hwrng USEPKG += micro-ecc include $(RIOTBASE)/Makefile.include diff --git a/tests/pkg_micro-ecc/main.c b/tests/pkg_micro-ecc/main.c index 808586b2b6..012253ed68 100644 --- a/tests/pkg_micro-ecc/main.c +++ b/tests/pkg_micro-ecc/main.c @@ -37,7 +37,7 @@ #include #include #include "uECC.h" -#include "periph/random.h" +#include "periph/hwrng.h" #define TESTROUNDS 16 @@ -61,9 +61,7 @@ int main(void) uint8_t l_sig[uECC_BYTES * 2]; /* initialize hardware random number generator */ - random_init(); - /* power off RNG to save energy */ - random_poweroff(); + hwrng_init(); printf("Testing %d random private key pairs and signature\n", TESTROUNDS);