3. 原始公钥扩展的结构
3. 原始公钥扩展的结构 (Structure of the Raw Public Key Extension)
本节定义两个 TLS 扩展 client_certificate_type 和 server_certificate_type, 当使用原始公钥时, 这些扩展可作为扩展 TLS 握手的一部分使用. 第 4 节 定义使用这些扩展的 TLS 客户端和 TLS 服务器行为.
本规范使用原始公钥, 即复用 PKIX 证书中已有的 SubjectPublicKeyInfo 结构编码. 为在 TLS 握手中携带原始公钥, Certificate 负载被用作容器, 如 Figure 1 所示. 所示 Certificate 结构是对其原始形式 [RFC5246] 的改编.
opaque ASN.1Cert<1..2^24-1>;
struct {
select(certificate_type){
// certificate type defined in this document.
case RawPublicKey:
opaque ASN.1_subjectPublicKeyInfo<1..2^24-1>;
// X.509 certificate defined in RFC 5246
case X.509:
ASN.1Cert certificate_list<0..2^24-1>;
// Additional certificate type based on
// "TLS Certificate Types" subregistry
};
} Certificate;
Figure 1: 将 Certificate 负载作为原始公钥容器
SubjectPublicKeyInfo 结构在 RFC 5280 [PKIX] 第 4.1 节中定义. 它不仅包含原始密钥, 例如 RSA 公钥的 public exponent 和 modulus, 还包含算法标识符. 算法标识符也可以包含参数. Certificate 负载中的 SubjectPublicKeyInfo 值 MUST 包含 SubjectPublicKeyInfo 的 DER 编码 [X.690]. 因此, 如 Figure 2 所示, 该结构也包含长度信息. Appendix A 提供了示例.
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }
AlgorithmIdentifier ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL }
Figure 2: SubjectPublicKeyInfo ASN.1 结构
算法标识符是对象标识符 (Object Identifiers, OIDs). 例如, RFC 3279 [RFC3279] 和 RFC 5480 [RFC5480] 定义了 Figure 3 中显示的 OID. 注意, 该列表并不完整, 未来 RFC 可能定义更多 OID.
Key Type | Document | OID
--------------------+----------------------------+-------------------
RSA | Section 2.3.1 of RFC 3279 | 1.2.840.113549.1.1
....................|............................|...................
Digital Signature | |
Algorithm (DSA) | Section 2.3.2 of RFC 3279 | 1.2.840.10040.4.1
....................|............................|...................
Elliptic Curve | |
Digital Signature | |
Algorithm (ECDSA) | Section 2 of RFC 5480 | 1.2.840.10045.2.1
--------------------+----------------------------+-------------------
Figure 3: 算法对象标识符示例
使用 "extension_data" 字段的扩展 client hello 和 server hello 扩展格式, 用于携带 ClientCertTypeExtension 和 ServerCertTypeExtension 结构. 这两个结构见 Figure 4. CertificateType 结构是一个 enum, 其值取自 "Transport Layer Security (TLS) Extensions" registry 的 "TLS Certificate Types" subregistry [TLS-Ext-Registry].
struct {
select(ClientOrServerExtension) {
case client:
CertificateType client_certificate_types<1..2^8-1>;
case server:
CertificateType client_certificate_type;
}
} ClientCertTypeExtension;
struct {
select(ClientOrServerExtension) {
case client:
CertificateType server_certificate_types<1..2^8-1>;
case server:
CertificateType server_certificate_type;
}
} ServerCertTypeExtension;
Figure 4: CertTypeExtension 结构