Commit Graph
653 Commits
Author SHA1 Message Date
Patrick Fallberg a1024cd2cd Added support to read the serial number from ATSHA204
The serial number can be used for whitelisting of nodes
that are considered "trusted".
2015-03-16 20:14:25 +01:00
Patrick Fallberg 4c4c9a8b39 Added SHA command to ATSHA204 backend driver
The SHA command is available in ATSHA204A variants of the chip
and can be used to calculate SHA256 digests of arbitrary data.

This enables us to strengthen the quality of the signatures by
salting signatures with node-specific data and improving the
quality of random data.
2015-03-16 20:14:22 +01:00
Henrik Ekblad cb5e3172bd Fixed compile problem 2015-03-16 19:39:06 +01:00
Henrik Ekblad 73024ea4c9 Weird compile error for Patrick 2015-03-16 10:43:09 +01:00
Henrik Ekblad fb6540f17a Merge pull request #88 from mapnull/dev-mqttgw_digitalIO
add DigitalIO.h to MQTTGateway
2015-03-13 20:30:23 +01:00
Marcelo Aquino 5ae55e5b8a add DigitalIO.h to MQTTGateway 2015-03-13 16:09:09 -03:00
Henrik Ekblad d88e917544 Simplify thinga a bit 2015-03-13 15:39:05 +01:00
Henrik Ekblad c1d5513578 Remove LowPower dependency 2015-03-12 23:59:36 +01:00
Henrik Ekblad c5760f72c6 Remove EEPROM buffer for routing information 2015-03-12 23:58:38 +01:00
Henrik Ekblad 9e85fac745 Separate the HW specifics from the MySensor library 2015-03-12 22:59:51 +01:00
Henrik Ekblad 6d0ae813c4 Rename MySigningDriver* to MySigning* 2015-03-10 00:07:57 +01:00
Henrik Ekblad 7a1cdd06e1 Rename RFDriver to Transport 2015-03-09 23:45:05 +01:00
Henrik Ekblad 7e6aa8bda8 Add the default constructors to gateway sketches 2015-03-09 22:58:05 +01:00
Henrik Ekblad ec5e64b6bf Merge pull request #85 from fallberg/personalizer
SHA204 personalizer updated to handle HMAC key better
2015-03-09 00:44:42 +01:00
Patrick Fallberg a21715d415 SHA204 personalizer updated to handle HMAC key better
HMAC key is now configured and printed exactly as it is set
in MyConfig.h. This makes it easier to move the key around.
2015-03-09 00:20:17 +01:00
Henrik Ekblad 5b034cf064 Merge pull request #84 from fallberg/gw_sign
Support for gateways to request signed messages
2015-03-08 12:01:39 +01:00
Patrick Fallberg 79be69b08d Support for gateways to request signed messages
Various fixes and tweaks to permit a gateway to request
signatures from nodes.
The following messages will not be signed (nor verified):
* All signing-related handshake messages
* All ID-related handshake messages
* All ACKs

An important change is that the polarity for the signing request
flags stored in EEPROM has changed. '0' now means signing required.
This ensures that if the "ClearEepromConfig" sketch is executed,
signing requests will be turned off by default.
As a consequence, it is recommended to clear EEPROM if signing will
be used to ensure all nodes default to a non-signing state.
2015-03-08 11:20:33 +01:00
Henrik Ekblad 89076d58d1 Fix spelling error. 2015-03-04 20:17:53 +01:00
Henrik Ekblad 7d67ad5c82 Add new sensor type S_MULTIMETER
To be used with V_CURRENT, V_VOLTAGE, V_IMPEDANCE
2015-03-04 19:24:13 +01:00
Henrik Ekblad 5aebe80711 Cleanup driver initialization 2015-03-03 00:24:13 +01:00
Henrik Ekblad afce932cff Remove the last "new" to reduce size 2015-02-27 22:17:05 +01:00
Henrik Ekblad ee6e34b59a Remove global initialization of sha256 2015-02-27 00:25:08 +01:00
Henrik Ekblad bf8102ecad For discussion 2015-02-26 23:53:37 +01:00
Henrik Ekblad 23a8a48f8e Rename "Dummy" signing driver to "None" 2015-02-25 23:18:26 +01:00
Henrik Ekblad a4f70342a2 Merge pull request #79 from fallberg/development
Fixed bug that caused the wrong message to be signed
2015-02-25 22:53:31 +01:00
Patrick Fallberg 961366313b Fixed bug that caused the wrong message to be signed
process() altered the message buffer pending signing when
called in sign() causing the wrong message to be sent to the
signing backend. This is resolved by copying the original
message before processing incoming messages to make sure
the original message is kept. After it is successfully signed,
it is copied back to its original location again.
Also, the old 'ack' message buffer is renamed to tmpMsg to
indicate its use as a temporary message buffer for various
purposes.
2015-02-25 22:50:51 +01:00
Henrik Ekblad 1cd84bf0c8 Merge pull request #75 from mapnull/dev-hotfix-begin_requestNodeId
check valid parentNodeId before requestNodeId
2015-02-22 23:40:55 +01:00
Henrik Ekblad 1979cb6f32 Merge pull request #77 from fallberg/sign-hotfix
Bugfix for gateway signing requirements
2015-02-22 23:40:27 +01:00
Patrick Fallberg 2ab9822172 Bugfix for gateway signing requirements
Gateway now only indicate signing requirements for sensors
that in turn have indicated signing requirements.
2015-02-22 23:32:45 +01:00
Henrik Ekblad fb1c542862 Move SHA204 personalizer sketch to MySensors examples
Fix include errors.
2015-02-22 23:22:06 +01:00
Marcelo Aquino 2d8fddcb05 check valid parentNodeId before requestNodeId 2015-02-22 10:41:29 -03:00
Henrik Ekblad e8bb9623e0 Merge pull request #74 from mapnull/dev-feature-parser_serial
add parser class for serial and ethernet gateways
2015-02-20 08:53:36 +01:00
Marcelo Aquino c358d8705a add parser class for serial and ethernet gateways 2015-02-19 21:39:46 -02:00
Henrik Ekblad 70b476ede4 Bugfix: setVersion missing in sendWrite 2015-02-19 13:47:45 +01:00
Henrik Ekblad 8550162235 Slim down dummy signing driver. 2015-02-19 11:22:36 +01:00
Henrik Ekblad 8274188b43 Use eeprom_update_* when writing to EEPROM
Saves a few bytes and minimizes the number of write cycles.
2015-02-19 09:15:50 +01:00
Henrik Ekblad e25f4974b2 Save some bytes by removing new when initalizing drivers 2015-02-19 09:09:38 +01:00
Henrik Ekblad 56a16671e5 Added const for PROGMEM declarations (Arduino IDE 1.5.8 compability)
Merge branch 'development' of https://github.com/mysensors/Arduino.git
into development

Conflicts:
	libraries/MySensors/MySensor.cpp
2015-02-18 23:52:33 +01:00
Henrik Ekblad 729cf8da5d Bugifx: GW should not send presentation 2015-02-18 23:40:58 +01:00
Henrik Ekblad 8ed85b1514 Merge pull request #72 from mapnull/dev-hotfix
fix ifdef for MYSENSORS_ETHERNET_MQTT_GATEWAY
2015-02-18 14:40:17 +01:00
Marcelo Aquino d7474a7b8d fix ifdef for MYSENSORS_ETHERNET_MQTT_GATEWAY 2015-02-18 11:15:54 -02:00
Henrik Ekblad 11058f7b4a Merge pull request #71 from fallberg/sign_dev
Signing support for MySensors
2015-02-18 09:26:56 +01:00
Patrick Fallberg cfc8d9f28a Added example sketch for a secure actuator
The sketch closely resembles the RelayActuator example.
The difference is that this sketch require gateway to sign
all messages addressed to the actuator.
2015-02-17 23:25:50 +01:00
Patrick Fallberg 644eac1712 Signing support implemented in the MySensors library
The dummy signing driver backend is used. But with this commit all
framework logic for managing signed messages in the MySensors
ecosystem is implemented and enables more sophisticated signing
backends to be added later on.

For a sensor (or gateway) that require a gateway to send signed
messages to it, add 'true' as the fifth argument to 'begin'.
The gateway will automatically inform a node of it's signing
requirements as soon as it receivs the nodes signing preference.
It is important to understand that if the gateway require
signing, it will in this implementation only require signing from
nodes that require signing by the gateway.

If the sensor requires signing from another node on the network
which it communicates directly with, it needs to send 'true' in
an internal message of type I_REQUEST_SIGNING.
2015-02-17 23:25:41 +01:00
Patrick Fallberg 911ae9c9d9 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.
2015-02-17 23:25:33 +01:00
Patrick Fallberg ce290e280e ATSHA204 signing backend
Default SDA pin is A3 for single wire communication.
The pin is selected in MyConfig.h.
I2C variant of ATSHA204 is not supported.

Messages are signed using HMAC-SHA256 where some parts of the
message digest are ATSHA204 specific.
2015-02-17 23:25:24 +01:00
Patrick Fallberg fca0d4b544 Dummy signing driver backend
The dummy signing driver implements the most rudimentary form of
signing. No pre-shared key is used, nonce is simply incremeted
each turn and signature is only calculated on the fist byte using
data XOR nonce.
This driver is intended for library debugging and sensor network
integrity verification (signed messages will force the radio to
transmit all 32 bytes of data).
It does check SIGNING_IDENTIFIER byte to avoid illegal mixing of
signing backends in the network (as seen by this node) and it does
verify proper execution order on the API.
The dummy driver rejects all other signing backend protocols.

Signing backend is selected in MyConfig.h
2015-02-17 23:25:16 +01:00
Patrick Fallberg c2a75d064e Signing driver framework
The signing driver framework resembles the radio driver framework
in the sense that it relies on MyConfig.h for driver specific
settings. This allows the constructor to be clean and the API less
likely to need change.

The API is designed with function pairs for sender and receiver of
a signed message.
The sender of a signed message uses putNonce() and signMsg()
and the receiver of a signed message uses getNonce() and
verifyMsg().
In addition, receiver is expected to call checkTimer() at regular
intervals to make sure the message session does not time out.

The program flow is that the sender transmit, after determining
that the message needs signing, a request to the receiver for a
nonce (I_GET_NONCE). The receiver calls getNonce() to obtain a
nonce and transmits the nonce back to the sender
(I_GET_NONCE_RESPONSE).
The sender stores the received nonce in the driver with putNonce()
and then calls signMsg() to sign the message to be transmitted.
The receiver then calls verifyMsg() to authenticate the signed
message using the nonce transmitted earlier.

The flow is described below:
---------------- --------            ---------- ------------------
|senders driver| |sender|            |receiver| |receivers driver|
---------------- --------            ---------- ------------------
        |            |    I_GET_NONCE     |  getNonce()  |
        |            |------------------->|------------->|
        |            |                    |              |
        | setNonce() |I_GET_NONCE_RESPONSE|              |
        |<-----------|<-------------------|<-------------|
        | signMsg()  |                    |              |
        |<-----------|                    | verifyMsg()  |
        |----------->|------------------->|------------->|
        |            |                    | OK / not OK  |
        |            |                    |<-------------|

It is expected that all signing schemes is built upon this
principle.
2015-02-17 23:25:08 +01:00
Patrick Fallberg 9f337e3cae Message header updates for signing support
One bit in the protocol version field is converted to a sign
indicator. '1' means the message carries a signature in the
unused part of the payload data buffer.

Three new internal message types have been defined:

 * I_REQUEST_SIGNING    carries a boolean and is used to exchange
                        signing requirement information between
                        nodes.
                        If the I_REQUEST_SIGNING carries 'true'
                        the receiver is informed that the sender
                        require properly signed messages in order
                        to be able to accept the messages.
 * I_GET_NONCE          is passed from sender to a receiver that
                        require signing tellig it to submit a
                        cryptographic 'nonce' that the sender needs
                        in order to be able to sign the message it
                        intend to send. The I_GET_NONCE carries no
                        payload.
 * I_GET_NONCE_RESPONSE is sent by the receiver of a signed
                        message in response to I_GET_NONCE.
                        The first byte of the payload is a signing
                        identifier informing the sender of the
                        signed message about the type of signature
                        the receiver is expecting.
2015-02-17 23:25:00 +01:00
Henrik Ekblad 8b8f623627 Merge branch 'development' of https://github.com/mysensors/Arduino.git into development 2015-02-17 22:29:01 +01:00