Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I've seen people everywhere say to use a MAC or HMAC with block ciphers. I think I understand the basics, but I'm still not sure how the HMAC secret is distributed so the other party can verify that it's valid. Is the secret distributed freely like the IV (though the name suggests it is secret)? Is it part of the ciphertext? Is it sent over a secure channel like the AES key?

Also, is it safe to use the same HMAC secret for each subsequent AES encrypted message after the initial connection? Assuming all keys (other than public/private keypairs) are destroyed after the connection is closed.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It is "sent over a secure channel like the AES key".
It is "safe to use the same HMAC secret for each subsequent
AES encrypted message after the initial connection".

share|improve this answer

How is the MAC or HMAC secret shared with the other party for verification?

It depends on the type of implementation or system you are interested in, but i can share my experience. Unless pre-agreed key is known before hand, usually a public key cryptography is used to share secret key (e.g. AES-key) over a public insecure channel.

  1. Encrypting by the public key of the receiver, you can enable the receiver to decrypt the key with its private key.
  2. Generating sharedsecret using public-private key of sender and receiver. You can refer Diffie-Hellman

is it safe to use the same HMAC secret for each subsequent AES encrypted message after the initial connection?

It depends what type of application you are planning. For example, if it is sensitive data requiring high security protection, you can generate shared key per session. You can refer Ephemeral Diffie-Hellman, that enables generating non static session key.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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