-
Notifications
You must be signed in to change notification settings - Fork 148
Fixed compile-time error for arduino IDE 1.0.5 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,14 @@ | |
| #include <avr/pgmspace.h> | ||
| #include "sha1.h" | ||
|
|
||
| #include "debugstuff.c" | ||
|
|
||
| #define SHA1_K0 0x5a827999 | ||
| #define SHA1_K20 0x6ed9eba1 | ||
| #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 | ||
|
|
@@ -27,6 +29,7 @@ uint32_t Sha1Class::rol32(uint32_t number, uint8_t bits) { | |
| } | ||
|
|
||
| void Sha1Class::hashBlock() { | ||
| // SHA1 only for now | ||
| uint8_t i; | ||
| uint32_t a,b,c,d,e,t; | ||
|
|
||
|
|
@@ -72,7 +75,7 @@ void Sha1Class::addUncounted(uint8_t data) { | |
| } | ||
| } | ||
|
|
||
| void Sha1Class::write(uint8_t data) { | ||
| size_t Sha1Class::write(uint8_t data) { | ||
| ++byteCount; | ||
| addUncounted(data); | ||
| } | ||
|
|
@@ -115,9 +118,12 @@ uint8_t* Sha1Class::result(void) { | |
| return state.b; | ||
| } | ||
|
|
||
|
|
||
| #define HMAC_IPAD 0x36 | ||
| #define HMAC_OPAD 0x5c | ||
|
|
||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need these enters |
||
| void Sha1Class::initHmac(const uint8_t* key, int keyLength) { | ||
| uint8_t i; | ||
| memset(keyBuffer,0,BLOCK_LENGTH); | ||
|
|
@@ -130,6 +136,7 @@ void Sha1Class::initHmac(const uint8_t* key, int keyLength) { | |
| // Block length keys are used as is | ||
| memcpy(keyBuffer,key,keyLength); | ||
| } | ||
| //for (i=0; i<BLOCK_LENGTH; i++) debugHH(keyBuffer[i]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this can be removed? |
||
| // Start inner hash | ||
| init(); | ||
| for (i=0; i<BLOCK_LENGTH; i++) { | ||
|
|
@@ -139,8 +146,10 @@ void Sha1Class::initHmac(const uint8_t* key, int keyLength) { | |
|
|
||
| uint8_t* Sha1Class::resultHmac(void) { | ||
| uint8_t i; | ||
| // Complete inner hash | ||
| // Complete inner hash | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad identation |
||
| memcpy(innerHash,result(),HASH_LENGTH); | ||
| // now innerHash[] contains H((K0 xor ipad)||text) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this can be removed? |
||
|
|
||
| // Calculate outer hash | ||
| init(); | ||
| for (i=0; i<BLOCK_LENGTH; i++) write(keyBuffer[i] ^ HMAC_OPAD); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ | |
| #include <avr/pgmspace.h> | ||
| #include "sha256.h" | ||
|
|
||
| uint32_t sha256K[] PROGMEM = { | ||
| //#include "debugstuff.c" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this can be removed? |
||
|
|
||
| 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 +18,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 | ||
|
|
@@ -38,6 +40,7 @@ uint32_t Sha256Class::ror32(uint32_t number, uint8_t bits) { | |
| } | ||
|
|
||
| void Sha256Class::hashBlock() { | ||
| // Sha256 only for now | ||
| uint8_t i; | ||
| uint32_t a,b,c,d,e,f,g,h,t1,t2; | ||
|
|
||
|
|
@@ -87,7 +90,7 @@ void Sha256Class::addUncounted(uint8_t data) { | |
| } | ||
| } | ||
|
|
||
| void Sha256Class::write(uint8_t data) { | ||
| size_t Sha256Class::write(uint8_t data) { | ||
| ++byteCount; | ||
| addUncounted(data); | ||
| } | ||
|
|
@@ -130,6 +133,7 @@ uint8_t* Sha256Class::result(void) { | |
| return state.b; | ||
| } | ||
|
|
||
|
|
||
| #define HMAC_IPAD 0x36 | ||
| #define HMAC_OPAD 0x5c | ||
|
|
||
|
|
@@ -148,6 +152,7 @@ void Sha256Class::initHmac(const uint8_t* key, int keyLength) { | |
| // Block length keys are used as is | ||
| memcpy(keyBuffer,key,keyLength); | ||
| } | ||
| //for (i=0; i<BLOCK_LENGTH; i++) debugHH(keyBuffer[i]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this can be removed? |
||
| // Start inner hash | ||
| init(); | ||
| for (i=0; i<BLOCK_LENGTH; i++) { | ||
|
|
@@ -157,8 +162,10 @@ void Sha256Class::initHmac(const uint8_t* key, int keyLength) { | |
|
|
||
| uint8_t* Sha256Class::resultHmac(void) { | ||
| uint8_t i; | ||
| // Complete inner hash | ||
| // Complete inner hash | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad identation |
||
| memcpy(innerHash,result(),HASH_LENGTH); | ||
| // now innerHash[] contains H((K0 xor ipad)||text) | ||
|
|
||
| // Calculate outer hash | ||
| init(); | ||
| for (i=0; i<BLOCK_LENGTH; i++) write(keyBuffer[i] ^ HMAC_OPAD); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?