密码学
现代密码学知识地图:从 Hash/MAC/KDF、对称密码与 AEAD、公钥密码与数字签名,到 PKI/TLS 组合协议,并单独保留 DES/3DES/ECB/CBC/CFB 等 legacy 知识用于兼容与理解演进。
密码学
知识总览
filters:
and:
- 'file.ext == "md"'
- 'file.inFolder("z")'
- 'this.file.links.contains(file)'
- 'file.path != this.file.path'
formulas:
knowledge: 'file.asLink(title)'
properties:
formula.knowledge:
displayName: 知识
note.description:
displayName: Description
note.mastery:
displayName: Mastery
views:
- type: table
name: 知识总览
order:
- formula.knowledge
- note.description
- note.mastery
columnSize:
formula.knowledge: 280
note.description: 760
note.mastery: 56
[!info] related notes
核心问题
现代密码学不是“把明文变乱码”这一件事。
它主要解决:
- Confidentiality:未授权者不能读取内容;
- Integrity:内容被改动时能够检测;
- Authentication:确认消息/实体来自谁或由谁控制某个密钥;
- Key Establishment:安全建立共享密钥;
- Digital Signature:提供公钥可验证的签名;
- Key Derivation:从 root secret 派生用途隔离密钥。
不同 primitive 解决不同问题。
Primitive Map
Hash
message
→ fixed-length digest
不需要 secret key,不提供 confidentiality,也不能单独提供 message authentication。
MAC / HMAC
message + shared secret
→ authentication tag
用于共享 secret 场景的 integrity/authentication。
KDF
secret/keying material
→ derived keys
区分:
- HKDF 这类 general-purpose KDF;
- PBKDF2 / Argon2 这类 password-based KDF。
Symmetric Cryptography
共享 secret key,适合高效保护大量数据。
Block cipher:
- AES
- DES(legacy)
- 3DES / TDEA(legacy)
经典 mode:
Block Cipher Modes of Operation
AEAD
现代消息保护优先心智模型:
plaintext + AAD + nonce + key
→ ciphertext + tag
典型:
- AES-GCM;
- ChaCha20-Poly1305。
Public-Key Cryptography
至少区分:
- public-key encryption;
- digital signature;
- key agreement。
典型数学体系:
Digital Signature
private key → sign
public key → verify
签名不是“私钥加密”。
Trust Layer
PKI
解决:
为什么相信这个 public key 属于这个域名/主体?
核心:
- certificate;
- CA;
- trust anchor;
- path validation;
- revocation/status。
Protocol Composition
真实协议不会只使用一种 primitive。
例如现代 TLS:
certificate / signature
→ authenticate server
ECDHE
→ establish shared secret
HKDF
→ derive traffic secrets
AEAD
→ protect records
详见:
Block Cipher Mode 演进
经典 confidentiality mode:
它们主要解决 confidentiality。
现代新协议更常直接选标准 AEAD,因为:
encryption 不等于 authentication。
Legacy 区域
DES
- 56-bit effective key;
- FIPS 46-3 于 2005 年撤回;
- 主要用于历史理解。
3DES / TDEA
- 继承 64-bit block;
- 已进入 legacy-only 使用阶段。
ECB / CBC / CFB
仍需要学习,因为大量历史协议、文件格式和面试资料会出现。
但:
学习 legacy primitive ≠ 推荐新系统继续采用。
一个推荐学习顺序
Security goals
→ Hash
→ HMAC
→ KDF
→ Symmetric Cipher / AES
→ Block Cipher Modes
→ AEAD
→ Public-Key Cryptography
→ Signature / Key Agreement
→ PKI
→ TLS composition
这条顺序强调:
先理解 primitive,再理解 composition,最后理解 protocol。
不要从“背 TLS 消息顺序”反推整个密码学。