Revision 9b0d959aea55e085083652864435023cc39f0785 (click the page title to view the current version)

TLS Handshake Model

This example demonstrates modeling the TLS 1.2 handshake protocol (RFC 5246, section 7.3) between a client and a server, as a product line: anonymous mode and client authentication are features, fixed in each trace.

Client                                   Server
ClientHello                  -------->
                                         ServerHello
                                         Certificate*
                                         ServerKeyExchange*
                                         CertificateRequest*
                             <--------   ServerHelloDone
Certificate*
ClientKeyExchange
CertificateVerify*
[ChangeCipherSpec]
Finished                     -------->
                                         [ChangeCipherSpec]
                             <--------   Finished
Application Data             <------->   Application Data

The server answers with a protocol_version alert when the client and the server have no version in common, and a fatal alert ends the connection.

Module Downloads: | [.cfr] | [.html] |

Feature modeling

abstract final Feature
abstract final FeatureModel
TLSFeatures : FeatureModel
annonymousMode : Feature ?
clientAuthentication : Feature ?
// the server requests a client certificate only from a known server (no anonymous mode)
abstract final Domain
enum ProtocolVersion = SSL2_0 | SSL3_0 | TLS1_0 | TLS1_1 | TLS1_2
enum HandshakeStatus = initiated | completed | failed
abstract Port
abstract final Message

Server side messages

serverHelloRequestMessage : Message
serverHelloMessage : Message
serverCertificateMessage : Message
serverKeyExchangeMessage : Message
serverCertificateRequestMessage : Message
serverHelloDoneMessage : Message
serverChangeCipherSpecMessage : Message
serverFinishedMessage : Message
protocolMismatch : Message

Client side messages

clientHelloMessage : Message
clientCertificateMessage : Message
clientKeyExchangeMessage : Message
certificateVerifyMessage : Message
clientChangeCipherSpecMessage : Message
clientFinishedMessage : Message

Application data

applicationDataMessage : Message

Nodes

abstract final Node : Domain
send : Port -> Message
receive : Port -> Message
protocolversion -> ProtocolVersion +
certificate ?
signing ?
abstract final Server : Node
abstract final Client : Node

Connecting messages

Concrete client and server

The main protocol

A phase of the channel is left only from its last states. A transition that leaves a phase is a constraint of the channel: as a transition of a state nested in the phase, it would lapse when the phase is left, which is when it should take effect.

Protocol : Domain
final client -> aClient
final server -> OurServer
handshakeStatus -> HandshakeStatus
xor channel // The phases of the connection. A phase is left only from its last states, and a
xor serverResponse// transition that leaves a phase is a constraint of the channel: as a transition of a state
[ handshakeStatus = initiated ]// nested in the phase, it would lapse when the phase is left, which is when it should take
[ initially serverHello || mismatch ]// effect. The transitions within a phase hold while the phase lasts.
serverHello
[ server.send = serverHelloMessage ]// no version in common: a protocol_version alert
serverCertificate// the server picks a version that both support
[ serverCertificate -[no clientAuthentication]-> serverKeyExchange || serverHelloDone ]// a known server sends its certificate; an anonymous one its key exchange
serverKeyExchange
serverHelloDone
[ serverResponse -[ ! (serverResponse.mismatch || serverResponse.serverHelloDone)]-> serverResponse ]// features: client authentication
xor clientResponse // the client sends its certificate when the server requests it
clientKeyExchange
certificateVerify --> clientChangeCipherSpec
[ client.send = certificateVerifyMessage ]// a client with a certificate that can sign proves that it has the private key
clientChangeCipherSpec --> clientFinished
clientFinished
xor serverFinish
initial serverChangeCipherSpec --> serverFinished
// both Finished messages complete the handshake
fatalError --> fatalError
// the application data flows until a new handshake (renegotiation)
// a fatal alert ends the connection