From e070d5a694e9869375571dc349c8e1123b7c6f9f Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 8 Feb 2019 14:43:57 +0100 Subject: [PATCH 1/3] sys/random: fix indention in doxygen header --- sys/random/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/random/random.c b/sys/random/random.c index 8449507b3f9e..85f1bc3e041f 100644 --- a/sys/random/random.c +++ b/sys/random/random.c @@ -7,13 +7,13 @@ */ /** - * @ingroup sys_random + * @ingroup sys_random * @{ * @file * - * @brief PRNG seeding + * @brief PRNG seeding * - * @author Kaspar Schleiser + * @author Kaspar Schleiser * @} */ From 8a135d3a433e527ceed4e94c8682af6277269747 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 8 Feb 2019 14:43:09 +0100 Subject: [PATCH 2/3] sys/random: add guard for periph/cpuid include --- sys/random/random.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/random/random.c b/sys/random/random.c index 85f1bc3e041f..3d356c8dcab4 100644 --- a/sys/random/random.c +++ b/sys/random/random.c @@ -21,11 +21,13 @@ #include "log.h" #include "luid.h" -#include "periph/cpuid.h" #include "random.h" #ifdef MODULE_PUF_SRAM #include "puf_sram.h" #endif +#ifdef MODULE_PERIPH_CPUID +#include "periph/cpuid.h" +#endif #define ENABLE_DEBUG (0) #include "debug.h" From 64489e8b444efde859e9f048b17707e5da88a983 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 8 Feb 2019 14:41:57 +0100 Subject: [PATCH 3/3] sys/random: add hwrng as seed source (if available) --- Makefile.dep | 4 ++++ sys/random/random.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Makefile.dep b/Makefile.dep index fac58386961d..f89090bbb578 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -661,6 +661,10 @@ ifneq (,$(filter random,$(USEMODULE))) USEMODULE += hashes endif + ifeq (,$(filter puf_sram,$(USEMODULE))) + FEATURES_OPTIONAL += periph_hwrng + endif + USEMODULE += luid endif diff --git a/sys/random/random.c b/sys/random/random.c index 3d356c8dcab4..ffd23fcfff93 100644 --- a/sys/random/random.c +++ b/sys/random/random.c @@ -1,5 +1,6 @@ /** * Copyright (C) 2017 Kaspar Schleiser + * 2019 Freie Universität Berlin * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -14,6 +15,7 @@ * @brief PRNG seeding * * @author Kaspar Schleiser + * @author Hauke Petersen * @} */ @@ -25,6 +27,9 @@ #ifdef MODULE_PUF_SRAM #include "puf_sram.h" #endif +#ifdef MODULE_PERIPH_HWRNG +#include "periph/hwrng.h" +#endif #ifdef MODULE_PERIPH_CPUID #include "periph/cpuid.h" #endif @@ -41,6 +46,8 @@ void auto_init_random(void) LOG_WARNING("random: PUF SEED not fresh\n"); } seed = puf_sram_seed; +#elif defined (MODULE_PERIPH_HWRNG) + hwrng_read(&seed, 4); #elif defined (MODULE_PERIPH_CPUID) luid_get(&seed, 4); #else