-
Notifications
You must be signed in to change notification settings - Fork 0
SSL TLS
特点:加密、验证、完整性
- 对称加密算法使用同一个秘钥加密解密数据,很容易被暴力破解,且无法识别发送者的身份;
优势:
- fast, low resource usage
- simple operation
- secure
缺点:
- same key used for encryption/decryption
- key must be distributed using an already established, secure channel
- different key for different parties - difficult key management/distribution
- cannot authenticate users
- 非对称加密使用两个不同秘钥,可以验证发送者的身份,但由于非常耗资源和吃 cpu,耗时较长。
优点:
- key distribution is easy
- authenticity
- Integrity
- security
缺点:
- slower than symmetric encryption
- need more resources
握手过程使用非对称加密,生成一个 shared key,传输数据的时候使用对称加密算法;这样就得到了优化
Client Hello
a list of Client Version, Client Random(32-byte random number), Session ID, a list of Cipher Suites, a list of Compression Methods.
Server Hello
selected Server Version, Server Random(32-byte random number), Session ID(same as above), selected Cipher Suites, selected Compression Method.
Server Certificate
服务端发送证书证明身份,证书包含 public key, 数字签名等。
Server Key Exchange
Server Hello Done
服务端发送 done 确保相关信息发送完毕
Client Key Exchange
pre-master secret(method of create depends on the cipher suite), Client public key
Master Secret
服务器收到 pre-master 后,解码;双方根据对方的 random,自己的 random,共享的 pre-master,生成 master secret: master_secret = PRF(pre_master_secret, "master secret", ClientHello.random + ServerHello.random) [0..47];
使用 master secret 生成 sessions keys 用于数据加密传输。
Client Change Cipher Spec
Client Handshake Finish
Server Change Cipher Spec
Server Handshake Finish
PS
查看系统支持的加密套件清单: openssl ciphers -v
握手延迟命令查看: curl -w "TCP handshake: %{time_connect}, SSL handshake: %{time_appconnect}\n" -so /dev/null https://www.alipay.com
Q1: SSL/TLS 如何提供验证
-
对于服务器身份验证,客户端使用服务器的公钥来加密用于计算 secret-key 的数据。只有当服务器可以使用正确的私钥解密数据时,服务器才能生成 secret-key
-
对于客户端身份验证,服务器使用客户端证书中的公钥来解密客户端发送过来的数据
-
客户端验证:使用证书中的公钥对签名进行解密 S,和证书中协商的加密算法对证书的明文信息解析加密 T,比较 S 是否等于 T
Q2: SSL/TLS 如何保证数据完整性
- get public key from certificate
- excrypt test.txt file content using public key
- decrypt from cipher.txt using private key
- confirming the integrity of file which is signed with private key
Q3: SSL/TLS 如何提供加密
结合使用对称加密和非对称加密确保数据私有化,在 TLS 握手期间,使用非对称加密,协商加密算法,生成共享秘钥进行数据加密、解密
JS
CSS
- float
- BFC
- position
- flex
- grid
DOM
- DOM
- how browser works
Node.js
react
- 生命周期
- setState
- hook
git
- git 基础命令
- git rebase 理解
- git bisect
- git commit
- git hook
设计模式
- 策略模式
- ...
TCP/IP 协议
- HTTP/1.x
- HTTP/2
- SSL/TLS
- TCP
- DNS
- HTTP Cache
- CORS
- http status code
linux(shell)知识点