lep442 发表于 2011-12-20 09:47

TLS1.1-握手协议

<DIV>RFC4346中的内容, 摘取了我认为比较重要的部分,做个备忘.</DIV>
<DIV>&nbsp;</DIV>
<DIV>0. Variants</DIV>
<DIV>&nbsp;&nbsp; Defined structures may have variants based on some knowledge that is<BR>&nbsp;&nbsp; available within the environment.&nbsp; The selector must be an enumerated<BR>&nbsp;&nbsp; type that defines the possible variants the structure defines.&nbsp; There<BR>&nbsp;&nbsp; must be a case arm for every element of the enumeration declared in<BR>&nbsp;&nbsp; the select.&nbsp; The body of the variant structure may be given a label<BR>&nbsp;&nbsp; for reference.&nbsp; The mechanism by which the variant is selected at<BR>&nbsp;&nbsp; runtime is not prescribed by the presentation language.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T1 f1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T2 f2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tn fn;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (E) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case e1: Te1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case e2: Te2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case en: Ten;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } [];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } [];</DIV>
<DIV>&nbsp;&nbsp; For example:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum { apple, orange } VariantTag;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint16 number;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque string&lt;0..10&gt;; /* variable length */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } V1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32 number;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque string;&nbsp;&nbsp;&nbsp; /* fixed length */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } V2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (VariantTag) { /* value of selector is implicit */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case apple: V1;&nbsp;&nbsp; /* VariantBody, tag = apple */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case orange: V2;&nbsp; /* VariantBody, tag = orange */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } variant_body;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* optional label on variant */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } VariantRecord;</DIV>
<DIV>&nbsp;&nbsp; Variant structures may be qualified (narrowed) by specifying a value<BR>&nbsp;&nbsp; for the selector prior to the type.&nbsp; For example, an</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; orange VariantRecord</DIV>
<DIV>&nbsp;&nbsp; is a narrowed type of a VariantRecord containing a variant_body of<BR>&nbsp;&nbsp; type V2.</DIV>
<DIV>&nbsp;</DIV>
<DIV>1. RECORD LAYER PROTOCOL:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint8 major, minor;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ProtocolVersion;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; change_cipher_spec(20), alert(21), handshake(22),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; application_data(23), (255)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ContentType;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ContentType type;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProtocolVersion version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint16 length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque fragment;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } TLSPlaintext;</DIV>
<DIV>1.1 HANDSHAKE FLOW:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Client&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Server</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientHello&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerHello<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Certificate*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerKeyExchange*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CertificateRequest*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerHelloDone<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Certificate*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientKeyExchange<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CertificateVerify*<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finished&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finished<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application Data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-------&gt;&nbsp;&nbsp;&nbsp;&nbsp; Application Data</DIV>
<DIV><BR>1.2 HANDSHAKE PROTOCAL:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hello_request(0), client_hello(1), server_hello(2),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate(11), server_key_exchange (12),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate_request(13), server_hello_done(14),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate_verify(15), client_key_exchange(16),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finished(20), (255)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } HandshakeType;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HandshakeType msg_type;&nbsp;&nbsp;&nbsp; /* handshake type */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint24 length;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* bytes in message */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (HandshakeType) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case hello_request:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HelloRequest;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case client_hello:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientHello;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case server_hello:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerHello;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case certificate:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Certificate;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case server_key_exchange: ServerKeyExchange;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case certificate_request: CertificateRequest;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case server_hello_done:&nbsp;&nbsp; ServerHelloDone;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case certificate_verify:&nbsp; CertificateVerify;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case client_key_exchange: ClientKeyExchange;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case finished:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finished;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } body;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Handshake;</DIV>
<DIV>&nbsp;</DIV>
<DIV>1.2.1 CLIENT_HELLO:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32 gmt_unix_time;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque random_bytes;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Random;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque SessionID&lt;0..32&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint8 CipherSuite;&nbsp;&nbsp;&nbsp; /* Cryptographic suite selector */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum { null(0), (255) } CompressionMethod;</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProtocolVersion client_version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Random random;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SessionID session_id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CipherSuite cipher_suites&lt;2..2^16-1&gt;; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CompressionMethod compression_methods&lt;1..2^8-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ClientHello;</DIV>
<DIV>&nbsp;&nbsp; 关于客户端的cipher_suites,重要:<BR>&nbsp;&nbsp; cipher_suites<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is a list of the cryptographic options supported by the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client, with the client's first preference first.&nbsp; If the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session_id field is not empty (implying a session resumption<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request) this vector MUST include at least the cipher_suite from<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; that session.&nbsp; Values are defined in Appendix A.5.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Each CipherSuite defines a key exchange algorithm, a bulk encryption <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; algorithm (including secret key length), and a MAC algorithm.&nbsp; </DIV>
<DIV><BR>1.2.2 SERVER_HELLO:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProtocolVersion server_version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Random random;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SessionID session_id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CipherSuite cipher_suite;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CompressionMethod compression_method;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ServerHello;</DIV>
<DIV>&nbsp;&nbsp; 关于session_id的说明, 涉及复用:<BR>&nbsp;&nbsp; session_id<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is the identity of the session corresponding to this<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.&nbsp; If the ClientHello.session_id was non-empty, the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server will look in its session cache for a match.&nbsp; If a match is<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; found and the server is willing to establish the new connection<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using the specified session state, the server will respond with<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the same value as was supplied by the client.&nbsp; This indicates a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resumed session and dictates that the parties must proceed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; directly to the finished messages.&nbsp; Otherwise this field will<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contain a different value identifying the new session.&nbsp; The server<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; may return an empty session_id to indicate that the session will<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not be cached and therefore cannot be resumed.&nbsp; If a session is<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resumed, it must be resumed using the same cipher suite it was<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; originally negotiated with.<BR>&nbsp;&nbsp; cipher_suite的说明:<BR>&nbsp;&nbsp; cipher_suite<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The single cipher suite selected by the server from the list in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientHello.cipher_suites.&nbsp; For resumed sessions, this field is<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the value from the state of the session being resumed.</DIV>
<DIV>1.2.3 Server Certificate:<BR>&nbsp;&nbsp; 消息类型(需要查看x509v3的rfc: RFC3280):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque ASN.1Cert&lt;1..2^24-1&gt;;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASN.1Cert certificate_list&lt;0..2^24-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Certificate;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; 关于服务端证书的一些说明:<BR>&nbsp;&nbsp; When this message will be sent:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The server MUST send a certificate whenever the agreed-upon key<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exchange method is not an anonymous one.&nbsp; This message will always<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; immediately follow the server hello message.</DIV>
<DIV>&nbsp;&nbsp; Meaning of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The certificate type MUST be appropriate for the selected cipher<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; suite's key exchange algorithm, and is generally an X.509v3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate.&nbsp; It MUST contain a key that matches the key exchange<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; method, as follows.&nbsp; Unless otherwise specified, the signing<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; algorithm for the certificate MUST be the same as the algorithm<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for the certificate key.&nbsp; Unless otherwise specified, the public<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key MAY be of any length.</DIV>
<DIV>&nbsp;&nbsp; 密钥交换算法的证书密钥类型:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Key Exchange Algorithm&nbsp; Certificate Key Type</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RSA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RSA public key; the certificate MUST<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; allow the key to be used for encryption.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DHE_DSS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DSS public key.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DHE_RSA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RSA public key that can be used for<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signing.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DH_DSS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Diffie-Hellman key. The algorithm used<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to sign the certificate MUST be DSS.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DH_RSA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Diffie-Hellman key. The algorithm used<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to sign the certificate MUST be RSA.</DIV>
<DIV>&nbsp;&nbsp; All certificate profiles and key and cryptographic formats are<BR>&nbsp;&nbsp; defined by the IETF PKIX working group .&nbsp; When a key usage<BR>&nbsp;&nbsp; extension is present, the digitalSignature bit MUST be set for the<BR>&nbsp;&nbsp; key to be eligible for signing, as described above, and the<BR>&nbsp;&nbsp; keyEncipherment bit MUST be present to allow encryption, as described<BR>&nbsp;&nbsp; above.&nbsp; The keyAgreement bit must be set on Diffie-Hellman<BR>&nbsp;&nbsp; certificates.</DIV>
<DIV><BR>&nbsp;&nbsp; 关于证书链的说明:<BR>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque ASN.1Cert&lt;1..2^24-1&gt;;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASN.1Cert certificate_list&lt;0..2^24-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Certificate;</DIV>
<DIV>&nbsp;&nbsp; certificate_list<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is a sequence (chain) of X.509v3 certificates.&nbsp; The sender's<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate must come first in the list.&nbsp; Each following<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate must directly certify the one preceding it.&nbsp; Because<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate validation requires that root keys be distributed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; independently, the self-signed certificate that specifies the root<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate authority may optionally be omitted from the chain,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; under the assumption that the remote end must already possess it<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in order to validate it in any case.</DIV>
<DIV>1.2.4 Server Key Exchange Message:<BR>&nbsp;&nbsp; 这个需要看下DH交换和RSA交换的RFC,以便理解发送的参数:</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum { rsa, diffie_hellman } KeyExchangeAlgorithm;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque rsa_modulus&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque rsa_exponent&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ServerRSAParams;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rsa_modulus<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The modulus of the server's temporary RSA key.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rsa_exponent<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The public exponent of the server's temporary RSA key.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque dh_p&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque dh_g&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque dh_Ys&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ServerDHParams;&nbsp;&nbsp;&nbsp;&nbsp; /* Ephemeral DH parameters */</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dh_p<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The prime modulus used for the Diffie-Hellman operation.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dh_g<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The generator used for the Diffie-Hellman operation.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dh_Ys<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The server's Diffie-Hellman public value (g^X mod p).</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (KeyExchangeAlgorithm) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case diffie_hellman:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerDHParams params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Signature signed_params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case rsa:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerRSAParams params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Signature signed_params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ServerKeyExchange;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (KeyExchangeAlgorithm) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case diffie_hellman:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerDHParams params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case rsa:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerRSAParams params;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ServerParams;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; params<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The server's key exchange parameters.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signed_params<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For non-anonymous key exchanges, a hash of the corresponding<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; params value, with the signature appropriate to that hash<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; applied.</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; md5_hash<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MD5(ClientHello.random + ServerHello.random + ServerParams);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sha_hash<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SHA(ClientHello.random + ServerHello.random + ServerParams);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum { anonymous, rsa, dsa } SignatureAlgorithm;</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (SignatureAlgorithm) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case anonymous: struct { };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case rsa:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitally-signed struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque md5_hash;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque sha_hash;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case dsa:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; digitally-signed struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque sha_hash;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Signature;</DIV>
<DIV>1.2.5 Certificate request:<BR>&nbsp;&nbsp; When this message will be sent:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A non-anonymous server can optionally request a certificate from<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the client, if it is appropriate for the selected cipher suite.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This message, if sent, will immediately follow the Server Key<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exchange message (if it is sent; otherwise, the Server Certificate<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message).</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fortezza_dms_RESERVED(20), (255)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ClientCertificateType; </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque DistinguishedName&lt;1..2^16-1&gt;;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientCertificateType certificate_types&lt;1..2^8-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DistinguishedName certificate_authorities&lt;0..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } CertificateRequest;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate_types<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This field is a list of the types of certificates requested,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sorted in order of the server's preference.<BR>&nbsp; Values from 0 (zero) through 63 decimal (0x3F) inclusive are<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reserved for IETF Standards Track protocols.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate_authorities<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A list of the distinguished names of acceptable certificate<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorities.&nbsp; These distinguished names may specify a desired<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; distinguished name for a root CA or for a subordinate CA; thus,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this message can be used to describe both known roots and a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; desired authorization space.&nbsp; If the certificate_authorities<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list is empty then the client MAY send any certificate of the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appropriate ClientCertificateType, unless there is some<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; external arrangement to the contrary.</DIV>
<DIV>&nbsp;&nbsp; Note: It is a fatal handshake_failure alert for an anonymous server<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to request client authentication.</DIV>
<DIV><BR>1.2.6 Server Hello Done<BR>&nbsp;&nbsp; 服务端发送这个消息表示server hello阶段的结束. 服务端发送此消息后将会<BR>&nbsp;&nbsp; 等待客户端的回应.此消息意味着服务端支持key exchange的消息发送完毕,<BR>&nbsp;&nbsp; 客户端可以继续它自己的key exchange的阶段.收到服务端的这个消息,客户端<BR>&nbsp;&nbsp; SHOULD确认服务端提供了一个有效的证书(如果需要)并且检查server hello的<BR>&nbsp;&nbsp; 参数是可接受的.<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct { } ServerHelloDone;</DIV>
<DIV>1.2.7 Client certificate<BR>&nbsp;&nbsp; When this message will be sent:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这是客户端收到server_hello_done之后发送的第一个消息.客户端发送此消<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 息只有服务端发送了certificate_request消息时. 如果无可用证书,客户端<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SHOULD发送一个不包含证书的证书消息.也就是length为0的certificate_list<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结构.如果服务端对于客户端验证时require的,那将会导致一个fatal <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handshake failure alert.</DIV>
<DIV>&nbsp;&nbsp; Note: When using a static Diffie-Hellman based key exchange method<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (DH_DSS or DH_RSA), if client authentication is requested, the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Diffie-Hellman group and generator encoded in the client's<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate MUST match the server specified Diffie-Hellman<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameters if the client's parameters are to be used for the key<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exchange.</DIV>
<DIV>1.2.8 Client Key Exchange Message:<BR>&nbsp;&nbsp; When this message will be sent:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 由客户端发送,且MUST紧跟client certificate message(如果发送),否则<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 就作为收到server hello done之后的第一个消息.</DIV>
<DIV>&nbsp;&nbsp; Meaning of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With this message, the premaster secret is set, either though<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; direct transmission of the RSA-encrypted secret or by the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transmission of Diffie-Hellman parameters that will allow each<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; side to agree upon the same premaster secret.&nbsp; When the key<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exchange method is DH_RSA or DH_DSS, client certification has been<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; requested, and the client was able to respond with a certificate<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; that contained a Diffie-Hellman public key whose parameters (group<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and generator) matched those specified by the server in its<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate, this message MUST not contain any data.</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The choice of messages depends on which key exchange method has<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; been selected.&nbsp; See Section 1.2.4 for the KeyExchangeAlgorithm<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; definition.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (KeyExchangeAlgorithm) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case rsa: EncryptedPreMasterSecret;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case diffie_hellman: ClientDiffieHellmanPublic;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } exchange_keys;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ClientKeyExchange;</DIV>
<DIV>1.2.8.1 RSA Encrypted Premaster Secret Message<BR>&nbsp; Meaning of this message:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If RSA is being used for key agreement and authentication, the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client generates a 48-byte premaster secret, encrypts it using the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public key from the server's certificate or the temporary RSA key<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provided in a server key exchange message, and sends the result in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; an encrypted premaster secret message.&nbsp; This structure is a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; variant of the client key exchange message and is not a message in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itself.</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProtocolVersion client_version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque random;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } PreMasterSecret;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client_version The latest (newest) version supported by the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.&nbsp; This is used to detect version roll-back attacks.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Upon receiving the premaster secret, the server SHOULD check<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; that this value matches the value transmitted by the client in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the client hello message.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; random<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 46 securely-generated random bytes.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public-key-encrypted PreMasterSecret pre_master_secret;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } EncryptedPreMasterSecret;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pre_master_secret<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This random value is generated by the client and is used to<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; generate the master secret.</DIV>
<DIV>1.2.8.2 Client Diffie-Hellman Public Value<BR>&nbsp;&nbsp; Meaning of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This structure conveys the client's Diffie-Hellman public value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Yc) if it was not already included in the client's certificate.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The encoding used for Yc is determined by the enumerated<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PublicValueEncoding.&nbsp; 这个是一个变体,不是消息本身.</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum { implicit, explicit } PublicValueEncoding;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; implicit<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If the client certificate already contains a suitable Diffie-<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hellman key, then Yc is implicit and does not need to be sent<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; again.&nbsp; In this case, the client key exchange message will be<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sent, but it MUST be empty.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; explicit<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Yc needs to be sent.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (PublicValueEncoding) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case implicit: struct { };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case explicit: opaque dh_Yc&lt;1..2^16-1&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } dh_public;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ClientDiffieHellmanPublic;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dh_Yc<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The client's Diffie-Hellman public value (Yc).</DIV>
<DIV>1.2.9 Certificate verify<BR>&nbsp;&nbsp; When this message will be sent:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This message is used to provide explicit verification of a client<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate.When<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sent, it MUST immediately follow the client key exchange message.</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Signature signature;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } CertificateVerify;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The Signature type is defined in 1.2.4.</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CertificateVerify.signature.md5_hash<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MD5(handshake_messages);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CertificateVerify.signature.sha_hash<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SHA(handshake_messages);</DIV>
<DIV>&nbsp;&nbsp; Here handshake_messages refers to all handshake messages sent or<BR>&nbsp;&nbsp; received starting at client hello up to but not including this<BR>&nbsp;&nbsp; message, including the type and length fields of the handshake<BR>&nbsp;&nbsp; messages. </DIV>
<DIV>1.2.10 Finished(密文的,抓包看不到的)<BR>&nbsp;&nbsp; When this message will be sent:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A finished message is always sent immediately after a change<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cipher spec message to verify that the key exchange and<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authentication processes were successful.&nbsp; It is essential that a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; change cipher spec message be received between the other handshake<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; messages and the Finished message.(中间的change cipher spec是必要的)</DIV>
<DIV>&nbsp;&nbsp; Meaning of this message:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The finished message is the first protected with the just-<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; negotiated algorithms, keys, and secrets.&nbsp; Recipients of finished<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; messages MUST verify that the contents are correct.&nbsp; Once a side<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; has sent its Finished message and received and validated the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finished message from its peer, it may begin to send and receive<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; application data over the connection.</DIV>
<DIV>&nbsp;&nbsp; Structure of this message:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opaque verify_data;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } Finished;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; verify_data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PRF(master_secret, finished_label, MD5(handshake_messages) +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SHA-1(handshake_messages)) ;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finished_label<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Finished messages sent by the client, the string "client<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finished".&nbsp; For Finished messages sent by the server, the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string "server finished".</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handshake_messages<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; All of the data from all messages in this handshake (not<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; including any HelloRequest messages) up to but not including<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this message.&nbsp; This is only data visible at the handshake<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layer and does not include record layer headers.&nbsp; This is the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; concatenation of all the Handshake structures, as defined in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7.4, exchanged thus far.</DIV>
<DIV>2 Cryptographic Computations<BR>&nbsp;&nbsp; 为了保护连接, TLS的记录层需要一组算法,主密钥,服务端和客户端随机数的<BR>&nbsp;&nbsp; 详细说明. authentication, encryption, and MAC algorithms由服务端选择<BR>&nbsp;&nbsp; 的cipher_suite决定,并在server hello消息中指明.压缩算法在hello消息中<BR>&nbsp;&nbsp; 协商.所有上述这些都用作计算主密钥.</DIV>
<DIV>2.1. Computing the Master Secret<BR>&nbsp;&nbsp; For all key exchange methods, the same algorithm is used to convert<BR>&nbsp;&nbsp; the pre_master_secret into the master_secret.&nbsp; The pre_master_secret<BR>&nbsp;&nbsp; should be deleted from memory once the master_secret has been<BR>&nbsp;&nbsp; computed.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; master_secret = PRF(pre_master_secret, "master secret",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientHello.random + ServerHello.random)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;</DIV>
<DIV>&nbsp;&nbsp; The master secret is always exactly 48 bytes in length.&nbsp; The length<BR>&nbsp;&nbsp; of the premaster secret will vary depending on key exchange method.</DIV>
<DIV>&nbsp;</DIV>
<DIV>2.1.1. RSA</DIV>
<DIV>&nbsp;&nbsp; When RSA is used for server authentication and key exchange, a 48-<BR>&nbsp;&nbsp; byte pre_master_secret is generated by the client, encrypted under<BR>&nbsp;&nbsp; the server's public key, and sent to the server.&nbsp; The server uses its<BR>&nbsp;&nbsp; private key to decrypt the pre_master_secret.&nbsp; Both parties then<BR>&nbsp;&nbsp; convert the pre_master_secret into the master_secret, as specified<BR>&nbsp;&nbsp; above.</DIV>
<DIV>&nbsp;&nbsp; RSA digital signatures are performed using PKCS #1 block type<BR>&nbsp;&nbsp; 1. RSA public key encryption is performed using PKCS #1 block type 2.</DIV>
<DIV>2.1.2. Diffie-Hellman</DIV>
<DIV>&nbsp;&nbsp; A conventional Diffie-Hellman computation is performed.&nbsp; The<BR>&nbsp;&nbsp; negotiated key (Z) is used as the pre_master_secret, and is converted<BR>&nbsp;&nbsp; into the master_secret, as specified above.&nbsp; Leading bytes of Z that<BR>&nbsp;&nbsp; contain all zero bits are stripped before it is used as the<BR>&nbsp;&nbsp; pre_master_secret.</DIV>
<DIV>&nbsp;&nbsp; Note: Diffie-Hellman parameters are specified by the server and may<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; be either ephemeral or contained within the server's<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certificate.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV></DIV>
<DIV></DIV>
页: [1]
查看完整版本: TLS1.1-握手协议