From 555de052930d207aa874a5d3cd49eb226e5b0093 Mon Sep 17 00:00:00 2001 From: toruuetani Date: Fri, 27 Feb 2015 15:33:24 +0900 Subject: [PATCH 1/3] Fix compile error at Arduino IDE 1.6.0 From f2145b6493c781f725cf59b21f3a30ec40e6764a Mon Sep 17 00:00:00 2001 From: toruuetani Date: Fri, 27 Feb 2015 15:41:24 +0900 Subject: [PATCH 2/3] Fix compile error by conflict type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See [Arduino 1.0 support (untested) by jkiv · Pull Request #1 · Cathedrow/Cryptosuite](https://github.com/Cathedrow/Cryptosuite/pull/1) --- Sha/sha1.cpp | 14 +++++++++++--- Sha/sha1.h | 6 +++++- Sha/sha256.cpp | 16 ++++++++++++---- Sha/sha256.h | 4 ++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Sha/sha1.cpp b/Sha/sha1.cpp index 9ff3a1c..7e215f2 100644 --- a/Sha/sha1.cpp +++ b/Sha/sha1.cpp @@ -72,9 +72,17 @@ void Sha1Class::addUncounted(uint8_t data) { } } -void Sha1Class::write(uint8_t data) { +#if defined(ARDUINO) && ARDUINO >= 100 +size_t +#else +void +#endif +Sha1Class::write(uint8_t data) { ++byteCount; addUncounted(data); +#if defined(ARDUINO) && ARDUINO >= 100 + return 1; +#endif } void Sha1Class::pad() { @@ -99,7 +107,7 @@ void Sha1Class::pad() { uint8_t* Sha1Class::result(void) { // Pad to complete the last block pad(); - + // Swap byte order back for (int i=0; i<5; i++) { uint32_t a,b; @@ -110,7 +118,7 @@ uint8_t* Sha1Class::result(void) { b|=a>>24; state.w[i]=b; } - + // Return pointer to hash (20 characters) return state.b; } diff --git a/Sha/sha1.h b/Sha/sha1.h index 9975660..71c11cd 100644 --- a/Sha/sha1.h +++ b/Sha/sha1.h @@ -23,7 +23,11 @@ class Sha1Class : public Print void initHmac(const uint8_t* secret, int secretLength); uint8_t* result(void); uint8_t* resultHmac(void); +#if defined(ARDUINO) && ARDUINO >= 100 + virtual size_t write(uint8_t); +#else virtual void write(uint8_t); +#endif using Print::write; private: void pad(); @@ -36,7 +40,7 @@ class Sha1Class : public Print uint32_t byteCount; uint8_t keyBuffer[BLOCK_LENGTH]; uint8_t innerHash[HASH_LENGTH]; - + }; extern Sha1Class Sha1; diff --git a/Sha/sha256.cpp b/Sha/sha256.cpp index e479d86..7ba56b9 100644 --- a/Sha/sha256.cpp +++ b/Sha/sha256.cpp @@ -49,7 +49,7 @@ void Sha256Class::hashBlock() { f=state.w[5]; g=state.w[6]; h=state.w[7]; - + for (i=0; i<64; i++) { if (i>=16) { t1 = buffer.w[i&15] + buffer.w[(i-7)&15]; @@ -87,9 +87,17 @@ void Sha256Class::addUncounted(uint8_t data) { } } -void Sha256Class::write(uint8_t data) { +#if defined(ARDUINO) && ARDUINO >= 100 +size_t +#else +void +#endif +Sha256Class::write(uint8_t data) { ++byteCount; addUncounted(data); +#if defined(ARDUINO) && ARDUINO >= 100 + return 1; +#endif } void Sha256Class::pad() { @@ -114,7 +122,7 @@ void Sha256Class::pad() { uint8_t* Sha256Class::result(void) { // Pad to complete the last block pad(); - + // Swap byte order back for (int i=0; i<8; i++) { uint32_t a,b; @@ -125,7 +133,7 @@ uint8_t* Sha256Class::result(void) { b|=a>>24; state.w[i]=b; } - + // Return pointer to hash (20 characters) return state.b; } diff --git a/Sha/sha256.h b/Sha/sha256.h index b4b5fd4..b9f4d08 100644 --- a/Sha/sha256.h +++ b/Sha/sha256.h @@ -23,7 +23,11 @@ class Sha256Class : public Print void initHmac(const uint8_t* secret, int secretLength); uint8_t* result(void); uint8_t* resultHmac(void); +#if defined(ARDUINO) && ARDUINO >= 100 + virtual size_t write(uint8_t); +#else virtual void write(uint8_t); +#endif using Print::write; private: void pad(); From 41e84a452ae25ed90def2de8cfa2bec83ae2f917 Mon Sep 17 00:00:00 2001 From: toruuetani Date: Fri, 27 Feb 2015 15:48:23 +0900 Subject: [PATCH 3/3] Fix compile error by not const. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See [Fixed compile-time error for arduino IDE 1.0.5 by C5E3B7BD · Pull Request #3 · Cathedrow/Cryptosuite](https://github.com/Cathedrow/Cryptosuite/pull/3) --- Sha/sha1.cpp | 2 +- Sha/sha256.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sha/sha1.cpp b/Sha/sha1.cpp index 7e215f2..5eb6095 100644 --- a/Sha/sha1.cpp +++ b/Sha/sha1.cpp @@ -8,7 +8,7 @@ #define SHA1_K40 0x8f1bbcdc #define SHA1_K60 0xca62c1d6 -uint8_t sha1InitState[] PROGMEM = { +const uint8_t sha1InitState[] PROGMEM = { 0x01,0x23,0x45,0x67, // H0 0x89,0xab,0xcd,0xef, // H1 0xfe,0xdc,0xba,0x98, // H2 diff --git a/Sha/sha256.cpp b/Sha/sha256.cpp index 7ba56b9..a394a75 100644 --- a/Sha/sha256.cpp +++ b/Sha/sha256.cpp @@ -3,7 +3,7 @@ #include #include "sha256.h" -uint32_t sha256K[] PROGMEM = { +const uint32_t sha256K[] PROGMEM = { 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, @@ -16,7 +16,7 @@ uint32_t sha256K[] PROGMEM = { #define BUFFER_SIZE 64 -uint8_t sha256InitState[] PROGMEM = { +const uint8_t sha256InitState[] PROGMEM = { 0x67,0xe6,0x09,0x6a, // H0 0x85,0xae,0x67,0xbb, // H1 0x72,0xf3,0x6e,0x3c, // H2