8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf ·...

16
1 8 Transport Layer Security TLS example Layer 3 versus layer 4 security TLS protocol layers TLS record protocol TLS record structure TLS handshake protocol Resuming a TLS session Implemented SSL/TLS protocol versions BEAST attack on TLS 1.0 Latest TLS protocol versions SSL/SSL configuration options (Mozilla Firefox and Internet Explorer) TLS enhanced TCP-based application protocols

Transcript of 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf ·...

Page 1: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

1

8 Transport Layer Security

• TLS example

• Layer 3 versus layer 4 security

• TLS protocol layers

• TLS record protocol

• TLS record structure

• TLS handshake protocol

• Resuming a TLS session

• Implemented SSL/TLS protocol versions

• BEAST attack on TLS 1.0

• Latest TLS protocol versions

• SSL/SSL configuration options (Mozilla Firefox and Internet Explorer)

• TLS enhanced TCP-based application protocols

Page 2: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

2

Page 3: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

3

Page 4: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

4

Page 5: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

5

TLS/SSL Protocol Layer

• The Secure Sockets Layer (SSL) is inserted between the Transport layer

and the Application Layer (with communication layers defined according to

Tanenbaum !). In contrast to IPSec which is a Layer 3+ protocol based directly

on IPv4 or IPv6, TLS/SSL is a Layer 4+ protocol based directly on a TCP transport

mechanism.

• The TLS protocol offers secure sockets to TLS-aware applications. The TCP/IP

stack of the SSL client and server platforms do not have to be modified!

• The IPSec protocol offers secure communication to any existing IP based service

or application. It is the IP stacks of the IPsec clients or IPsec security gateways

that must be modified in order to support IPsec transport mode or IPSec tunnel

mode, respectively.

• The TLS protocol is responsible for the following tasks:

- Fragmentation of application data streams into SSL PDUs

- Compression of PDUs before encryption

- Authentication of PDUs

- Encryption of PDUs

Page 6: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

6

The TLS Record Protocol is sandwiched between a reliable Transport layer (that

means TCP and not UDP) and the Application layer. Though the TLS Handshake

Protocol is not really an application protocol, it sits above the TLS Record Protocol

in the stack, and its messages are encapsulated by the TLS Record Protocol.

A single TLS record may be up to 16384 bytes in length.

A TLS message may span multiple TLS records. A TLS certificate message may in

principle be as long as 16MB.

The TLS Handshake Messages allow the server and the client to authenticate each

other and to negotiate an encryption algorithm and cryptographic keys before the

application protocol transmits or receives its first byte of data. Thus, when a TLS

client and server first start communicating, they agree on a protocol version, select

cryptographic algorithms, optionally authenticate each other, and use public key

cryptography techniques to generate shared secrets. The TLS Handshake provides

the negotiated security parameters for the Application Message exchange.

The TLS Application Message exchange uses a keyed-hash MAC (Message

Authenticity Code), or HMAC, to protect the message's data integrity. An HMAC

algorithm takes a secret key and a message and generates a hash. (There are other

types of MAC algorithms.) Calculation of the HMAC with the same hash algorithm at

the recipient's end of the communication would detect tampering with the data. And,

because the recipient of the message with the MAC also has the secret key, the

recipient can verify authenticity of the message, which is the second feature

included in the RFC's term "reliable". This means that the message could only have

been sent by someone with the same key.

Page 7: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

The record layer fragments information blocks into TLS Plaintext records (Record

PDUs) carrying data in chunks of 2^14 bytes or less. Client message boundaries

are not preserved in the record layer (i.e., multiple client messages of the same

ContentType may be coalesced into a single TLSPlaintext record, or a single

message may be fragmented across several records).

Application data is segmented into “Application Data Segments” and packed into

“Record PDUs”. The Application Data in the Record PDU may be compressed.

(However, compression is not often used.) Each PDU is integrity checked with a

keyed Message Authentication Code (MAC). Then the packet is padded to a length

which fits to the encryption scheme.

The padding data is added to force the length of the plaintext to be an integral

multiple of the block cipher's block length. The padding may be any length up to 255

bytes long, as long as it results in the TLSCiphertext.length being an integral

multiple of the block length. Each unit in the padding data vector must be filled with

the padding length value. Legal values range from zero to 255, inclusive. This

length specifies the length of the padding field itself.

Length: Length of Application data (excluding the protocol header, and the MAC

and padding trailers)

MAC: 20 bytes for the SHA-1-based HMAC, 16 bytes for the MD5-based HMAC.

Padding: Variable length ; last byte contains the padding length

7

Page 8: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

8

TLS Handshake Protocol

• The TLS session state is controlled by the TLS handshake protocol that runs on

top of the TLS record layer. When a TLS client and a TLS server first start

communicating, they agree on a protocol version, select cryptographic algorithms,

optionally authenticate each other, and use public-key encryption techniques to

generate shared secrets.

• The client starts with a ClientHello message to which the server must respond

with a ServerHello message – otherwise a fatal error occurs and the connection

fails. The following attributes are established: Protocol Version, Session ID, Cipher

Suite, and Compression Method. Additionally, two random values are generated

and exchanged ClientHello-Random RC and ServerHello-Random RS.

• Next the server usually sends its X.509 server certificate in an optional Certificate

message. If no certificate is sent, then an optional ServerKeyExchange message

may be sent instead, containing the server part of a Diffie-Hellman (DH) secret.

If the server insists on a client side authentication an optional CertificateRequest

message is appended. The server indicates the end of the server hello phase by

sending a ServerHelloDone message.

• If the server has sent a CertificateRequest message, the client must send either

its X.509 client certificate in a Certificate message or a „no certificate„ alert.

If the client has received a server certificate containing the server„s public RSA

key, the client encrypts a randomly chosen premaster secret with it and sends it

to the server in a ClientKeyExchange message. Alternatively the client can send

its part of a DH key exchange. Each side can now form a shared master secret.

• The client then emits a ChangeCipherSpec message announcing that the new

parameters have been loaded, followed by a Finished message already encrypted

with the new settings. The server does the same on its side.

• The encrypted exchange of application data can now be started.

Source: Stephen Thomas, SSL and TLS Essentials, Wiley Computer Publishing

Page 9: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

9

Resuming a TLS Session

• When the client and server decide to resume a previous session or duplicate an

existing session (instead of negotiating new security parameters) the message flow

is as follows:

• The client sends a ClientHello using the Session ID of the session to be resumed.

The server then checks its session cache for a match. If a match is found, and the

server is willing to re-establish the connection under the specified session state, it

will send a ServerHello with the same Session ID value. Using the cached master

secret and the fresh client hello and server hello nonces, new session key material

is generated. At this point, both client and server must send change cipher spec

messages and proceed directly to the finished messages. Once the re-establishment

is complete, the client and server may begin to exchange application layer data.

If a Session ID match is not found, the server generates a new session ID and the

TLS client and server perform a full handshake.

Source: RFC 2246 – TLS Protocol Version 1.0

Page 10: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

10

Page 11: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

11

BEAST Blog by Thai Duong

• http://vnhacker.blogspot.com/2011/09/beast.html

BEAST vs HTTPS Youtube Demo

• http://www.youtube.com/watch?v=BTqAIDVUvrU

Page 12: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

12

Page 13: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

13

Page 14: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

14

Page 15: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

15

Page 16: 8 Transport Layer Security (SSL/TLS)security.hsr.ch/lectures/Internet_Security_1/08-TLS.pdf · 2011-11-03 · 5 TLS/SSL Protocol Layer • The Secure Sockets Layer (SSL) is inserted

16