php-sha3 icon indicating copy to clipboard operation
php-sha3 copied to clipboard

Add support for HMAC

Open mackwil opened this issue 11 years ago • 3 comments

Can this library receive hex or base64 as input into the hash?

Can this library perform HMAC using the SHA3 algorithm? I would like to do HMAC(key, message) with perhaps either or both parameters as hex.

These would be a few good features. Please consider adding them if it doesn't work already.

Thank you!

mackwil avatar Mar 05 '14 02:03 mackwil

If you pass in a hex string or base64 encoded string it should work.

HMAC is not yet supported, but it's something I may add in the future.

strawbrary avatar May 04 '15 04:05 strawbrary

+1

pculka avatar Aug 11 '15 12:08 pculka

Note that since sha3 is not vulnerable to extension attacks one can just prepend the secret key to the message to be authenticated in order to build a secure MAC.

Unlike SHA-1 and SHA-2, Keccak does not have the length-extension weakness, hence does not need the HMAC nested construction. Instead, MAC computation can be performed by simply prepending the message with the key.

source: http://keccak.noekeon.org/

2072 avatar Jan 02 '16 23:01 2072