I installed this SHA library: GitHub - Cathedrow/Cryptosuite: Cryptographic suite for Arduino (SHA, HMAC-SHA). I want to implement HMAC256. I copied the example given in their webpage. I am still new and want to test and try. I wrote this code in Arduino IDE.
#include "sha256.h"
void setup() {
// put your setup code here, to run once:
uint8_t *hash;
Sha256.initHmac("hash key",8); // key, and length of key in bytes
Sha256.print("This is a message to hash");
hash = Sha256.resultHmac();
Serial.print(hash,HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}
I got this error:
Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\e\Documents\Arduino\codes\test_v1\test_v1.ino:1:0:
C:\Users\e\Documents\Arduino\libraries\Sha/sha256.h:26:18: error: conflicting return type specified for 'virtual void Sha256Class::write(uint8_t)'
virtual void write(uint8_t);
^
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:224,
from sketch\test_v1.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:48:20: error: overriding 'virtual size_t Print::write(uint8_t)'
virtual size_t write(uint8_t) = 0;
^
C:\Users\e\Documents\Arduino\codes\test_v1\test_v1.ino: In function 'void setup()':
test_v1:6: error: invalid conversion from 'const char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
Sha256.initHmac("hash key",8); // key, and length of key in bytes
^
In file included from C:\Users\e\Documents\Arduino\codes\test_v1\test_v1.ino:1:0:
C:\Users\e\Documents\Arduino\libraries\Sha/sha256.h:23:10: error: initializing argument 1 of 'void Sha256Class::initHmac(const uint8_t*, int)' [-fpermissive]
void initHmac(const uint8_t* secret, int secretLength);
^
test_v1:9: error: call of overloaded 'print(uint8_t*&, int)' is ambiguous
Serial.print(hash,HEX);
^
C:\Users\e\Documents\Arduino\codes\test_v1\test_v1.ino:9:24: note: candidates are:
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:224,
from sketch\test_v1.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:62:12: note: size_t Print::print(unsigned char, int)
size_t print(unsigned char, int = DEC);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:62:12: note: no known conversion for argument 1 from 'uint8_t* {aka unsigned char*}' to 'unsigned char'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:63:12: note: size_t Print::print(int, int)
size_t print(int, int = DEC);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:63:12: note: no known conversion for argument 1 from 'uint8_t* {aka unsigned char*}' to 'int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:64:12: note: size_t Print::print(unsigned int, int)
size_t print(unsigned int, int = DEC);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:64:12: note: no known conversion for argument 1 from 'uint8_t* {aka unsigned char*}' to 'unsigned int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:65:12: note: size_t Print::print(long int, int)
size_t print(long, int = DEC);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:65:12: note: no known conversion for argument 1 from 'uint8_t* {aka unsigned char*}' to 'long int'
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:66:12: note: size_t Print::print(long unsigned int, int)
size_t print(unsigned long, int = DEC);
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:66:12: note: no known conversion for argument 1 from 'uint8_t* {aka unsigned char*}' to 'long unsigned int'
exit status 1
invalid conversion from 'const char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
I tried to replace the uint_t *hash by this type: static const char hash[450]={};
But again, got the same error.
Can you help me please.