I have a question regarding the TLS handshake. As of my reading I came to know that master_secret will be derived from pre_master_secret shared by client as follows:

  • master_secret = PRF(pre_master_secret, "master secret", lientHello.random + ServerHello.random)

  • From this master_secret the below session keys are derived.

  • On client side:

  • On server side:


Wwhen these session keys are generated separately on the client and the server and never exchanged and transmitted between them, how does the server decrypt the client's encrypted message and vice-versa?

Or all the 6 session keys are created on both client and server individually and hope they are similar. If this is true then both the client and the server can decrypt each others encrypted messages.


1 Answer 1


Look at RFC 5246 Section 6.3. On both sides, bytes are generated using the PRF from the same arguments, so the generated bytes are the same. Those generated bytes are used the following way: The first "mac_key_length" bytes (e.g. 20 bytes) are the client's MAC key and the next "mac_key_length" are the server's. Then the next "enc_key_length" (e.g. 16 bytes) are the client's cipher (e.g. AEs) key and the next are the server's, etc.

Each sides knows whether it's the client or the server, so they choose the right MAC/key/IV when reading and the other MAC/key/IV when writing.

  • Excellent.... My question is answered.. Thanks a lot..
    – Srinivas M
    May 27, 2016 at 13:27

Not the answer you're looking for? Browse other questions tagged .