Skip to content
Snippets Groups Projects
Commit ccf704ba authored by Kaspar Schleiser's avatar Kaspar Schleiser
Browse files

sys: random: use luid to generate random seed

parent ac2e2e21
Branches
No related tags found
No related merge requests found
...@@ -656,6 +656,8 @@ ifneq (,$(filter random,$(USEMODULE))) ...@@ -656,6 +656,8 @@ ifneq (,$(filter random,$(USEMODULE)))
ifneq (,$(filter prng_tinymt32,$(USEMODULE))) ifneq (,$(filter prng_tinymt32,$(USEMODULE)))
USEMODULE += tinymt32 USEMODULE += tinymt32
endif endif
USEMODULE += luid
endif endif
ifneq (,$(filter openthread_contrib,$(USEMODULE))) ifneq (,$(filter openthread_contrib,$(USEMODULE)))
......
...@@ -80,10 +80,6 @@ ...@@ -80,10 +80,6 @@
#include "net/fib.h" #include "net/fib.h"
#endif #endif
#ifdef MODULE_PRNG
#include "random.h"
#endif
#ifdef MODULE_GCOAP #ifdef MODULE_GCOAP
#include "net/gcoap.h" #include "net/gcoap.h"
#endif #endif
...@@ -99,7 +95,8 @@ ...@@ -99,7 +95,8 @@
void auto_init(void) void auto_init(void)
{ {
#ifdef MODULE_PRNG #ifdef MODULE_PRNG
random_init(0); void auto_init_random(void);
auto_init_random();
#endif #endif
#ifdef MODULE_XTIMER #ifdef MODULE_XTIMER
DEBUG("Auto init xtimer module.\n"); DEBUG("Auto init xtimer module.\n");
......
SRC := seed.c
BASE_MODULE := prng BASE_MODULE := prng
SUBMODULES := 1 SUBMODULES := 1
......
/**
* Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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
* directory for more details.
*/
/**
* @ingroup sys_random
* @{
* @file
*
* @brief PRNG seeding
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @}
*/
#include <stdint.h>
#include "log.h"
#include "luid.h"
#include "periph/cpuid.h"
#include "random.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
void auto_init_random(void)
{
uint32_t seed;
#ifdef MODULE_PERIPH_CPUID
luid_get(&seed, 4);
#else
LOG_WARNING("random: NO SEED AVAILABLE!\n");
seed = 1;
#endif
DEBUG("random: using seed value %u\n", (unsigned)seed);
random_init(seed);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment