2

For example: I am using HMAC SHA 256 to sign an XML file. Part of the file data is a version number. If I append the version to my secret to use it as a key, does that weaken the HMAC? As the version is also part of the signed message is it weakend or still safe?

2 Answers 2

2

No, its not weakened. The HMAC ensures that even if some of the key is known, the remainder remains unchanged. Otherwise there would be zeroes instead of the version number. However, the HMAC isn't made "stronger" either.

2
  • 1
    TL;DR: No but it's useless. Just leave the message out of the key.
    – Luc
    Sep 8, 2014 at 15:18
  • @Luc I thought of it as a form of versioning the XML file. Having a different key for every version.
    – aggsol
    Jan 27, 2015 at 8:14
0

If I understand you correctly, you're using a known (i.e. visible to an attacker) piece of information as part of your key. If this is the case, then you are absolutely weaking your HMAC, because you're reducing the amount of unknown keyspace they need to bruteforce to forge a message.

For example, if you're using a 128-bit key with your HMAC, but 32 of those bits are always known to an attacker, then they only need to attack a 96-bit keyspace.

2
  • The extra bits of information known to the attacker doesn't have to be instead of a high entropy key. It can be in addition to. HMAC keys can have arbitrary length (though you get the highest entropy, if the key length is no longer than one input block for the hash.)
    – kasperd
    Sep 8, 2014 at 20:00
  • I am using HMAC SHA256 and from what I understand from the key I input two keys, ipad and opad, are derived.
    – aggsol
    Sep 10, 2014 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .