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:CBA54DBA951FB57F905AC8696BDE3A77D8A525DB3CFC61787F9C13A78C78CBB58D12F7C6
(stdin)= 0aa133f891f038b31f20843280a61ca1f6e057a16fc178fd907202f5ea11eb0c

That way we were confident to promote the software into production

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s