AES, CMAC and "3 pass authentication protocol" Explained
AES is a block cipher. It permutes (maps) input blocks to output blocks of 16 bytes. The permutation that is used depends on the key. AES must be used in a mode of operation such as CBC to be able to be offer confidentiality of dynamically sized messages. CBC is commonly used in Smart Card environments. CBC offers confidentiality against (passive) eavesdroppers.

AES-CMAC is a MAC based on AES-CBC. It offers data integrity and authenticity. It is an alteration on CBC-MAC to make it secure for dynamically sized messages. Reusing CBC is of course a good idea for embedded environments (rather than relying on HMAC where the hash is commonly implemented in software).

Sometimes you may only need a MAC when communicating with a Smart Card or tag (e.g. when sending commands without confidential data). In that case you may directly perform MAC over the plaintext (command). If the data needs to be confidential then usually encrypt-than-mac is used instead of mac-then-encrypt. This is especially important when it comes to avoiding CBC padding oracle attacks.

Usually the message protection is performed by session keys, derived from the master key.



3-pass mutual authentication may also use encryption or MAC. There is not a single 3-pass protocol, there are multiple protocols that either use the master key or derived (session) authentication key, encryption or MAC. This protocol is used for entity authentication rather than message security. The (random) values used within this protocol that precedes message exchange may be used to derive the other session key(s).



Per session there may be as much as 6 session keys per pair of entities (e.g. card and reader). One key may be used for entity authentication, one for encryption and one for MAC. These 3 keys can have two sets: one for sending and one for receiving (authentication) messages. These may be generated directly or indirectly from one master key. Quite often the master key is however used directly for entity authentication, removing two keys from the list of session keys.