有人可以解释 RFC 5280 中的“第 4.2.1.3 节。密钥用法”扩展,因为它与 TLS 1.2 RFC 5246 相关

信息安全 tls 证书
2021-09-04 08:21:34

TLS 1.2 RFC 5246 中有关于使用证书(服务器和客户端)的参考。我不清楚证书的“密钥使用”扩展,因为它与 TLS 1.2 相关,并且也仅用于数据加密。我不担心 CA 自己使用 TLS。以下是各种密钥使用类型:

 KeyUsage ::= BIT STRING {
       digitalSignature        (0),
       nonRepudiation          (1), -- recent editions of X.509 have
                            -- renamed this bit to contentCommitment
       keyEncipherment         (2),
       dataEncipherment        (3),
       keyAgreement            (4),
       keyCertSign             (5),
       cRLSign                 (6),
       encipherOnly            (7),
       decipherOnly            (8) }

显然 dataEncipherment 在 TLS 1.2 中没有任何作用。有人可以提供在 TLS 1.2 中发挥作用的密钥扩展和一两句话解释该密钥扩展的证书的具体用法吗?

在 TLS 1.2 RFC 中提到了其中一些扩展(例如在第 7.4.2 节中)。但对于我在这方面的知识水平来说,它太简短了。

1个回答

好问题!我不知道这是否有明确的来源,所以我将根据 RFC 做出有根据的猜测。

TL;DR:TLS 1.2 支持以下keyUsage位用于最终实体证书:

   digitalSignature        (0),
   keyEncipherment         (2),
   keyAgreement            (4),

现在让我们keyUsage一次过一个:

电子签名

 KeyUsage ::= BIT STRING {
   digitalSignature        (0),

这个很明显,这是普通的 RSA 或 ECC 证书认证。

不可否认性

   nonRepudiation          (1), -- recent editions of X.509 have
                        -- renamed this bit to contentCommitment

这通常用于具有法律约束力的签名,例如 eIDAS。我无法想象你会把它放在 TLS 证书上。

密钥加密

   keyEncipherment         (2),

这将对应于具有 RSA 密钥传输的 TLS 密码套件,例如TLS_RSA_WITH_AES_256_GCM_SHA384.

来自 RFC 5246 (TLS1.2) 第 7.4.2 节服务器证书:

RSA                RSA public key; the certificate MUST allow the
RSA_PSK            key to be used for encryption (the
                     keyEncipherment bit MUST be set if the key
                     usage extension is present).
                     Note: RSA_PSK is defined in [TLSPSK].

数据加密

   dataEncipherment        (3),

我认为这在 TLS 中没有用处。

关键协议

   keyAgreement            (4),

当您在证书中有 Diffie-Hellman 密钥时使用此选项。这绝对不像以前那么常见了,人们更喜欢临时版本——DHE 和 ECDHE——但 TLS 1.2 确实支持它与TLS_DH_RSA_WITH_AES_256_GCM_SHA384.

来自 RFC 5246 (TLS1.2) 第 7.4.2 节服务器证书:

DH_DSS             Diffie-Hellman public key; the keyAgreement bit
DH_RSA             MUST be set if the key usage extension is present.

keyCertSign 和 cRLSign

   keyCertSign             (5),

来自 RFC 5280 (X.509) 第 4.2.1.3 节。关键用途:

The keyCertSign bit is asserted when the subject public key is
  used for verifying signatures on public key certificates.  If the
  keyCertSign bit is asserted, then the cA bit in the basic
  constraints extension (Section 4.2.1.9) MUST also be asserted.

您不(或至少,真的不应该)直接将 CA 证书用于 TLS,因此我不希望在 TLS 证书上看到此密钥用法。

相似地:

   cRLSign                 (6),

来自 RFC 5280 (X.509) 第 4.2.1.3 节。关键用途:

The cRLSign bit is asserted when the subject public key is used
  for verifying signatures on certificate revocation lists (e.g.,
  CRLs, delta CRLs, or ARLs).

因此,您不应该在 TLS 证书上看到该密钥用法。

仅加密和仅解密

   encipherOnly            (7),
   decipherOnly            (8) }

来自 RFC 5280 (X.509) 第 4.2.1.3 节。关键用途:

The meaning of the encipherOnly bit is undefined in the absence of
  the keyAgreement bit.  When the encipherOnly bit is asserted and
  the keyAgreement bit is also set, the subject public key may be
  used only for enciphering data while performing key agreement.

 The meaning of the decipherOnly bit is undefined in the absence of
  the keyAgreement bit.  When the decipherOnly bit is asserted and
  the keyAgreement bit is also set, the subject public key may be
  used only for deciphering data while performing key agreement.

这些术语没有出现在 RFC 5246 中,所以我不认为 TLS 服务器/客户端会知道如何处理它们,即使它们存在