Files
Knowledge/sunyard/7 信安/RSA 算法.md
T

19 lines
638 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
RSA 算法有:指数模、CRT 两种不同的实现方法。
### **RSA 核心公式(指数模)**
1. **密钥生成**:
- 选择两个大素数 `p` 和 `q`,计算模数 `n = p * q`
- 计算欧拉函数 `φ(n) = (p-1) * (q-1)`
- 选择公钥指数 `e`,满足 `1 < e < φ(n)` 且 `gcd(e, φ(n)) = 1`
- 计算私钥指数 `d = e⁻¹ mod φ(n)`(模逆元)
2. **加密/解密**:
- 加密:`c = m^e mod n`(明文 `m`,密文 `c`)
- 解密:`m = c^d mod n`
3. **签名/验签**:
- 签名:`s = m^d mod n`
- 验签:`m' = s^e mod n`,检查 `m' == m`