Skip to content
2012 edited this page Jul 20, 2020 · 5 revisions

特点:加密、验证、完整性


对称加密 vs 非对称加密

  • 对称加密算法使用同一个秘钥加密解密数据,很容易被暴力破解,且无法识别发送者的身份;

优势:

  1. fast, low resource usage
  2. simple operation
  3. secure

缺点:

  1. same key used for encryption/decryption
  2. key must be distributed using an already established, secure channel
  3. different key for different parties - difficult key management/distribution
  4. cannot authenticate users
  • 非对称加密使用两个不同秘钥,可以验证发送者的身份,但由于非常耗资源和吃 cpu,耗时较长。

优点:

  1. key distribution is easy
  2. authenticity
  3. Integrity
  4. security

缺点:

  1. slower than symmetric encryption
  2. need more resources

公开密钥加密技术(public key infrastructure, PKI)

握手过程使用非对称加密,生成一个 shared key,传输数据的时候使用对称加密算法;这样就得到了优化


握手

SSL/TLS handshake 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 如何保证数据完整性

  1. get public key from certificate
  2. excrypt test.txt file content using public key
  3. decrypt from cipher.txt using private key
  4. confirming the integrity of file which is signed with private key

Q3: SSL/TLS 如何提供加密

结合使用对称加密和非对称加密确保数据私有化,在 TLS 握手期间,使用非对称加密,协商加密算法,生成共享秘钥进行数据加密、解密

JS

  1. 作用域
  2. 闭包
  3. 原型(链)
  4. 模块
  5. 位操作符
  6. 事件循环
  7. eval

CSS

  1. float
  2. BFC
  3. position
  4. flex
  5. grid

DOM

  1. DOM
  2. how browser works

Node.js

  1. Stream
  2. Timers
  3. Child Processes
  4. HTTP
  5. File System

react

  1. 生命周期
  2. setState
  3. hook

git

  1. git 基础命令
  2. git rebase 理解
  3. git bisect
  4. git commit
  5. git hook

设计模式

  1. 策略模式
  2. ...

TCP/IP 协议

  1. HTTP/1.x
  2. HTTP/2
  3. SSL/TLS
  4. TCP
  5. DNS
  6. HTTP Cache
  7. CORS
  8. http status code

linux(shell)知识点

  1. bashrc vs profile
  2. vim
  3. shell基本语法
  4. shell 知识误区
  5. shell命令
  6. 鸟哥的Linux私房菜:基础学习篇
  7. sudo vs su
Clone this wiki locally