理解 HTTPS 的工作原理
在TLS协议中,有四种子协议运行于Record protocol之上
Record protocol起到了这样的作用
值得一提的是,Record protocol提供了数据完整性和隐私性保证,但Record类型(type)和长度(length)是公开传输的 Record Protocol有三个连接状态(Connection State),连接状态定义了压缩,加密和MAC算法。所有的Record都是被当前状态(Current State)确定的算法处理的。 TLS Handshake Protocol和Change Ciper Spec Protocol会导致Record Protocol状态切换。
初始当前状态(Current State)没有指定加密,压缩和MAC算法,因而在完成TLS Handshaking Protocols一系列动作之前,客户端和服务端的数据都是明文传输的;当TLS完成握手过程后,客户端和服务端确定了加密,压缩和MAC算法及其参数,数据(Record)会通过指定算法处理。 其中,Record首先被加密,然后添加MAC(message authentication code)以保证数据完整性。 TLS Handshaking Protocols Handshakeing protocols包括Alert Protocol,Change Ciper Spec Protocol和Handshake protocol。本文不会详细介绍Alert Protocol和Change Ciper Spec Protocol。 使用RSA算法的握手过程是这样的(已在总览中提到) ![]() Source: Keyless SSL: The Nitty Gritty Technical Details 客户端和服务端在握手hello消息中明文交换了client_random和server_random,使用RSA公钥加密传输premaster secret,最后通过算法,客户端和服务端分别计算master secret。其中,不直接使用premaster secret的原因是:保证secret的随机性不受任意一方的影响。 除了使用RSA算法在公共信道交换密钥,还可以通过Diffie–Hellman算法。Diffie–Hellman算法的原理是这样的: ![]()
使用Diffie–Hellman算法交换premaster secret的流程 ![]() Source: Keyless SSL: The Nitty Gritty Technical Details 小结 TLS Handshaking Protocols协商了TLS Record Protocol使用的算法和所需参数,并验证了服务端身份;TLS Record Protocol在协商后保证应用层数据的完整性和隐私性。 TLS Handshaking Protocol的核心是在公开信道上传递premaster secret。 Q&A 为什么传输内容不直接使用非对称加密? 性能 HTTPS能保证正常连接? no There are a number of ways in which a man-in-the-middle attacker can attempt to make two entities drop down to the least secure method they support. 攻击者甚至可以直接丢弃双方的数据包。 服务端如何验证客户端身份? 通过Client Certificate This message conveys the client’s certificate chain to the server; the server will use it when verifying the CertificateVerify message (when the client authentication is based on signing) or calculating thepremaster secret (for non-ephemeral Diffie- Hellman). The certificate MUST be appropriate for the negotiated cipher suite’s key exchange algorithm, and any negotiated extensions. Alert protocol有什么作用? Closure Alerts:防止Truncation Attack In a truncation attack, an attacker inserts into a message a TCP code indicating the message has finished, thus preventing the recipient picking up the rest of the message. To prevent this, SSL from version v3 onward has a closing handshake, so the recipient knows the message has not ended until this has been performed. Error Alerts:错误处理 master secret是如何计算的
加密,压缩和MAC算法参数是如何计算的 Handshaking Protocols使得客户端和服务端交换了三个参数:client_random,server_random和master_secret,通过以下算法生成算法所需要的参数
(编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |