1 of 28

SSL/TLS 101

Shih-Chiang Chien

2 of 28

Outline

  • Requirement for network security
  • SSL/TLS
    • Data Encryption / Integrity
    • Key exchange
    • Authentication / Certificate Verification
  • Extensions
    • TLS False Start
    • Session Resumption / Session Tickets
    • Application Layer Protocol Negotiation
    • Server Name Indication
  • Security feature in browser
    • HTTP Strict Transport Security
    • HTTP Public Key Pinning
    • CSP for enforcing HTTPS

3 of 28

Requirement for network security

  • Encryption
    • A mechanism to obfuscate what is sent from one host to another.
    • Only Alice can decrypt the message from Bob, not the eavesdropper.
  • Authentication
    • A mechanism to verify the validity of provided identification material.
    • Alice can make sure the received message is from Bob, not someone else.
  • Integrity
    • A mechanism to detect message tampering and forgery.
    • Alice can ensure the received message from Bob is not modified by someone else.

4 of 28

What is SSL/TLS

  • SSL and TLS are cryptographic protocols that provide communications security over a computer network.
  • The SSL protocol was originally developed at Netscape to enable e-commerce transaction security on the Web
  • When the SSL protocol was standardized by the IETF, it was renamed to Transport Layer Security (TLS)

5 of 28

History of SSL/TLS

  • SSL
    • Was proprietary to Netscape
    • SSL 1.0 was never publicly released because of serious security flaws in the protocol
    • SSL 2.0 was released in 1995 as the first publicly released version of the protocol
    • SSL 3.0 was released in 1996 due to a number of discovered security flaws in 2.0
  • TLS
    • IETF formed an effort to standardize the protocol, which based on SSL 3.0
    • TLS 1.0 (RFC 2246) was published in 1999
    • TLS 1.1 (RFC 4346) was published in 2006
    • TLS 1.2 (RFC 5246) was published in 2008
    • TLS 1.3 is still a working draft

6 of 28

TLS Record Protocol

Uninterpreted data from higher layers in non-empty blocks of arbitrary size.

  • Fragmentation
    • < 2^14 bytes
    • same content type may be coalesced into a single record
    • Data of different content type may be interleaved, but the order within the same type is guaranteed
  • Compression / Decompression (optional)
  • Encryption and MAC

7 of 28

Data Encryption

  • Symmetric cryptography
    • If both Alice and Bob keep a shared key and a shared cipher function…
  • Blocked Cipher
    • DES
    • 3DES
    • AES
  • Stream Cipher
    • RC4

8 of 28

Data Integrity

  • Keyed Message Authentication Code (MAC)
    • If both Alice and Bob keep a shared key and a shared hash function…
  • MAC is generated by
    • Hash of message
    • Shared key
    • Sequence number

9 of 28

TLS Handshake protocol

  • This protocol allows the server and client to
    • negotiate an encryption and MAC algorithm
    • authenticate each other
    • agree cryptographic keys to be used to protect payload data
  • The handshake protocol is used before any application data is transmitted.
  • It establishes a session.
    • A session defines the set of cryptographic security parameters to be used
    • Multiple secure connections between client and server can share the same session
      • reduces computation cost

10 of 28

Establish Security Capabilities

  • ClientHello
    • cryptographic algorithms supported by the client
    • in decreasing order of preference
    • May carry requested extension
    • May carry session id for resumption
  • ServerHello
    • assigns a session id
    • selects the CipherSpec
    • selects the Key exchange method (RSA or DH)

11 of 28

Key Exchange

  • To obtain pre_master_secret
  • Certificate (from server)
  • ServerKeyExchange
    • Depends on the exchange method
    • ServerHelloDone is sent if appropriate cipher suite selected
  • ServerHelloDone
  • Certificate (from client)
    • Only send if server requested
  • ClientKeyExchange
    • Depends on the public key algorithm

12 of 28

RSA

  • a 48-byte pre_master_secret is generated by the client
    • Client protocol version + 46-byte random
  • encrypted under the server's public key and sent to the server
  • server uses its private key to decrypt the pre_master_secret

​

13 of 28

Diffie-Hellman

  • Server provider following ServerDHParams
    • dh_p: The prime modulus used for the Diffie-Hellman operation.
    • dh_g: The generator used for the Diffie-Hellman operation.
    • dh_Ys: The server's Diffie-Hellman public value (g^X mod p).
    • Signature is required for non-anonymous key exchanges
  • Client compute following ClientDiffieHellmanPublic
    • dh_Yc: The client's Diffie-Hellman public value (Yc).
  • The negotiated key (Z) is used as the pre_master_secret

​

​

14 of 28

Key Calculation

master_secret = PRF(pre_master_secret,� "master secret",� client_random + server_random)� [0..47];�key_block = PRF(master_secret,� "key expansion",� server_random + client_random);

  • Iteratively generate key_block until enough output has been generated
  • key_block is partitioned as follows:
    • client_write_MAC_key[mac_key_length]
    • server_write_MAC_key[mac_key_length]
    • client_write_key[enc_key_length]
    • server_write_key[enc_key_length]
    • client_write_IV[fixed_iv_length]
    • server_write_IV[fixed_iv_length]

15 of 28

Perfect Forward Secrecy

  • the compromise of long-term keys (e.g. server’s private key) does not compromise past session keys and does not allow the attacker to decrypt previously recorded sessions

16 of 28

Authentication

  • Chain of Trust

​

​

  • Certificate Authorities

17 of 28

Certificate Validation

  • Certificate Revocation List (CRL)
    • RFC 5280
    • Each certificate authority maintains and periodically publishes a list of revoked certificate serial numbers
    • Client download the revocation list, cache it
  • Online Certificate Status Protocol (OCSP)
    • RFC 2560
    • Perform a real-time check for status of the certificate to CA’s certificate database
  • OCSP Stapling
    • RFC 6066
    • Server piggyback the certificate status in TLS handshake

18 of 28

Change Cipher Spec Protocol

  • For synchronizing the timing that encryption started
  • sent by both the client and the server to notify the receiving party that subsequent records will be protected under the newly negotiated CipherSpec and keys.
  • A Finished message is always sent immediately after a change cipher spec message to verify that the key exchange and authentication processes were successful
    • verify_data = PRF(master_secret, finished_label, Hash(handshake_messages))� [0..verify_data_length-1];
    • finished_label
      • "client finished" if sent by the client; "server finished" if sent by the server.
    • handshake_messages
      • All of the data from all messages in this handshake, at the handshake layer

​

​

19 of 28

Alert Protocol

  • convey the severity of the message (warning or fatal)

enum { close_notify(0), unexpected_message(10), bad_record_mac(20),� decryption_failed_RESERVED(21), record_overflow(22),� decompression_failure(30), handshake_failure(40),� no_certificate_RESERVED(41), bad_certificate(42),� unsupported_certificate(43), certificate_revoked(44),� certificate_expired(45), certificate_unknown(46),� illegal_parameter(47), unknown_ca(48), access_denied(49),� decode_error(50), decrypt_error(51), export_restriction_RESERVED(60),� protocol_version(70), insufficient_security(71),� internal_error(80), user_canceled(90), no_renegotiation(100),� unsupported_extension(110), (255)�} AlertDescription;

​

20 of 28

TLS False Start

  • To reduce delay for Finished verification
  • Try send application data right after ChangeCipherSpec
  • Usage is limited due to server compatibility and security attack

21 of 28

Session Resumption

  • RFC 5246
  • client include the session ID in the ClientHello
  • Server can decide to skip the key exchange procedure if server is able to find the associated session parameters

22 of 28

Session Ticket

  • RFC 5077
  • Reduce server resource on keeping session state
  • Server encrypt session state and send to client via ServerHello
  • Client can include this in next ClientHello

23 of 28

Application Layer Protocol Negotiation (ALPN)

  • RFC 7301
  • To reduce the delay for negotiating an application protocol on port 443
  • ClientHello contains a list of protocols advertised by the client, in descending order of preference
  • ServerHello must contain exactly one "ProtocolName“ representing the selected protocol

24 of 28

Server Name Indication (SNI)

  • RFC 3546
  • To support host multiple independent sites, each with its own TLS certificate, on the same IP address.
  • Client include SNI hostname in the ClientHello
  • Server select the associated certificate for that SNI hostname

25 of 28

HTTP Strict Transport Security

  • RFC 6797
  • To prevent MITM attack via redirecting HTTP to HTTPS
  • security policy mechanism in HTTP header
    • Strict-Transport-Security: max-age=expireTime [; includeSubDomains] [; preload]
  • All requests to the origin should be sent over HTTPS
  • User is not allowed to circumvent the warning and request the HTTP version
  • max-age specifies the lifetime of the specified HSTS ruleset in seconds
  • includeSubdomains indicates that the policy should apply to all subdomains of the current origin

26 of 28

HTTP Public Key Pinning

  • RFC 7469
  • To prevent MITM attacks with forged certificates
    • Public-Key-Pins: pin-sha256="base64=="; max-age=expireTime [; includeSubDomains][; report-uri="reportURI"]
  • Trust on First Use
  • Server tells client the signature of the correct public key
  • Client need to validate the public key get from future TLS handshake

27 of 28

CSP for enforcing HTTPS

  • W3C Upgrade Insecure Requests
  • To instruct a user agent to upgrade a priori insecure resource requests to secure transport before fetching them
    • Content-Security-Policy: upgrade-insecure-requests
  • To reduce the burden of migrating websites from a priori insecure origins
  • All internal links will be forced to use HTTPS

28 of 28

References