TLS: Cipher Suites

简介


Cipher Suite 在 TLS 中用来指定整个通信过程中所使用的加密相关的参数, 包括如何协商加密得到加密所用的密钥,以及签名使用的算法和哈希算法。

主要涉及到下面几个方面:

Key 交换算法 用户交换一个叫做 Shared key 的私钥。 这里主要使用非对称加密算法(asymmetric key algorithm). 这个key 将作为种子,用来生成多个密钥,生成的密钥将用于保护不同的数据。

因为非堆成加密的特性,它只被用来加密少量的数据。 大量数据的情况下,性能会很低,因此不用它来做大数据量的加密操作。

Bulk encryption 用来加密客户端和服务器的通信数据。 不同与非对称加密算法, 这些算法可以用来进行大量数据的加密,而且性能比非对称加密算法强很多。

Message authentication 算法用来生成 消息的哈希,签名等,用来确保消息的完整性。


TLS 中如何协商 Cipher Suite?


TLS 协议中通过 ClientHello 和 SeverHello 两个包来协商当前链接将要使用的 CipherSuite.

客户端将自己支持的所有 Cipher Suite 的列表,放入 ClientHello 中,发送给服务器端。

服务器端收到 ClientHello 后,从中选择自己也支持的 CipherSuite,然后将选中的结果放在 ServerHello 中发送给客户端。

CipherSuite 列表中,放在最前面的值是客户端最想要的值。

示例


// ClientHello
Transport Layer Security
TLSv1.2 Record Layer: Handshake Protocol: Client Hello
Content Type: Handshake (22)
...
Handshake Protocol: Client Hello
Handshake Type: Client Hello (1)
...
Cipher Suites (18 suites)
Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b)
Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)
Cipher Suite: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 (0x009e)
Cipher Suite: TLS_RSA_WITH_AES_128_GCM_SHA256 (0x009c)
Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xc00a)
Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)
Cipher Suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA (0x0039)
Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA (0x0035)
Cipher Suite: TLS_ECDHE_ECDSA_WITH_RC4_128_SHA (0xc007)
Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA (0xc009)
Cipher Suite: TLS_ECDHE_RSA_WITH_RC4_128_SHA (0xc011)
Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (0xc013)
Cipher Suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA (0x0033)
Cipher Suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA (0x0032)
Cipher Suite: TLS_RSA_WITH_RC4_128_SHA (0x0005)
Cipher Suite: TLS_RSA_WITH_RC4_128_MD5 (0x0004)
Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA (0x002f)
Cipher Suite: TLS_RSA_WITH_3DES_EDE_CBC_SHA (0x000a)
Compression Methods Length: 1
Compression Methods (1 method)
...
// ServerHello
Transport Layer Security
TLSv1.2 Record Layer: Handshake Protocol: Server Hello
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 81
Handshake Protocol: Server Hello
Handshake Type: Server Hello (2)
Length: 77
Version: TLS 1.2 (0x0303)
Random: 8566d75a1...
Session ID Length: 32
Session ID: 51ff379f32....
Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)
Compression Method: null (0)
Extensions Length: 5
Extension: renegotiation_info (len=1)
....

Cipher Suites 示例:


截止 TLS1.2, 已经有特别多的 CipherSuite 可供选择了。 这里,我们列举一些作为例子:

TLS_RSA_WITH_NULL_SHA256

Key Exchange: Rivest Shamir Adleman algorithm (RSA)

Authentication: Rivest Shamir Adleman algorithm (RSA)

**Encryption: **NULL Encryption (NULL)

**Hash: **Secure Hash Algorithm 256 (SHA256)

TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA

Key Exchange: Elliptic Curve Diffie-Hellman Ephemeral (ECDHE)

Authentication: Rivest Shamir Adleman algorithm (RSA)

**Encryption: **Advanced Encryption Standard with 128bit key in Cipher Block Chaining mode (AES 128 CBC)

**Hash: **Secure Hash Algorithm 1 (SHA)

TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384

Key Exchange: Elliptic Curve Diffie-Hellman Ephemeral (ECDHE)

Authentication: Elliptic Curve Digital Signature Algorithm (ECDSA)

**Encryption: **Advanced Encryption Standard with 256bit key in Cipher Block Chaining mode (AES 256 CBC)

**Hash: **Secure Hash Algorithm 384 (SHA384)

TLS_AES_256_GCM_SHA384

Key Exchange: ---

Authentication: ----

**Encryption: **Advanced Encryption Standard with 256bit key in Galois/Counter mode (AES 256 GCM)

**Hash: **Secure Hash Algorithm 384 (SHA384)

TLS_DHE_RSA_WITH_AES_256_CBC_SHA

Key Exchange: Diffie-Hellman Ephemeral (DHE)

Authentication: Rivest Shamir Adleman algorithm (RSA)

**Encryption: **Advanced Encryption Standard with 256bit key in Cipher Block Chaining mode (AES 256 CBC)

**Hash: **Secure Hash Algorithm 1 (SHA)

TLS_DHE_DSS_WITH_AES_256_CBC_SHA

Key Exchange: Diffie-Hellman Ephemeral (DHE)

Authentication: Digital Signature Standard (DSS)

**Encryption: **Advanced Encryption Standard with 256bit key in Cipher Block Chaining mode (AES 256 CBC)

**Hash: **Secure Hash Algorithm 1 (SHA)

TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA

Key Exchange: Diffie-Hellman (DH)

Authentication: Anonymous (anon)

**Encryption: **Data Encryption Standard with 40bit key in Cipher Block Chaining mode (DES40 CBC)

**Hash: **Secure Hash Algorithm 1 (SHA)

TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256

Key Exchange: Elliptic Curve Diffie-Hellman (ECDH)

Authentication: Elliptic Curve Digital Signature Algorithm (ECDSA)

**Encryption: **ARIA with 128bit key in Cipher Block Chaining mode (ARIA 128 CBC)

**Hash: **Secure Hash Algorithm 256 (SHA256)

Published at:
September 28, 2026
Keywords:
TLS
Crypto