Merge pull request #630 from fallberg/signing_fixes

Make stability improvements in message signing
This commit is contained in:
Henrik Ekblad
2016-10-31 20:02:15 +01:00
committed by GitHub
+12 -12
View File
@@ -148,33 +148,36 @@ void signerPresentation(MyMessage &msg, uint8_t destination) {
#endif
if (!_sendRoute(msg)) {
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!"));
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!\n"));
}
#if defined(MY_SIGNING_FEATURE)
// If we do support signing, wait for the gateway to tell us how it prefer us to transmit our messages
if (destination == GATEWAY_ADDRESS) {
SIGN_DEBUG(PSTR("Waiting for GW to send signing preferences...\n"));
wait(2000, C_INTERNAL, I_SIGNING_PRESENTATION);
}
#endif
}
bool signerProcessInternal(MyMessage &msg) {
uint8_t sender = msg.sender;
(void)sender;
if (mGetCommand(msg) == C_INTERNAL) {
#if !defined(MY_SIGNING_FEATURE) && defined(MY_GATEWAY_FEATURE)
#if !defined(MY_SIGNING_FEATURE)
if (msg.type == I_SIGNING_PRESENTATION) {
#if defined(MY_GATEWAY_FEATURE)
// If we act as gateway and do not have the signing feature and receive a signing request we still
// need to do make sure the requester does not believe the gateway still require signatures
if (msg.type == I_SIGNING_PRESENTATION) {
prepareSigningPresentation(msg, sender);
SIGN_DEBUG(PSTR("Informing node %d that we do not require signatures because we do not support it\n"),
sender);
if (!_sendRoute(msg)) {
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!"));
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!\n"));
}
return true; // No need to further process I_SIGNING_PRESENTATION in this case
#else
// If we act as a node and do not have the signing feature then we just silently drop any signing
// presentation messages received
SIGN_DEBUG(PSTR("Received signing presentation, but signing is not supported (message ignored)\n"));
return true;
#endif
}
#elif defined(MY_SIGNING_FEATURE)
if (msg.type == I_NONCE_REQUEST) {
@@ -205,7 +208,6 @@ bool signerProcessInternal(MyMessage &msg) {
SIGN_DEBUG(PSTR("Unsupported signing presentation version (%d)!\n"), msg.data[0]);
return true; // Just drop this presentation message
}
// We only handle version 1 here...
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_SIGNATURES) {
// We received an indicator that the sender require us to sign all messages we send to it
@@ -216,7 +218,6 @@ bool signerProcessInternal(MyMessage &msg) {
SIGN_DEBUG(PSTR("Mark node %d as one that do not require signed messages\n"), msg.sender);
CLEAR_SIGN(msg.sender);
}
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_WHITELISTING) {
// We received an indicator that the sender require us to salt signatures with serial
SIGN_DEBUG(PSTR("Mark node %d as one that require whitelisting\n"), msg.sender);
@@ -266,7 +267,7 @@ bool signerProcessInternal(MyMessage &msg) {
SIGN_DEBUG(PSTR("Informing node %d that we do not require whitelisting\n"), sender);
}
if (!_sendRoute(msg)) {
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!"));
SIGN_DEBUG(PSTR("Failed to transmit signing presentation!\n"));
}
#endif // MY_GATEWAY_FEATURE
return true; // No need to further process I_SIGNING_PRESENTATION
@@ -299,7 +300,6 @@ bool signerProcessInternal(MyMessage &msg) {
return true; // No need to further process I_NONCE_RESPONSE
}
#endif // MY_SIGNING_FEATURE
}
return false;
}