On Saturday, August 16, 2014 11:46:17 AM UTC-4, Frank Spears wrote:
>
> hello,
>
> i tried to use the new SHA-3 hash function that is available in Crypto++
> version 5.6.2, through the following code:
>
> CryptoPP::HMAC <CryptoPP::SHA3_512> sha;
>
> this compiles just fine. however, when i run the program, it crashes with
> the following exception:
>
> terminate called after throwing an instance of 'CryptoPP::InvalidArgument'
> what(): HMAC: can only be used with a block-based hash function
>
> is there a way around this? as far as i know, SHA-3 should be good enough
> to be used as HMAC.
>
> I could not get it to compile. To get through the compile error, I had to
open sha3.h and add "CRYPTOPP_CONSTANT(BLOCKSIZE = DIGESTSIZE)" to the
classes. For example:
class SHA3_512 : public SHA3
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 64)
CRYPTOPP_CONSTANT(BLOCKSIZE = DIGESTSIZE)
SHA3_512() : SHA3(DIGESTSIZE) {}
static const char * StaticAlgorithmName() {return "SHA-3-512";}
};
However, it causes a runtime error:
$ ./cryptopp-test.exe
key: 22D373A66BCA096CCCF0FFDAC4B8ADA9F826F786AB60BB317
BC086FDF9A87A9A01DD1CA0D6283272D25EEF974B3D936160E9AC
5126B3D50B8B62DCC7FF9FA3C9
plain text: HMAC Test
HMAC: can only be used with a block-based hash function
The error message is coming from hmac.cpp, HMAC_Base::UncheckedSetKey:
HashTransformation &hash = AccessHash();
unsigned int blockSize = hash.BlockSize();
if (!blockSize)
throw InvalidArgument("HMAC: can only be used with a block-based
hash function");
I don't know enough about SHA3 and HMACs to know if things are OK. There's
a question about it on the Crypto Stack Exchange:
https://crypto.stackexchange.com/questions/15782/how-secure-would-hmac-sha3-be.
Jeff
--
--
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.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.