Hey there,
I am trying to figure out how to use the message authentication code
for cryptopp.
Based on reading the FAQ I have come up with this code to try and
produce a digest for this test vector:
test_case = 1
key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
key_len = 16
data = "Hi There"
data_len = 8
digest = 0x9294727a3638bb1c13f48ef8158bfc9d
However I have some errors.
It looks simple enough to implement but my programming is pretty
rubbish so if you could help me out with what needs to be done to get
an output for a digest that would be great.
Am confused that the digest is needed to be declared as I thought that
was the result not an input.
Thanks for any help!
Here is my code implementing HMAC-SHA1 (similar to the code in the
FAQ)
#include "sha.h"
#include "hmac.h"
int main()
{
HMAC<SHA >(const byte* key = 0x0b, size_t length= 20)).CalculateDigest
(byte *digest, const byte *input = "Hi there", size_t length= 64)
}
Here is my makefile:
CC=g++
authentication:auth.o hmac.o sha.o
$(CC) auth.o hmac1.o sha.o -o authentication
auth.o: auth.cpp hmac.h sha.h
$(CC) -c auth.cpp
sha.o: sha.cpp sha.h
$(CC) -c sha.cpp
hmac.o: hmac.cpp hmac.h
$(CC) -c hmac.cpp
And here is my error message:
g++ -c auth.cpp
In file included from sha.h:4,
from auth.cpp:1:
iterhash.h: In member function ‘void
CryptoPP::IteratedHashWithStaticTransform<T, B, S,
M>::vTransform(const T*)’:
iterhash.h:84: error: ‘m_digest’ was not declared in this scope
iterhash.h: In member function ‘void CryptoPP::IteratedHashBase2<T, B,
BASE>::TruncatedFinal(byte*, unsigned int)’:
iterhash.h:92: error: there are no arguments to
‘ThrowIfInvalidTruncatedSize’ that depend on a template parameter, so
a declaration of ‘ThrowIfInvalidTruncatedSize’ must be available
iterhash.h:92: error: (if you use ‘-fpermissive’, G++ will accept your
code, but allowing the use of an undeclared name is deprecated)
iterhash.h:94: error: there are no arguments to ‘BlockSize’ that
depend on a template parameter, so a declaration of ‘BlockSize’ must
be available
iterhash.h:95: error: ‘m_data’ was not declared in this scope
iterhash.h:95: error: there are no arguments to ‘BlockSize’ that
depend on a template parameter, so a declaration of ‘BlockSize’ must
be available
iterhash.h:97: error: there are no arguments to ‘GetBitCountHi’ that
depend on a template parameter, so a declaration of ‘GetBitCountHi’
must be available
iterhash.h:97: error: there are no arguments to ‘GetBitCountLo’ that
depend on a template parameter, so a declaration of ‘GetBitCountLo’
must be available
iterhash.h:98: error: there are no arguments to ‘GetBitCountLo’ that
depend on a template parameter, so a declaration of ‘GetBitCountLo’
must be available
iterhash.h:98: error: there are no arguments to ‘GetBitCountHi’ that
depend on a template parameter, so a declaration of ‘GetBitCountHi’
must be available
iterhash.h:101: error: ‘m_digest’ was not declared in this scope
iterhash.h:101: error: there are no arguments to ‘DigestSize’ that
depend on a template parameter, so a declaration of ‘DigestSize’ must
be available
iterhash.h:104: error: there are no arguments to ‘Restart’ that depend
on a template parameter, so a declaration of ‘Restart’ must be
available
iterhash.h: In member function ‘void CryptoPP::IteratedHashBase2<T, B,
BASE>::HashBlock(const typename CryptoPP::IteratedHashBase<T,
BASE>::HashWordType*)’:
iterhash.h:113: error: ‘m_data’ was not declared in this scope
iterhash.h:113: error: there are no arguments to ‘BlockSize’ that
depend on a template parameter, so a declaration of ‘BlockSize’ must
be available
In file included from seckey.h:10,
from hmac.h:6,
from auth.cpp:2:
simple.h: In member function ‘bool
CryptoPP::Unflushable<T>::Flush(bool, int, bool)’:
simple.h:71: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h: In member function ‘bool
CryptoPP::Unflushable<T>::ChannelFlush(const std::string&, bool, int,
bool)’:
simple.h:80: error: there are no arguments to ‘AttachedTransformation’
that depend on a template parameter, so a declaration of
‘AttachedTransformation’ must be available
simple.h: In member function ‘void
CryptoPP::Multichannel<T>::Initialize(const CryptoPP::NameValuePairs&,
int)’:
simple.h:134: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h: In member function ‘bool
CryptoPP::Multichannel<T>::Flush(bool, int, bool)’:
simple.h:136: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h: In member function ‘void
CryptoPP::Multichannel<T>::MessageSeriesEnd(int)’:
simple.h:138: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h:138: error: there are no arguments to
‘ChannelMessageSeriesEnd’ that depend on a template parameter, so a
declaration of ‘ChannelMessageSeriesEnd’ must be available
simple.h: In member function ‘byte*
CryptoPP::Multichannel<T>::CreatePutSpace(unsigned int&)’:
simple.h:140: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h: In member function ‘unsigned int
CryptoPP::Multichannel<T>::Put2(const byte*, unsigned int, int,
bool)’:
simple.h:142: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h: In member function ‘unsigned int
CryptoPP::Multichannel<T>::PutModifiable2(byte*, byte*, int, bool)’:
simple.h:144: error: ‘NULL_CHANNEL’ was not declared in this scope
simple.h:144: error: there are no arguments to ‘ChannelPutModifiable2’
that depend on a template parameter, so a declaration of
‘ChannelPutModifiable2’ must be available
simple.h: In member function ‘bool
CryptoPP::Multichannel<T>::ChannelPutModifiable(const std::string&,
byte*, unsigned int)’:
simple.h:151: error: there are no arguments to ‘ChannelPut’ that
depend on a template parameter, so a declaration of ‘ChannelPut’ must
be available
In file included from hmac.h:6,
from auth.cpp:2:
seckey.h: In member function ‘unsigned int
CryptoPP::BlockCipherBaseTemplate<INFO, INTERFACE>::BlockSize()
const’:
seckey.h:159: error: ‘BLOCKSIZE’ was not declared in this scope
seckey.h: In constructor ‘CryptoPP::BlockCipherTemplate<DIR,
BASE>::BlockCipherTemplate(const byte*)’:
seckey.h:169: error: ‘DEFAULT_KEYLENGTH’ was not declared in this
scope
seckey.h: In constructor ‘CryptoPP::BlockCipherTemplate<DIR,
BASE>::BlockCipherTemplate(const byte*, unsigned int, unsigned int)’:
seckey.h:173: error: there are no arguments to ‘SetKeyWithRounds’ that
depend on a template parameter, so a declaration of ‘SetKeyWithRounds’
must be available
seckey.h: In constructor
‘CryptoPP::MessageAuthenticationCodeTemplate<BASE>::MessageAuthenticationCodeTemplate(const
byte*)’:
seckey.h:197: error: ‘DEFAULT_KEYLENGTH’ was not declared in this
scope
seckey.h: In member function ‘std::string
CryptoPP::MessageAuthenticationCodeTemplate<BASE>::AlgorithmName()
const’:
seckey.h:201: error: there are no arguments to ‘StaticAlgorithmName’
that depend on a template parameter, so a declaration of
‘StaticAlgorithmName’ must be available
In file included from auth.cpp:2:
hmac.h: In constructor ‘CryptoPP::HMAC<T>::HMAC(const byte*, unsigned
int)’:
hmac.h:47: error: there are no arguments to ‘SetKey’ that depend on a
template parameter, so a declaration of ‘SetKey’ must be available
auth.cpp: In function ‘int main()’:
auth.cpp:9: error: ‘HMAC’ was not declared in this scope
auth.cpp:9: error: ‘SHA’ was not declared in this scope
auth.cpp:9: error: expected primary-expression before ‘const’
auth.cpp:9: error: expected `)' before ‘const’
auth.cpp:13: error: expected `;' before ‘}’ token
make: *** [auth.o] Error 1
--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---