A few days ago we were implementing HMAC SHA-256 algorithm in java accordingly to RFC 2104. At a certain point the question was: “Is that implementation correct?” How could we be sure of it? The following openssl command cleared out the doubts.
echo -n [SAMPLE_INPUT_TEXT] | openssl dgst -sha256 -mac hmac -macopt hexkey:[HEXA_KEY]Putting some value on it we got:
echo -n "TEXT_INPUT_FOR_HMAC" | openssl dgst -sha256 -mac hmac -macopt hexkey:CBA54DBA951FB57F905AC8696BDE3A77D8A525DB3CFC61787F9C13A78C78CBB58D12F7C6That way we were confident to promote the software into production