Hey, its me again!
Am just in the process of finalizing my code with use for a testbed.
The MAC calculations seem to be working correctly so thanks for your
previous help with that.
Now instead of having my key hard coded into the code, I am trying to
read the key from a file. That way I can change the key mid session by
altering the file.
I have successfully managed to do this when using the key of: Jefe
and got the correct test vector output.
I used this code to obtain and use my key from the file:
key unsigned char [20];
string keystring;
std::ifstream infile;
infile.open("/home/adam/Documents/cryptopp/mackey.txt");
if (!infile)
{
printf("\n Unable to open the key file. \n");
exit (1);
}
getline(infile,keystring);
//getline(keystring, 20 );
infile.close();
HMAC<SHA1> hmac ( (byte*)keystring.c_str(), keystring.size() );
hmac.Update( (byte*)payload.c_str(), payload.size() );
hmac.Final( digest );
However it wont give the correct digest when I want to use the key
of : 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
I guess that is because it is in binary format and I am reading the
file as a string, and then converting it to an array of unsigned
chars...so it is not correctly putting the value of '0b' into each
array slot.
What adjustments would I need to do for it to be able to be able to
read my key of 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b from a file?
Many thanks,
I appreciate this is more related to general programming rather than
cryptopp but thought I would still try asking just in case, since it
is related to calculating a MAC with the obtained data. Thanks. Adam.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---