SSL and TLS

Secure Sockets Layer (SSL) was designed by Netscape in the 1990s and has been replaced by Transport Layer Security (TLS). SSL 2.0 and 3.0 and TLS 1.0 and 1.1 are obsolete and unsafe; TLS 1.2 and 1.3 are in use (TLS 1.3 was published in 2018). TLS sits above TCP and gives confidentiality (symmetric encryption), integrity (message authentication) and server authentication (certificates), with optional client authentication. HTTPS is HTTP over TLS (port 443).

The TLS Handshake

  1. ClientHello: the client sends supported versions, cipher suites and a random number.
  2. ServerHello and certificate: the server selects a cipher suite and sends its certificate and random number.
  3. The client verifies the certificate (trusted CA, validity, name).
  4. Key exchange: the two sides agree on a shared secret, using Diffie-Hellman (ephemeral keys, which give forward secrecy) or, in older versions, RSA encryption of a pre-master secret.
  5. Session keys are derived, and both sides send Finished messages to confirm.
  6. Application data is then protected with a symmetric cipher such as AES-GCM.

TLS 1.3 completes this in one round trip (TLS 1.2 needs two) and removes weak options.

SSH

Secure Shell (SSH) gives encrypted remote login and command execution (port 22), replacing Telnet and rlogin. It authenticates the server with a host key (the client keeps a list of known hosts) and the user with a password or, better, a public/private key pair. It can also forward ports (tunnelling) and transfer files with SCP.

SFTP

The SSH File Transfer Protocol (SFTP) transfers and manages files over an SSH connection (port 22), so commands, data and passwords are encrypted. It is not the same as FTPS, which is the older FTP protocol protected by TLS. Plain FTP and Telnet send passwords in clear text and must not be used on open networks.

Definition: TLS. Transport Layer Security, a protocol that provides an encrypted, authenticated and integrity-protected channel between two applications over a network, and is the basis of HTTPS.

Table 3.2: Secure protocols

Protocol Port Protects Replaces
HTTPS (TLS) 443 Web traffic HTTP
SSH 22 Remote login, tunnels Telnet
SFTP 22 File transfer over SSH FTP
FTPS 990 or 21 FTP over TLS FTP

Example 3.2: Latency of the TLS handshake

Problem: The round-trip time (RTT) to a server is 50 ms. A browser needs 1 RTT for the TCP connection, then the TLS handshake. Find the time before the first request can be sent for TLS 1.2 (2 RTT), TLS 1.3 (1 RTT), and a TLS 1.3 session resumed on an existing server (TCP only plus 0-RTT data). Ignore processing time.

Solution:

  1. TLS 1.2: 1 (TCP) + 2 (TLS) = 3 RTT = 3 × 50 = 150 ms.
  2. TLS 1.3: 1 + 1 = 2 RTT = 100 ms.
  3. TLS 1.3 with 0-RTT resumption: 1 RTT (TCP only) = 50 ms, since data goes with the first TLS message.

Result: 150 ms, 100 ms and 50 ms. Newer TLS versions are both safer and faster. (0-RTT data can be replayed, so it is used only for safe requests.)

rtt = 50
print("TLS 1.2 (ms):", (1 + 2) * rtt)
print("TLS 1.3 (ms):", (1 + 1) * rtt)
print("TLS 1.3 resumed 0-RTT (ms):", 1 * rtt)

Output

TLS 1.2 (ms): 150
TLS 1.3 (ms): 100
TLS 1.3 resumed 0-RTT (ms): 50

Common mistakes

  • Using old SSL or TLS 1.0 and 1.1 versions.
  • Ignoring certificate warnings.
  • Confusing SFTP (over SSH) with FTPS (FTP over TLS).
  • Using password login for SSH on internet-facing servers instead of keys.

Key takeaways

  • TLS: confidentiality, integrity, server authentication; HTTPS on 443.
  • Handshake: hello, certificate, key exchange, Finished, encrypted data.
  • TLS 1.3 needs one round trip and gives forward secrecy.
  • SSH and SFTP use port 22; Telnet and FTP are insecure.

Practice questions

  1. What does TLS provide?
  2. Which port does SSH use?
  3. How does SFTP differ from FTPS?

Answers to the practice questions

  1. Confidentiality, integrity and server authentication for a connection.
  2. Port 22.
  3. SFTP runs over SSH; FTPS is FTP protected by TLS.

Sources

  • Official BCA syllabus Computer Security, course code 25BCA406DS02, Unit III