Signing improvements package (#871)

* Signing support with MAX_PAYLOAD>32

Support in the signing backends to handle configurations
where MAX_PAYLOAD is more than 32 bytes.

Fixes #748

* Support big message signatures

Support for signing messages larger than 32 bytes.
This is not fully testable with the current version of
the library but the change would add theoretical support
for signing any sized messages.

Fixes #749

* Have gw properly indicate whitelisting preferences

If the gateway hold a signing whitelist, inform all
nodes of this requirement and not just nodes that hold
whitelists themselves.

Fixes #806

* Harden security

The flag MY_SIGNING_GW_REQUEST_SIGNATURES_FROM_ALL
has been removed. Gateway will now request signatures
from everyone by default.
In addition to this, no nodes in the network will allow
clearing of signing/whitelisting preferences by OTA
commands by default.
If the old behaviour is needed (suitable for gradual
signing roll out and development purposes) a new flag,
MY_SIGNING_WEAK_SECURITY can be set.

Fixes #807

* Signing debug messages rewritten

All signing related debug has been rewritten to
better match other core debug printouts.
Also, backends are updated to have a smaller
implementation delta.

* Simplified signing option implemented

Enable by MY_SIGNING_SIMPLE_PASSWD. Signing, and signing requirements
will be enabled, as will encryption. Whitelisting is optional.
The value provided to MY_SIGNING_SIMPLE_PASSWD is used as HMAC and AES
key. Whitelists use the first 8 bytes of the password and the ninth
byte from the node ID as serial.
Password is required to be at least 8 characters wide. It is zero
padded if it is not long enough to cover the AES (16 bytes) and HMAC
(32 bytes) keys. It is not recommended to have a password shorter than
32 bytes, and there is no need for a password longer than 32 bytes.

* Add documentation section for signing debug

* Add nRF5 encryption to simple signing option

* Restructure MySigning documentation

* Minor fixes for Linux
This commit is contained in:
Marcelo Aquino
2017-05-31 17:13:29 +02:00
committed by Patrick Fallberg
parent 4c0661e410
commit 28c4f3f19e
28 changed files with 1083 additions and 737 deletions
+3
View File
@@ -38,6 +38,9 @@
#define MY_SERIALDEVICE Serial
#endif
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
// Define these as macros to save valuable space
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
#define hwDigitalRead(__pin) digitalReadFast(__pin)
+2
View File
@@ -31,6 +31,8 @@
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
#define EEPROM_size (1024)
+3
View File
@@ -40,6 +40,9 @@ SerialSimulator Serial = SerialSimulator();
#define MY_SERIALDEVICE Serial
#endif
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
// Define these as macros (do nothing)
#define hwWatchdogReset()
#define hwReboot()
+3
View File
@@ -45,6 +45,9 @@
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
#define printf_P printf
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
// Define these as macros to save valuable space
#define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
#define hwDigitalRead(__pin) digitalRead(__pin)
+2
View File
@@ -39,6 +39,8 @@ extEEPROM eep(MY_EXT_EEPROM_SIZE, 1, MY_EXT_EEPROM_PAGE_SIZE,
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__)
// Define these as macros to save valuable space
+3
View File
@@ -42,6 +42,9 @@
#define MY_SERIALDEVICE Serial
#endif
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
#ifndef digitalPinToInterrupt
#define digitalPinToInterrupt(__pin) (__pin)
#endif
+3
View File
@@ -50,6 +50,9 @@
#define SIM_SCGC6_RNGA ((uint32_t)0x00000200)
#endif
#define MIN(a,b) min(a,b)
#define MAX(a,b) max(a,b)
// Define these as macros to save valuable space
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
#define hwDigitalRead(__pin) digitalReadFast(__pin)
+5
View File
@@ -273,7 +273,12 @@ void print_aes_key(uint8_t *key_ptr = NULL)
uint8_t key[16];
if (key_ptr == NULL) {
#ifdef MY_SIGNING_SIMPLE_PASSWD
memset(key, 0, 16);
memcpy(key, MY_SIGNING_SIMPLE_PASSWD, strnlen(MY_SIGNING_SIMPLE_PASSWD, 16));
#else
hwReadConfigBlock(&key, reinterpret_cast<void*>EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#endif
key_ptr = key;
}
+6 -1
View File
@@ -39,7 +39,12 @@ uint8_t _psk[16];
bool transportInit(void)
{
#if defined(MY_NRF5_ESB_ENABLE_ENCRYPTION)
hwReadConfigBlock((void *)_psk, (void *)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#ifdef MY_SIGNING_SIMPLE_PASSWD
memset(_psk, 0, 16);
memcpy(_psk, MY_SIGNING_SIMPLE_PASSWD, strnlen(MY_SIGNING_SIMPLE_PASSWD, 16));
#else
hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#endif
// set up AES-key
_aes.set_key(_psk, 16);
// Make sure it is purged from memory when set
+5
View File
@@ -68,7 +68,12 @@ uint8_t _psk[16];
bool transportInit(void)
{
#if defined(MY_RF24_ENABLE_ENCRYPTION)
#ifdef MY_SIGNING_SIMPLE_PASSWD
memset(_psk, 0, 16);
memcpy(_psk, MY_SIGNING_SIMPLE_PASSWD, strnlen(MY_SIGNING_SIMPLE_PASSWD, 16));
#else
hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#endif
//set up AES-key
_aes.set_key(_psk, 16);
// Make sure it is purged from memory when set
+11 -1
View File
@@ -33,7 +33,12 @@ bool transportInit(void)
#ifdef MY_RFM69_ENABLE_ENCRYPTION
uint8_t _psk[16];
#ifdef MY_SIGNING_SIMPLE_PASSWD
memset(_psk, 0, 16);
memcpy(_psk, MY_SIGNING_SIMPLE_PASSWD, strnlen(MY_SIGNING_SIMPLE_PASSWD, 16));
#else
hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#endif
RFM69_encrypt((const char*)_psk);
(void)memset(_psk, 0, 16); // Make sure it is purged from memory when set
#endif
@@ -163,7 +168,12 @@ bool transportInit(void)
if (_radio.initialize(MY_RFM69_FREQUENCY, _address, MY_RFM69_NETWORKID)) {
#ifdef MY_RFM69_ENABLE_ENCRYPTION
uint8_t _psk[16];
#ifdef MY_SIGNING_SIMPLE_PASSWD
memset(_psk, 0, 16);
memcpy(_psk, MY_SIGNING_SIMPLE_PASSWD, strnlen(MY_SIGNING_SIMPLE_PASSWD, 16));
#else
hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16);
#endif
_radio.encrypt((const char*)_psk);
(void)memset(_psk, 0, 16); // Make sure it is purged from memory when set
#endif
@@ -262,4 +272,4 @@ int16_t transportGetTxPowerLevel(void)
return INVALID_LEVEL;
}
#endif
#endif