Rename "Dummy" signing driver to "None"

This commit is contained in:
Henrik Ekblad
2015-02-25 23:18:26 +01:00
parent a4f70342a2
commit 23a8a48f8e
3 changed files with 28 additions and 28 deletions
+4 -4
View File
@@ -16,7 +16,7 @@
//#define MYSENSORS_RF_RF69
// Choose signing backend by enabling one of the following
#define MYSENSORS_SIGNING_DUMMY
#define MYSENSORS_SIGNING_NONE
//#define MYSENSORS_SIGNING_ATSHA204
//#define MYSENSORS_SIGNING_ATSHA204SOFT
@@ -40,10 +40,10 @@ typedef class MyRFDriverRF69 MyRFDriverClass;
typedef class MyParserSerial MyParserClass;
#endif
#ifdef MYSENSORS_SIGNING_DUMMY
#include "MySigningDriverDummy.h"
#ifdef MYSENSORS_SIGNING_NONE
#include "MySigningDriverNone.h"
#define SIGNING_IDENTIFIER (0) // Reserved for dummy implementation, will not work with other backends
typedef class MySigningDriverDummy MySigningDriverClass;
typedef class MySigningDriverNone MySigningDriverClass;
#endif
#ifdef MYSENSORS_SIGNING_ATSHA204
@@ -1,23 +1,23 @@
/*
Dummy signing backend. Does not provide any security measures.
Disabled signing backend. Does not provide any security measures.
Created by Patrick "Anticimex" Fallberg <patrick@fallberg.net>
*/
#include "MySigningDriver.h"
#include "MySigningDriverDummy.h"
#include "MySigningDriverNone.h"
#ifdef MYSENSORS_SIGNING_DUMMY
#ifdef MYSENSORS_SIGNING_NONE
// Uncomment this to get some useful serial debug info (Serial.print and Serial.println expected)
//#define DEBUG_DUMMY_SIGNING
//#define DEBUG_NONE_SIGNING
#ifdef DEBUG_DUMMY_SIGNING
#define DEBUG_DUMMY_PRINTLN(args) Serial.println(args)
#ifdef DEBUG_NONE_SIGNING
#define DEBUG_NONE_PRINTLN(args) Serial.println(args)
#else
#define DEBUG_DUMMY_PRINTLN(args)
#define DEBUG_NONE_PRINTLN(args)
#endif
#ifdef DEBUG_DUMMY_SIGNING
static void DEBUG_DUMMY_PRINTBUF(char* str, uint8_t* buf, uint8_t sz)
#ifdef DEBUG_NONE_SIGNING
static void DEBUG_NONE_PRINTBUF(char* str, uint8_t* buf, uint8_t sz)
{
int i;
Serial.println(str);
@@ -32,28 +32,28 @@ static void DEBUG_DUMMY_PRINTBUF(char* str, uint8_t* buf, uint8_t sz)
Serial.println();
}
#else
#define DEBUG_DUMMY_PRINTBUF(str, buf, sz)
#define DEBUG_NONE_PRINTBUF(str, buf, sz)
#endif
MySigningDriverDummy::MySigningDriverDummy() : MySigningDriver() {
MySigningDriverNone::MySigningDriverNone() : MySigningDriver() {
}
bool MySigningDriverDummy::getNonce(MyMessage &msg) {
bool MySigningDriverNone::getNonce(MyMessage &msg) {
return true;
}
bool MySigningDriverDummy::checkTimer() {
bool MySigningDriverNone::checkTimer() {
return true;
}
bool MySigningDriverDummy::putNonce(MyMessage &msg) {
bool MySigningDriverNone::putNonce(MyMessage &msg) {
return true;
}
bool MySigningDriverDummy::signMsg(MyMessage &msg) {
bool MySigningDriverNone::signMsg(MyMessage &msg) {
// If we cannot fit any signature in the message, refuse to sign it
if (mGetLength(msg) > MAX_PAYLOAD-2) {
DEBUG_DUMMY_PRINTLN("Cannot fit any signature to this message");
DEBUG_NONE_PRINTLN("Cannot fit any signature to this message");
return false;
}
mSetSigned(msg, 1); // make sure signing flag is set before signature is calculated
@@ -61,7 +61,7 @@ bool MySigningDriverDummy::signMsg(MyMessage &msg) {
return true;
}
bool MySigningDriverDummy::verifyMsg(MyMessage &msg) {
bool MySigningDriverNone::verifyMsg(MyMessage &msg) {
if (msg.data[mGetLength(msg)] != SIGNING_IDENTIFIER)
return false;
else
@@ -1,24 +1,24 @@
/*
Dummy signing backend. Does not provide any security measures.
Disabled signing backend. Does not provide any security measures.
Created by Patrick "Anticimex" Fallberg <patrick@fallberg.net>
*/
#ifndef MySigningDriverDummy_h
#define MySigningDriverDummy_h
#ifndef MySigningDriverNone_h
#define MySigningDriverNone_h
#include "MyConfig.h"
#include "MySigningDriver.h"
#include <stdint.h>
// The dummy signing driver that can be used for nodes
// The "none" signing driver that can be used for nodes
// not requiring signing
// It does check SIGNING_IDENTIFIER byte to avoid illegal mixing of signing back-ends in
// the network (as seen by this node) and it does verify proper execution order on the API.
// The dummy driver rejects all other back-ends.
class MySigningDriverDummy : public MySigningDriver
// The "none" driver rejects all other back-ends.
class MySigningDriverNone : public MySigningDriver
{
public:
MySigningDriverDummy();
MySigningDriverNone();
bool getNonce(MyMessage &msg);
bool checkTimer(void);
bool putNonce(MyMessage &msg);