diff --git a/libraries/MySensors/MyConfig.h b/libraries/MySensors/MyConfig.h index 736b11d..4d05506 100644 --- a/libraries/MySensors/MyConfig.h +++ b/libraries/MySensors/MyConfig.h @@ -211,7 +211,7 @@ // Note that a node can still transmit a non-salted message (i.e. have white listing disabled) // to a node that has white listing enabled (assuming the receiver does not have a matching entry // for the sender in it's white list) -//#define MY_SIGNING_NODE_WHITELIST {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}} +//#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}} // Atsha204 default pin setting #ifndef MY_SIGNING_ATSHA204_PIN diff --git a/libraries/MySensors/core/MySigningAtsha204.cpp b/libraries/MySensors/core/MySigningAtsha204.cpp index 6bc735c..22d0306 100644 --- a/libraries/MySensors/core/MySigningAtsha204.cpp +++ b/libraries/MySensors/core/MySigningAtsha204.cpp @@ -75,6 +75,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf, bool signerGetNonce(MyMessage &msg) { + DEBUG_SIGNING_PRINTLN(F("ATSHA204")); // Generate random number for use as nonce // We used a basic whitening technique that takes the first byte of a new random value and builds up a 32-byte random value // This 32-byte random value is then hashed (SHA256) to produce the resulting nonce @@ -119,6 +120,7 @@ bool signerCheckTimer() { } bool signerPutNonce(MyMessage &msg) { + DEBUG_SIGNING_PRINTLN(F("ATSHA204")); if (((uint8_t*)msg.getCustom())[0] != SIGNING_IDENTIFIER) { DEBUG_SIGNING_PRINTLN(F("ISI")); // ISI = Incorrect signing identifier return false; @@ -155,6 +157,7 @@ bool signerSignMsg(MyMessage &msg) { // Transfer as much signature data as the remaining space in the message permits memcpy(&msg.data[mGetLength(msg)], &_singning_rx_buffer[SHA204_BUFFER_POS_DATA], MAX_PAYLOAD-mGetLength(msg)); + DEBUG_SIGNING_PRINTBUF(F("SIM:"), (uint8_t*)&msg.data[mGetLength(msg)], MAX_PAYLOAD-mGetLength(msg)); // SIM = Signature in message return true; } diff --git a/libraries/MySensors/core/MySigningAtsha204Soft.cpp b/libraries/MySensors/core/MySigningAtsha204Soft.cpp index 140124f..8fafae0 100644 --- a/libraries/MySensors/core/MySigningAtsha204Soft.cpp +++ b/libraries/MySensors/core/MySigningAtsha204Soft.cpp @@ -79,6 +79,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf, bool signerGetNonce(MyMessage &msg) { + DEBUG_SIGNING_PRINTLN(F("ATSHA204Soft")); // Set randomseed randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN)); @@ -121,12 +122,15 @@ bool signerCheckTimer() { } bool signerPutNonce(MyMessage &msg) { + DEBUG_SIGNING_PRINTLN(F("ATSHA204Soft")); if (((uint8_t*)msg.getCustom())[0] != SIGNING_IDENTIFIER) { DEBUG_SIGNING_PRINTLN(F("ISI")); // ISI = Incorrect signing identifier return false; } memcpy(_signing_current_nonce, (uint8_t*)msg.getCustom(), MAX_PAYLOAD); + // We set the part of the 32-byte nonce that does not fit into a message to 0xAA + memset(&_signing_current_nonce[MAX_PAYLOAD], 0xAA, sizeof(_signing_current_nonce)-MAX_PAYLOAD); return true; } @@ -156,6 +160,7 @@ bool signerSignMsg(MyMessage &msg) { // Transfer as much signature data as the remaining space in the message permits memcpy(&msg.data[mGetLength(msg)], _signing_hmac, MAX_PAYLOAD-mGetLength(msg)); + DEBUG_SIGNING_PRINTBUF(F("SIM:"), (uint8_t*)&msg.data[mGetLength(msg)], MAX_PAYLOAD-mGetLength(msg)); // SIM = Signature in message return true; } diff --git a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino index 6dc8854..cb48084 100644 --- a/libraries/MySensors/examples/SecureActuator/SecureActuator.ino +++ b/libraries/MySensors/examples/SecureActuator/SecureActuator.ino @@ -40,12 +40,12 @@ // Enable node whitelisting //#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}} // Enable this if you want destination node to sign all messages sent to this node. Default is not to require signing. -//#define MY_SIGNING_REQUEST_SIGNATURES +#define MY_SIGNING_REQUEST_SIGNATURES // SETTINGS FOR MY_SIGNING_SOFT // Set the soft_serial value to an arbitrary value for proper security (9 bytes) -#define MY_SIGNING_SOFT_SERIAL 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09 +#define MY_SIGNING_SOFT_SERIAL 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09 // Key to use for HMAC calculation in soft signing (32 bytes) #define MY_SIGNING_SOFT_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino b/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino index 4c542df..237ae44 100644 --- a/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino +++ b/libraries/MySensors/examples/Sha204Personalizer/Sha204Personalizer.ino @@ -80,8 +80,7 @@ #endif #ifdef USER_KEY_DATA -#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 const uint8_t user_key_data[32] = {MY_HMAC_KEY}; #endif @@ -877,7 +876,6 @@ void setup() } Serial.print(key[i], HEX); if (i < 31) Serial.print(','); - if (i+1 == 16) Serial.print("\\\n "); } Serial.println(); diff --git a/libraries/MySensors/keywords.txt b/libraries/MySensors/keywords.txt index 522dbd5..b25b571 100644 --- a/libraries/MySensors/keywords.txt +++ b/libraries/MySensors/keywords.txt @@ -53,7 +53,7 @@ MY_INCLUSION_MODE_DURATION LITERAL1 MY_SIGNING_ATSHA204 LITERAL1 MY_SIGNING_SOFT LITERAL1 MY_VERIFICATION_TIMEOUT_MS LITERAL1 -MY_SIGNING_NODE_WHITELIST LITERAL1 +MY_SIGNING_NODE_WHITELISTING LITERAL1 MY_SIGNING_ATSHA204_PIN LITERAL1 MY_SIGNING_SOFT_RANDOMSEED_PIN LITERAL1 MY_SIGNING_SOFT_SERIAL LITERAL1