Having an issue with message signing.
-
Hello again
I am having an issue with message signing. I have begun to expand my mysensors devices to include some actuators and sensors I want to secure. I have tried to get this to work, but keep hitting a wall.
Here;s my set up for my testing. My mega Ethernet gateway with software backed signing enabled, and my Uno set up as a mock relay actuator with software backed signing enabled. If I set up MY_SIGNING_SIMPLE_PASSWD "blahblahblah", everything works great. As soon as thats disabled...nothing wants to talk to each other.
How I have programmed the devices. On the gateway I ran the personalizer sketch and generated the HMAC and AES keys. I copied that info into the proper sections, disabled generate keys and enabled personalize soft. I then ran the personalizer on both the gateway and the node and received a "Succes" message.
This is my gateway sketch.
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik EKblad * Contribution by a-lurker and Anticimex, * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> * Contribution by Tomas Hozza <thozza@gmail.com> * * * DESCRIPTION * The EthernetGateway sends data received from sensors to the ethernet link. * The gateway also accepts input on ethernet interface, which is then sent out to the radio network. * * The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program. * * LED purposes: * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. * */ // Enable debug prints to serial monitor #define MY_DEBUG #define MY_DEBUG_VERBOSE_SIGNING // Enable and select radio type attached #define MY_RADIO_RF24 // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif // Enable UDP communication //#define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,1,69 // If using static ip you can define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,1,1 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003// // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED // Set LOW transmit power level as default, if you have an amplified NRF-module and // power your radio separately with a good regulator you can turn up PA level. #define MY_RF24_PA_LEVEL RF24_PA_MAX // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 90 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds #define MY_WITH_LEDS_BLINKING_INVERSE // Flash leds on rx/tx/err // Uncomment to override default HW configurations #define MY_DEFAULT_ERR_LED_PIN 40 // Error led pin #define MY_DEFAULT_RX_LED_PIN 42 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 44 // Transmit led pin #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #define MY_SIGNING_SOFT #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 #define MY_SIGNING_SIMPLE_PASSWD "MyEmmaBemma2015" #define MY_SIGNING_WEAK_SECURITY #include <Ethernet.h> #include <MyConfig.h> #include <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { // Present locally attached sensors here } void loop() { // Send locally attached sensors data here }When I run the gateway I get the following message in the serial monitor
8732 TSF:MSG:BC 8734 TSF:MSG:FPAR REQ,ID=22 8736 TSF:CKU:OK,FCTRL 8738 TSF:MSG:GWL OK 9288 SGN:SKP:MSG CMD=3,TYPE=8 9293 TSF:MSG:SEND,0-0-22-22,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0 9300 TSF:MSG:READ,6-6-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 9306 TSF:MSG:PINGED,ID=6,HP=1 9308 SGN:SGN:NREQ=6 9312 TSF:MSG:SEND,0-0-6-6,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1 10048 TSF:MSG:READ,6-6-0,s=3,c=1,t=1,pt=7,l=5,sg=0:53.3 10778 TSF:MSG:READ,22-22-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 10783 TSF:MSG:PINGED,ID=22,HP=1 10786 SGN:SKP:MSG CMD=3,TYPE=25 10791 TSF:MSG:SEND,0-0-22-22,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1 10813 TSF:MSG:READ,22-22-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0101 10819 SGN:PRE:SGN REQ,FROM=22 10822 SGN:PRE:SGN NREQ,TO=22 10824 SGN:PRE:WHI NREQ,TO=22 10827 SGN:SKP:MSG CMD=3,TYPE=15 10834 TSF:MSG:SEND,0-0-22-22,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 10842 SGN:PRE:XMT,TO=22 10846 TSF:MSG:READ,22-22-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.0 10856 TSF:MSG:READ,22-22-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 12869 TSF:MSG:READ,22-22-0,s=255,c=3,t=11,pt=0,l=5,sg=0:Relay 12879 TSF:MSG:READ,22-22-0,s=255,c=3,t=12,pt=0,l=3,sg=0:2.0 12890 TSF:MSG:READ,22-22-0,s=1,c=0,t=3,pt=0,l=0,sg=0: 12901 TSF:MSG:READ,22-22-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 12906 SGN:SKP:MSG CMD=3,TYPE=16 12913 TSF:MSG:SEND,0-0-22-22,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK: 12919 SGN:SGN:NCE REQ,TO=22 12940 TSF:MSG:READ,22-22-0,s=255,c=3,t=17,pt=6,l=25,sg=0:<NONCE> 12946 SGN:NCE:FROM=22 12948 SGN:BND:NONCE=B8E06B367486872EC1CE2CADBF969CAAE127BADED76DF0095DAAAAAAAAAAAAAA 13035 SGN:BND:HMAC=0699DD1F9CE2830EC9F09D858D8AB9627DDA55AFBE587C1115A95C962E0AFFF1 13043 SGN:SGN:SGN 13048 TSF:MSG:SEND,0-0-22-22,s=255,c=3,t=27,pt=1,l=1,sg=1,ft=0,st=OK:1Here is my node sketch
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY **** Dave Version 1 */ // Enable debug prints to serial monitor #define MY_DEBUG #define MY_DEBUG_VERBOSE_SIGNING // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 // Enable repeater functionality for this node //#define MY_REPEATER_FEATURE // Inverses the behavior of leds #define MY_WITH_LEDS_BLINKING_INVERSE // Flash leds on rx/tx/err // Uncomment to override default HW configurations #define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin #define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED #define MY_NODE_ID 22 // Select soft/hardware signing method #define MY_SIGNING_SOFT //SOFTWARE BASED //#define MY_SIGNING_ATSHA204 //HARDWARE BASED #define MY_SIGNING_REQUEST_SIGNATURES //Hardware configuration for signing services #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 //#define MY_SIGNING_ATSHA204_PIN A3 #define MY_SIGNING_SIMPLE_PASSWD "MyEmmaBemma2015" #include <MyConfig.h> #include <MySensors.h> #include <SPI.h> #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 1// Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay", "2.0"); for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } } void loop() { } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_STATUS) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }And this is the serial monitor output.
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.0 16 MCO:BGN:INIT NODE,CP=RNNNAS--,VER=2.3.0 25 MCO:BGN:BFR 50 !SGN:PER:TAMPERED 86 SGN:INI:BND OK 87 TSM:INIT 88 TSF:WUR:MS=0 95 TSM:INIT:TSP OK 97 TSM:INIT:STATID=22 102 TSF:SID:OK,ID=22 104 TSM:FPAR 105 SGN:SGN:NREQ=255 142 TSF:MSG:SEND,22-22-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 954 TSF:MSG:READ,0-0-22,s=255,c=3,t=8,pt=1,l=1,sg=0:0 959 SGN:SKP:MSG CMD=3,TYPE=8 962 TSF:MSG:FPAR OK,ID=0,D=1 988 TSF:MSG:READ,6-6-22,s=255,c=3,t=8,pt=1,l=1,sg=0:1 992 SGN:SKP:MSG CMD=3,TYPE=8 1762 TSF:MSG:READ,1-1-22,s=255,c=3,t=8,pt=1,l=1,sg=0:1 1767 SGN:SKP:MSG CMD=3,TYPE=8 2150 TSM:FPAR:OK 2151 TSM:ID 2152 TSM:ID:OK 2154 TSM:UPL 2155 SGN:SGN:NREQ=0 2161 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2176 TSF:MSG:READ,0-0-22,s=255,c=3,t=25,pt=1,l=1,sg=0:1 2181 SGN:SKP:MSG CMD=3,TYPE=25 2184 TSF:MSG:PONG RECV,HP=1 2187 TSM:UPL:OK 2188 TSM:READY:ID=22,PAR=0,DIS=1 2191 SGN:PRE:SGN REQ 2193 SGN:PRE:WHI NREQ 2195 SGN:SGN:NREQ=0 2198 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0101 2205 SGN:PRE:XMT,TO=0 2207 SGN:PRE:WAIT GW 2217 TSF:MSG:READ,0-0-22,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 2223 SGN:SKP:MSG CMD=3,TYPE=15 2226 SGN:SGN:NREQ=0 2230 TSF:MSG:SEND,22-22-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0 2236 SGN:SGN:NREQ=0 2242 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 4248 SGN:SGN:NREQ=0 4253 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=11,pt=0,l=5,sg=0,ft=0,st=OK:Relay 4260 SGN:SGN:NREQ=0 4264 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:2.0 4271 SGN:SGN:NREQ=0 4277 TSF:MSG:SEND,22-22-0-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK: 4283 MCO:REG:REQ 4284 SGN:SGN:NREQ=0 4290 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 4297 TSF:MSG:READ,0-0-22,s=255,c=3,t=16,pt=0,l=0,sg=0: 4302 SGN:SKP:MSG CMD=3,TYPE=16 4320 SGN:SGN:NREQ=0 4327 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=OK:<NONCE> 4334 SGN:NCE:XMT,TO=22 4468 TSF:MSG:READ,0-0-22,s=255,c=3,t=27,pt=1,l=1,sg=1:1 4473 !SGN:VER:STATE 4475 !TSF:MSG:SIGN VERIFY FAIL 4477 MCO:BGN:STP 4480 MCO:BGN:INIT OK,TSP=1What am I missing here?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login