From 8400d5142039d73eac29cde048da3368a5db033b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Sat, 25 Nov 2017 05:39:42 +1000 Subject: [PATCH] Use __TIME__ and __DATE__ to provide the RNG a compile-time seed --- libraries/Crypto/RNG.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/Crypto/RNG.cpp b/libraries/Crypto/RNG.cpp index c4226555..f0647db2 100644 --- a/libraries/Crypto/RNG.cpp +++ b/libraries/Crypto/RNG.cpp @@ -415,6 +415,13 @@ void RNGClass::begin(const char *tag) // Stir in the unique identifier for the CPU so that different // devices will give different outputs even without seeding. stirUniqueIdentifier(); +#else + // AVR devices don't have anything like a serial number so it is + // difficult to make every device unique. Use the compilation + // time and date to provide a little randomness across applications + // if not across devices running the same pre-compiled application. + tag = __TIME__ __DATE__; + stir((const uint8_t *)tag, strlen(tag)); #endif #if defined(RNG_WATCHDOG)