Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using HMAC for message signing, is it wise to salt the key, message, or both?

Say I'm designing a library to sign/verify messages with SHA-256 HMAC. If the end user uses a weak shared key and sends a lot of short messages, I assume there would be risk of an attacker discovering the key.

My intuition says I should append a unique (per message) salt to the key to make reverse-engineering the key harder.

How much would key salting help, and would I gain anything by also salting the messages?

like image 701
Steve Clay Avatar asked Sep 01 '11 16:09

Steve Clay


People also ask

Does HMAC use salt?

An HMAC incorporates additional secret data in the form of a key. This key is combined with the message in a much deeper way than a salt, and may be used in addition to a simple salt of the message.

Do we need to apply HMAC hash-based message authentication code both to symmetric and asymmetric cryptography to ensure their integrity and authenticity?

Like any of the MAC, it is used for both data integrity and authentication. Checking data integrity is necessary for the parties involved in communication. HTTPS, SFTP, FTPS, and other transfer protocols use HMAC. The cryptographic hash function may be MD-5, SHA-1, or SHA-256.

Why does HMAC need a key?

You use an HMAC key to create signatures which are then included in requests to Cloud Storage. Signatures show that a given request is authorized by the user or service account. HMAC keys have two primary pieces, an access ID and a secret.

When should you use HMAC?

Hash-based message authentication code (or HMAC) is a cryptographic authentication technique that uses a hash function and a secret key. With HMAC, you can achieve authentication and verify that data is correct and authentic with shared secrets, as opposed to approaches that use signatures and asymmetric cryptography.


1 Answers

Normally people salt the key. It does increase security, both because it makes reverse-engineering the key harder, and because the same message does not always have the same MAC, so an attacker can't simply re-send a message that was sent earlier with the same MAC. I don't see what salting the message as well would get you.

like image 168
Vanessa MacDougal Avatar answered Oct 01 '22 00:10

Vanessa MacDougal