ATSHA204 emulated signing backend
ATSHA204 emulated signing backend. The emulated ATSHA204 implementation offers pseudo random number generation and HMAC-SHA256 authentication compatible with a "physical" ATSHA204. NOTE: Key is stored in clear text in the Arduino firmware. Therefore, the use of this back-end could compromise the key used in the signed message infrastructure if device is lost and its memory dumped. The seed for the random number generated is sampled from an analog pin. The pin is set in MyConfig.h using RANDOMSEED_PIN. The pin should be unconnected. The key to use for HMAC calculations must match the key used by other nodes this node will exchange signed messages with. The key for ATSHA204 emulator is set in MyConfig.h using hmacKey.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
// Choose signing backend by enabling one of the following
|
||||
#define MYSENSORS_SIGNING_DUMMY
|
||||
//#define MYSENSORS_SIGNING_ATSHA204
|
||||
//#define MYSENSORS_SIGNING_ATSHA204SOFT
|
||||
|
||||
// Define a suitable timeout for a signature verification session
|
||||
// Consider the turnaround from a nonce being generated to a signed message being received
|
||||
@@ -58,6 +59,33 @@ typedef class MySigningDriverDummy MySigningDriverClass;
|
||||
typedef class MySigningDriverAtsha204 MySigningDriverClass;
|
||||
#endif
|
||||
|
||||
#ifdef MYSENSORS_SIGNING_ATSHA204SOFT
|
||||
// Key to use for HMAC calculation
|
||||
static uint8_t hmacKey[32] = {
|
||||
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
|
||||
};
|
||||
|
||||
// Pick an unconnected analog pin for RANDOMSEED_PIN
|
||||
#ifdef MYSENSORS_SENSOR
|
||||
#define RANDOMSEED_PIN 7 //A7
|
||||
#endif
|
||||
|
||||
#ifdef MYSENSORS_SERIAL_GATEWAY
|
||||
#define RANDOMSEED_PIN 7 //A7
|
||||
#endif
|
||||
|
||||
#ifdef MYSENSORS_ETHERNET_MQTT_GATEWAY
|
||||
#define RANDOMSEED_PIN 7 //A7
|
||||
#endif
|
||||
|
||||
#include "MySigningDriverAtsha204Soft.h"
|
||||
#define SIGNING_IDENTIFIER (1) // SHA256-based HMAC (ATSHA204 specific)
|
||||
typedef class MySigningDriverAtsha204Soft MySigningDriverClass;
|
||||
#endif
|
||||
|
||||
/***
|
||||
* Enable/Disable debug logging
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user