12.6 TLS key exchange messages
During the TLS handshake, the Bob and the Alice negotiate the cryptographic settings for the key establishment and agree upon shared secret keys using Key Exchange Messages. These keys are used to protect the later part of the handshake itself as well as the subsequent application data transmitted between Bob and Alice.
We saw in Chapter 6, Transport Layer Security at a Glance, that there are a number of different handshake messages used depending on the chosen key exchange option and the current state of the protocol.
The handshake messages must be sent in the order specified by the TLS protocol. Whenever Alice or Bob receive an out-of-order handshake message, they immediately abort the handshake and signal the error by transmitting the unexpected˙alert
message.
This illustrates two good practices in cryptographic protocol design. First, the expected order of messages must be unambiguous in any given situation to avoid misinterpretations both...