Removed signing identifier from nonces

It serves no practical use to have signing identifier in nonces
as nonces are architecture independent.

Fixes #318
This commit is contained in:
Patrick Fallberg
2016-01-12 08:43:11 +01:00
parent 58dbc2ad27
commit 3bf9184670
3 changed files with 8 additions and 25 deletions
+6 -7
View File
@@ -59,14 +59,14 @@ enum { SIGN_WAITING_FOR_NONCE = 0, SIGN_OK = 1 };
#if defined(MY_SIGNING_SOFT)
extern bool signerAtsha204SoftCheckTimer(void);
extern bool signerAtsha204SoftGetNonce(MyMessage &msg);
extern bool signerAtsha204SoftPutNonce(MyMessage &msg);
extern void signerAtsha204SoftPutNonce(MyMessage &msg);
extern bool signerAtsha204SoftVerifyMsg(MyMessage &msg);
extern bool signerAtsha204SoftSignMsg(MyMessage &msg);
#endif
#if defined(MY_SIGNING_ATSHA204)
extern bool signerAtsha204CheckTimer(void);
extern bool signerAtsha204GetNonce(MyMessage &msg);
extern bool signerAtsha204PutNonce(MyMessage &msg);
extern void signerAtsha204PutNonce(MyMessage &msg);
extern bool signerAtsha204VerifyMsg(MyMessage &msg);
extern bool signerAtsha204SignMsg(MyMessage &msg);
#endif
@@ -240,17 +240,16 @@ bool signerProcessInternal(MyMessage &msg) {
return true; // No need to further process I_NONCE_RESPONSE
}
#if defined(MY_SIGNING_SOFT)
if (!signerAtsha204SoftPutNonce(msg)) {
signerAtsha204SoftPutNonce(msg);
#endif
#if defined(MY_SIGNING_ATSHA204)
if (!signerAtsha204PutNonce(msg)) {
signerAtsha204PutNonce(msg);
#endif
SIGN_DEBUG(PSTR("Failed to store nonce to signing backend!\n"));
#if defined(MY_SIGNING_SOFT)
} else if (!signerAtsha204SoftSignMsg(_msgSign)) {
if (!signerAtsha204SoftSignMsg(_msgSign)) {
#endif
#if defined(MY_SIGNING_ATSHA204)
} else if (!signerAtsha204SignMsg(_msgSign)) {
if (!signerAtsha204SignMsg(_msgSign)) {
#endif
SIGN_DEBUG(PSTR("Failed to sign message!\n"));
} else {
@@ -117,9 +117,6 @@ bool signerAtsha204GetNonce(MyMessage &msg) {
// We set the part of the 32-byte nonce that does not fit into a message to 0xAA
memset(&_signing_current_nonce[MAX_PAYLOAD], 0xAA, sizeof(_signing_current_nonce)-MAX_PAYLOAD);
// Replace the first byte in the nonce with our signing identifier
_signing_current_nonce[0] = SIGNING_IDENTIFIER;
// Transfer the first part of the nonce to the message
msg.set(_signing_current_nonce, MAX_PAYLOAD);
_signing_verification_ongoing = true;
@@ -131,17 +128,12 @@ bool signerAtsha204GetNonce(MyMessage &msg) {
return true;
}
bool signerAtsha204PutNonce(MyMessage &msg) {
void signerAtsha204PutNonce(MyMessage &msg) {
DEBUG_SIGNING_PRINTBUF(F("Signing backend: ATSHA204"), NULL, 0);
if (((uint8_t*)msg.getCustom())[0] != SIGNING_IDENTIFIER) {
DEBUG_SIGNING_PRINTBUF(F("Incorrect signing identifier"), NULL, 0);
return false;
}
memcpy(_signing_current_nonce, (uint8_t*)msg.getCustom(), MAX_PAYLOAD);
// We set the part of the 32-byte nonce that does not fit into a message to 0xAA
memset(&_signing_current_nonce[MAX_PAYLOAD], 0xAA, sizeof(_signing_current_nonce)-MAX_PAYLOAD);
return true;
}
bool signerAtsha204SignMsg(MyMessage &msg) {
@@ -117,9 +117,6 @@ bool signerAtsha204SoftGetNonce(MyMessage &msg) {
// We set the part of the 32-byte nonce that does not fit into a message to 0xAA
memset(&_signing_current_nonce[MAX_PAYLOAD], 0xAA, sizeof(_signing_current_nonce)-MAX_PAYLOAD);
// Replace the first byte in the nonce with our signing identifier
_signing_current_nonce[0] = SIGNING_IDENTIFIER;
// Transfer the first part of the nonce to the message
msg.set(_signing_current_nonce, MAX_PAYLOAD);
_signing_verification_ongoing = true;
@@ -131,17 +128,12 @@ bool signerAtsha204SoftGetNonce(MyMessage &msg) {
return true;
}
bool signerAtsha204SoftPutNonce(MyMessage &msg) {
void signerAtsha204SoftPutNonce(MyMessage &msg) {
DEBUG_SIGNING_PRINTBUF(F("Signing backend: ATSHA204Soft"), NULL, 0);
if (((uint8_t*)msg.getCustom())[0] != SIGNING_IDENTIFIER) {
DEBUG_SIGNING_PRINTBUF(F("Incorrect signing identifier"), NULL, 0);
return false;
}
memcpy(_signing_current_nonce, (uint8_t*)msg.getCustom(), MAX_PAYLOAD);
// We set the part of the 32-byte nonce that does not fit into a message to 0xAA
memset(&_signing_current_nonce[MAX_PAYLOAD], 0xAA, sizeof(_signing_current_nonce)-MAX_PAYLOAD);
return true;
}
bool signerAtsha204SoftSignMsg(MyMessage &msg) {