A few Modest Proposals on Optimizing SSL traffic and round trips

during TLS 1.2 TLS_RSA_WITH_AES_128_CBC_SHA Handshake

by David Stewart Zink, Version of Mon Dec 25 17:30:26 PST 2006

Based on The TLS Protocol Version 1.2.

Notation

We use + for addition, xor for bitwise exclusive or, || for concatenation, ^ for exponentiation. Assuming we get around to doing any of these things.

In ladder diagrams the Client appears on the left and the Server on the right. The depiction of each message begins with the name of the message and a centered arrow depicting the direction of motion, either "<<<——" or "——>>>". Note that these represent messages and not records: a large message may span many records.

Messages

This can be a little difficult to follow as there is some conflation of layers in the design. The simplest approach is to imagine that the HandShake protocol is an application which is exchanging messages across the record layer. A single Handshake message might be split across many records, they might begin in the middle of records, they simply are transferred using records. However, to respond to a handshake message obviously the record containing the message must be terminated. Thus in ContentType below, "change_cipher_spec" and "alert" are flow control meta-messages, while "handshake" and "application_data" represent two applications multiplexing across the connection.

Every Handshake message is a "Record" as defined by TLS. The fields of a Record are as follows:

Every Handshake message except for "ChangeCipherSpec" has type "handshake". The ChangeCipherSpec message for TLS 1.2 is exactly five bytes with has exactly this content:

Every message with type "handshake" is encapsulated in records with this format:

A handshake message has this format:

Generic Handshake Message Closure: the ChangeCipherSpec and Finished messages.

The general form of Handshake is that Client and Server exchange a number of messages establishing a new set of traffic keys, and then the Client sends ChangeCipherSpec to the Server, followed by Finished.

ChangeCipherSpec has the meaning, "I have changed my Write Keys and every message after this will be encrypted with the currently agreed write keys. You need to change your read keys to continue parsing data."

Finished contains a MAC of all the previous handshake messages, and since it follows the ChangeCipherSpec it is encrypted with the new keys. Therefore the ability to decrypt and verify the MAC proves to the server that the Client has received accurate versions of all handshake messages and properly computed the new keys.

Then the Server sends ChangeCipherSpec and Finished to the Client, allowing the Client to verify the server's understanding and keys.

The MAC sent by the Client to the Server and the MAC sent by the Server to the Client are computed in a slightly different fashion so that they cannot be reflected.

What is TLS_RSA_WITH_AES_128_CBC_SHA?

This is an SSL cipher-suite enum value which specifies that the traffic protocol will be AES-128 CBC and the traffic signing protocol will be SHA1. The "pre master secret" value from which the keys will eventually be generated will use RSA asymmetric keys. The use of RSA determines the structure of most of the handshake protocol, and is essentially the same for every RSA cipher-suite. SHA is used to signify SHA1 because 4.

Message exchange in TLS_RSA_WITH_AES_128_CBC_SHA with mutual authentication.

This is based on my (David Stewart Zink's) reading of the specifications and investigation of a sample implementation and should be considered informed but not authoritative.

We use the extended versions of ClientHello and ServerHello not because we are using extensions but because the eventual proposals will involve them and we wish to show their place in the protocol. The non extended versions are identical, except lack extensions.

Client                            Server
Extended Client Hello:   ———>>>
We assume that no extensions, sessions or compressors are present. The messages therefore contains the client's SSL version number (presumably TLS 1.2), a 32-byte kinda-random value, and offered cipher_suites including our darling TLS_RSA_WITH_AES_128_CBC_SHA.

              <<<——————  Extended Server Hello
The server presents its SSL versions (presumably TLS 1.2), provides its own 32-byte kinda-random value, accepts the TLS_RSA_WITH_AES_128_CBC_SHA cipher suite, and agrees to no compression.

              <<<——————  Server Certificate
The first certificate must be the server's certificate. Each certificate after that signs the one before it, until the root certificate is reached. The root certificate may be omitted since it is useless if the client does not already have it.

              <<<——————  Certificate Request
Presumably since we are doing mutual authentication the server would need a certificate from the client.

              <<<——————  Server Hello Done
This is an empty message, just a signifier.

Client Certificate   —————>>>
X.509 ASN encoded certificate. The first certificate must be the client's certificate. Each certificate after that signs the one before it, until the root certificate is reached. The root certificate may be omitted since it is useless if the server does not already have it.

Client Key Exchange   ——————>>>
The pre master secret requires some explanation. Its format is as follows: We encrypt this data with the public key from the server's certificate.

Certificate Verify   ——————>>>
Verifies that the client has the private key associated with the client's certificate.

At this point the client (and the server after it receives all the client's messages) has sufficient information to calculate the traffic keys. This is done by first computing the master secret from the following information:

This is combined using the "PRF" function to create

Then the magical PRF function is used once more to create the four traffic keys (encrypt + sign, decrypt and verify) from the following:

Now that the client has generated its four keys it sends the ChangeCipherSpec message and then the finished message.

ChangeCipherSpec     ——————>>>
empty non-handshake message signaling time to use new keys.

Finished             ——————>>>
The verify_data element is computed by calculating the HASH of all preceding handshake messages (as with the Certificate Verify message) and then combining once more using the mystical PRF function the following data:

And now the server has all the info it needs, calculates the keys and sends the ChangeCipherSpec message and then the finished message.

                   <<<——————   ChangeCipherSpec
empty non-handshake message signaling time to use new keys.

                   <<<——————   Finished
The verify_data element is computed by calculating the HASH of all preceding handshake messages (as with the Certificate Verify message) and then combining once more using the mystical PRF function the following data:

Oh boy we're done!

Existing Extension: Trusted CA Keys

A client can send an extension message with its ClientHello specifying the root servers from which it is prepared to accept signed certificates. The exact mechanism is unimportant (there are a few options), but essentially the client sends a list of names or whatever identifiers. The server then only accepts the Hello attempt if it can send a chain of certificates rooted in one of the acceptable root servers.

Proposed Extension: Versioned Trusted CA Keys

Corporate CAs occasionally find themselves invalidating all previous certificates, or migrating piecemeal to a new set of certificates. In this case it would be useful if the Client could specify exactly which version of the Trusted CA Key it is aware of. Trusted CA Keys have a pseudo-versioning option in that certificates can be identified by hash; however name-hash pairs would be better.

Proposed Extension: Trusted Certificates

There is no reason not to extend the "Trusted CA Keys" scheme to include all certificates. For instance, if the client has previously connected with the server and been given the chain of certificates A<-B<-C<-D<-ROOT, then it could specify in its hello message that entire chain "A<-B<-C<-D<-ROOT". If the server is still using certificate A then the server could simply confirm that it is doing so. If the server has a new certificate A2 signed by B, it can simply give A2, knowing that the client will be able to verify the signature. If none of the certificates are valid except the root, the fallback behavior would be the standard behavior. Obviously names are insufficient for this process and some versioning information (such as a hash or the certificate sequence number) should be included as well.

Proposed Extension: Proffered Client Certificate

There exists an extension to allow the client to send URLs instead of actual certificates so that they do not even need enough storage to hold their own certificates. The URL is sent at the time a certificate is normally sent. The first part of this proposal is that Client Certificate URLs if modest in size simply be included in the ClientHello message so that the Server can get a head start on processing them. Obviously if the server has spoken with the client before it might perform an If-Modified-Since operation rather than retrieving the Certificate every time. This leads to the second part of the proposal, that the Client simply be able to include a hash of its certificate or other identifier so that the Server can cache certificates reliably.

Proposed Extension: Fully Random Randoms

The first four octets of the random values generated for Client and Server random are specified to be the GMT time, which is further specified to be ignored. They should simply be generated as random values. If necessary, an extension could be added specifying this treatment.

Furthermore the first two bytes of the pre-master secret are not random but are rather the client version number, almost certainly 3 and 3. The document alleges that these were long ago placed here in order to demonstrate that the client version was as specified in the original hello message, but that this was no longer necessary since the entire handshake process is signed with a MAC in the Finished message. Therefore these should be randomized. An extension or version change would be necessary to specify this behavior.

Proposed Extension: Server Generated Pre Master Secrets

In the mutually authenticated environment the distinction between Client and Server is somewhat nominal. The pre-master secret is simply random data. It is generated on the Client because in the singly-authenticated environment only the Server's public key is available to securely encrypt documents. Since in the mutually authenticated environment with the Proffered Client Certificate extension the Server has access to the Client's public key, this could be used to encrypt the pre-master key. This has the effect of making it possible to redistribute processing load without affecting the security of the protocol.

Revision History