Photo by Sixteen Miles Out on Unsplash

Key-based Hashing

--

One of the great things about teaching is when you get probing questions from questions that allow you to explain things in different ways. And, so, yesterday, one student asked if an encryption key could be used with a hash. And, of course, it does, but I had used the term “HMAC”, and had not actually given it, its correct generic name of a key-based hash. So, let’s have a look at key-based hashing.

With our normal hashing, we data any amount of input data, and then correct it (normally) into a fixed-length hash:

And so, if Bob and Alice are communicating, how do they know that it is them that are still part of the communication and that Eve hasn’t hi-jacked their session? Well, this is where key-based hashing comes in. With this Bob and Alice can authenticate each other at the start of the conversation, and then generate a shared secret. This secret might be a long-term secret that they used in every conversation they have, or could be generated for every conversation they have. Hopefully, Eve will not know this secret, and even if she discovers it, Bob and Alice can move to another secret.

HMAC (Hash-based Message Authentication Code) can be used to verify the integrity and authentication of…

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.