Codebender adoption
Had to make some chnages to make the code work on codebender (which seems to run a bit older version of AVR-LIBC. The compiler didn't like array constructor initializations either..
This commit is contained in:
@@ -94,8 +94,7 @@
|
|||||||
#define MY_RANDOMSEED_PIN 7 // A7 - Pin used for random generation (do not connect anything to this)
|
#define MY_RANDOMSEED_PIN 7 // A7 - Pin used for random generation (do not connect anything to this)
|
||||||
|
|
||||||
// Key to use for HMAC calculation in MySigningAtsha204Soft (32 bytes)
|
// Key to use for HMAC calculation in MySigningAtsha204Soft (32 bytes)
|
||||||
#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
|
#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
|
|||||||
@@ -37,13 +37,39 @@
|
|||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined __AVR_ATmega328P__
|
||||||
|
#ifndef sleep_bod_disable
|
||||||
|
#define sleep_bod_disable() \
|
||||||
|
do { \
|
||||||
|
unsigned char tempreg; \
|
||||||
|
__asm__ __volatile__("in %[tempreg], %[mcucr]" "\n\t" \
|
||||||
|
"ori %[tempreg], %[bods_bodse]" "\n\t" \
|
||||||
|
"out %[mcucr], %[tempreg]" "\n\t" \
|
||||||
|
"andi %[tempreg], %[not_bodse]" "\n\t" \
|
||||||
|
"out %[mcucr], %[tempreg]" \
|
||||||
|
: [tempreg] "=&d" (tempreg) \
|
||||||
|
: [mcucr] "I" _SFR_IO_ADDR(MCUCR), \
|
||||||
|
[bods_bodse] "i" (_BV(BODS) | _BV(BODSE)), \
|
||||||
|
[not_bodse] "i" (~_BV(BODSE))); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Define these as macros to save valuable space
|
// Define these as macros to save valuable space
|
||||||
#define hw_init() Serial.begin(BAUD_RATE)
|
#define hw_init() Serial.begin(BAUD_RATE)
|
||||||
#define hw_watchdogReset() wdt_reset()
|
#define hw_watchdogReset() wdt_reset()
|
||||||
#define hw_reboot() wdt_enable(WDTO_15MS); while (1)
|
#define hw_reboot() wdt_enable(WDTO_15MS); while (1)
|
||||||
#define hw_millis() millis()
|
#define hw_millis() millis()
|
||||||
#define hw_readConfig(__pos) (eeprom_read_byte((uint8_t*)(__pos)))
|
#define hw_readConfig(__pos) (eeprom_read_byte((uint8_t*)(__pos)))
|
||||||
#define hw_writeConfig(__pos, __value) (eeprom_update_byte((uint8_t*)(__pos), (__value)))
|
|
||||||
|
#ifndef eeprom_update_byte
|
||||||
|
#define hw_writeConfig(loc, val) if((uint8_t)(val) != eeprom_read_byte((uint8_t*)(loc))) { eeprom_write_byte((uint8_t*)(loc), (val)); }
|
||||||
|
#else
|
||||||
|
#define hw_writeConfig(__pos, __value) (eeprom_update_byte((uint8_t*)(__pos), (__value)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
#define hw_readConfigBlock(__buf, __pos, __length) (eeprom_read_block((__buf), (void*)(__pos), (__length)))
|
#define hw_readConfigBlock(__buf, __pos, __length) (eeprom_read_block((__buf), (void*)(__pos), (__length)))
|
||||||
#define hw_writeConfigBlock(__pos, __buf, __length) (eeprom_write_block((void*)(__pos), (void*)__buf, (__length)))
|
#define hw_writeConfigBlock(__pos, __buf, __length) (eeprom_write_block((void*)(__pos), (void*)__buf, (__length)))
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
|
|||||||
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)
|
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Initialize hmacKey from MyConfig.h (codebender didn't like static initialization in constructor)
|
||||||
|
uint8_t MySigningAtsha204Soft::hmacKey[32] = { MY_HMAC_KEY };
|
||||||
|
|
||||||
MySigningAtsha204Soft::MySigningAtsha204Soft(bool requestSignatures,
|
MySigningAtsha204Soft::MySigningAtsha204Soft(bool requestSignatures,
|
||||||
#ifdef MY_SECURE_NODE_WHITELISTING
|
#ifdef MY_SECURE_NODE_WHITELISTING
|
||||||
uint8_t nof_whitelist_entries, const whitelist_entry_t* the_whitelist,
|
uint8_t nof_whitelist_entries, const whitelist_entry_t* the_whitelist,
|
||||||
@@ -70,7 +73,6 @@ MySigningAtsha204Soft::MySigningAtsha204Soft(bool requestSignatures,
|
|||||||
:
|
:
|
||||||
MySigning(requestSignatures),
|
MySigning(requestSignatures),
|
||||||
rndPin(randomseedPin),
|
rndPin(randomseedPin),
|
||||||
hmacKey({MY_HMAC_KEY}),
|
|
||||||
#ifdef MY_SECURE_NODE_WHITELISTING
|
#ifdef MY_SECURE_NODE_WHITELISTING
|
||||||
whitlist_sz(nof_whitelist_entries),
|
whitlist_sz(nof_whitelist_entries),
|
||||||
whitelist(the_whitelist),
|
whitelist(the_whitelist),
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ private:
|
|||||||
bool verification_ongoing;
|
bool verification_ongoing;
|
||||||
uint8_t current_nonce[NONCE_NUMIN_SIZE_PASSTHROUGH];
|
uint8_t current_nonce[NONCE_NUMIN_SIZE_PASSTHROUGH];
|
||||||
uint8_t temp_message[32];
|
uint8_t temp_message[32];
|
||||||
uint8_t hmacKey[32];
|
static uint8_t hmacKey[32];
|
||||||
uint8_t rndPin;
|
uint8_t rndPin;
|
||||||
uint8_t hmac[32];
|
uint8_t hmac[32];
|
||||||
void calculateSignature(MyMessage &msg);
|
void calculateSignature(MyMessage &msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user