Somehow I do not get HMAC.
I once asked Why do I need HMAC when we have public key signatures? , and I think I got it. Easier to calculate and so on ...
But I donβt understand why we need HMAC in general, respectively, what problem they solve.
From my understanding, HMACs ...
- Provide a way to ensure that the message has not been modified,
- "protected" with a secret but symmetric key.
Therefore, to calculate the HMAC (either initially or for verification) I need to know the secret key.
Now, if I can exchange this key in a secret way without being dropped, I could also exchange the message in the same secret form without being tampered with, is it?
Well, now you can claim that you only need to exchange the key once, but you can have several messages. It's fine.
But if we now have a secret key that should be kept secret by all parties, we could also directly use symmetric encryption using the same secret key to encrypt the message, right?
Of course, the HMAC should provide a solution against unauthorized access, but if I have only an encrypted message without a secret key and a reasonable encryption algorithm, I cannot change this encrypted message in such a way that: a) the decryption still works, and b) a meaningful one appears decrypted message.
So why do I need an HMAC? Or - where is my flaw?
encryption hmac
Golo roden
source share