Skip to main content
1 of 3
DannyNiu
  • 9.8k
  • 2
  • 25
  • 62

Is this protocol design secure?

See below.

What would be the advantage to use HMAC (or any other MAC) instead of AES encryption?

HMAC was originally proposed as construct that turns a Merkle-Damgaard hash function based on compression functions built from block ciphers. Although there's no decryption in HMAC, you can actually easily replace your AES decryption-based authentication with comparing HMAC-signed tag.

Did I miss something?

What you're doing is essentially an authenticated security transport without confidentiality.

What you're missing is that you didn't authenticate the exchange following the initial authentication - this allows for connection hijacking, arbitrary injection of data packets, and more.

Therefore, you should use HMAC+[hash] or CMAC+[block cipher] to authenticate all of your messages exchanged, and also keep a counter as a state to detect duplicate packets and message replay attackes.

DannyNiu
  • 9.8k
  • 2
  • 25
  • 62