I have a server which has a configured value of AES and HMAC key. The client also should have the same keys.

When the client sends a request, the server interprets this request and reads the message.

Now when the client has the wrong AES and HMAC keys, the server will still interpret the request from the client but get the wrong message out of it since the AES and HMAC keys are different.

Is there a way for the server to tell whether the AES and HMAC keys used by the client are wrong? From what I understand, the server will get the wrong message after decrypting the client request, but cannot tell if the keys used by the client are wrong.

  • The answer is "yes ..." but how depends on if you are doing MAC then ENCRYPT, ENCRYPT then MAC, or MAC and ENCRYPT. Jul 10, 2015 at 14:36

1 Answer 1


The server should never even attempt to decrypt the message. If the HMAC keys are different between the server and the client, the authentication should fail (the server won't be able to create the same MAC from the ciphertext and the server key, since the server key is not the same as the client key, and the process should abort.

Now, if you're doing something sub-optimal like MAC-then-Encrypt, or MAC-and-Encrypt, you have other issues, but you still won't be able to authenticate the plaintext since neither the plaintext nor the MAC will match, and you should know at that point that you have a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.