This Handshake Protocol allows the server and client to authenticate each other and to negotiate an encryption and MAC algorithm and cryptographic keys.
Moreover, The Handshake Protocol is used before any application data is transmitted.
A handshake message has the following format:
Type (1 byte): Indicates one of 10 messages of handshake protocol.
Length (3 bytes): The length of the message in bytes.
Content ( bytes): The parameters associated with this message.
Similarly, The algorithm has four phases.
Phase 1. Establish Security Capabilities: This phase is used to initiate a logical connection and to establish the security capabilities that will be associated with it.
- The exchange is initiated by the client, which sends a client_hello message with the following parameters:
- Version: The highest SSL version understood by the client.
- Random: A client-generated random number which serves as the nonce.
- Session ID: A variable-length session identifier. A nonzero value indicates that the client wishes to update the parameters of an existing session. A zero value indicates that the client wishes to establish a new connection on a new session.
- CipherSuite: This is a list that contains the cryptographic algorithms (key exchange, encryption, and MAC) supported by the client, in decreasing order of preference.
- Compression Method: This is a list of the compression methods the client supports.
- After sending the client_hello message, the client waits for the server_hello message, which contains the same parameters as the client_hello message. The parameters contain the values which client had sent to the server and the server has chosen to use.
Phase 2: Server Authentication and Key Exchange: This phase provides authentication of the server to the client. o The server sends its certificate (one or more) if it needs to be authenticated.
- The server sends a server_key_exchange message which contains the list of secret keys to be used for the subsequent data. o The certificate_request message is sent next which includes two parameters: certificate_type and certificate_authorities.
- Moreover, The final message in phase 2, and one that always required is the server_done message, which sent by the server to indicate the end of the server hello and associated messages.
- After sending this message, the server will wait for a client response. This message has no parameters.
Phase 3. Client Authentication and Key Exchange: This phase provides client authentication to the server.
- The client verifies the server certificates and checks whether the server_hello parameters are acceptable.
- Moreover, If all is satisfactory, the client sends a certificate message if the server has requested a certificate. If no suitable certificate is available, the client sends a no_certificate alert.
- Next is the client_key_exchange message which has the same parameters as the server_key_exchange message.
- Similarly, The client may send a certificate_verify message to provide explicit verification of a client certificate.
The client encrypts all the previous messages and master secret with its private key.
Phase 4. Finish: This phase completes the setting up of a secure connection.
- The client sends a change_cipher_spec message and copies the pending CipherSpec into the current CipherSpec.
- Moreover, The client then immediately sends the finished
- The server sends its own change_cipher_spec message, transfers the pending to the current CipherSpec, and sends it finished
- At this point, the handshake is complete and the client and server may begin to exchange application-layer data.
Cryptographic Computations: Handshake Protocol
Additionally, Two further items are of interest:
- The creation of a shared master secret by means of the key exchange ü The shared master secret is a 48-byte value unique to this session.
- First, a pre_master_secret exchanged.
- Then, the master_secret calculated by both parties.
- The generation of cryptographic parameters from the master secret.
- Moreover, The parameters include a client write MAC secret, a server writes MAC secret, a client writes key, a server writes key, a client writes IV, and a server writes IV, which generated from the master secret.
- These parameters generated from the master secret by hashing the master secret into a sequence of secure bytes of sufficient length for all needed parameters.