Skip to content

Commit 1b2aefa

Browse files
committed
Merge pull request arduino#1 from mysensors/development
update
2 parents 714d630 + 7837501 commit 1b2aefa

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: libraries/MySensors/core/MySensorCore.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ void _begin() {
6363
#if !defined(MY_DISABLED_SERIAL)
6464
hwInit();
6565
#endif
66+
67+
#if defined(MY_SIGNING_SOFT)
68+
// initialize pseudo-RNG
69+
randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN));
70+
#endif
6671

6772
debug(PSTR("Starting " MY_NODE_TYPE " (" MY_CAPABILIIES ", " LIBRARY_VERSION ")\n"));
6873

Diff for: libraries/MySensors/core/MySigningAtsha204Soft.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
9191

9292
bool signerGetNonce(MyMessage &msg) {
9393
DEBUG_SIGNING_PRINTBUF(F("Signing backend: ATSHA204Soft"), NULL, 0);
94-
// Set randomseed
95-
randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN));
9694

9795
// We used a basic whitening technique that takes the first byte of a new random value and builds up a 32-byte random value
9896
// This 32-byte random value is then hashed (SHA256) to produce the resulting nonce
9997
_signing_sha256.init();
10098
for (int i = 0; i < 32; i++) {
101-
_signing_sha256.write(random(255));
99+
_signing_sha256.write(random(256));
102100
}
103101
memcpy(_signing_current_nonce, _signing_sha256.result(), MAX_PAYLOAD);
104102
DEBUG_SIGNING_PRINTBUF(F("SHA256: "), _signing_current_nonce, 32);

0 commit comments

Comments
 (0)