| 标准 | RFC 8017 §7.1(RSAES-OAEP) |
|---|---|
| 组成 | lHash + PS + 0x01 + M,配 MGF1 |
| 推荐哈希 | SHA-256(与 MGF1 保持一致) |
| 与 v1.5 对比 | 抗 Bleichenbacher 类攻击能力更强 |
Python 示例(cryptography)
Python 示例(cryptography)
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
ct = pub.encrypt(msg, padding.OAEP(mgf=padding.MGF1(hashes.SHA256()), algorithm=hashes.SHA256(), label=None))解密失败时对外必须统一响应(错误码、耗时一致),否则可能重演针对填充的密文选择攻击。