Public-Key Cryptosystem (ระบบเข้ารหัสกุญแจสาธารณะ)
ระบบเข้ารหัสที่ใช้ คู่กุญแจ: Public Key (เข้ารหัส/ตรวจสอบ) และ Private Key (ถอดรหัส/เซ็น) ทางคณิตศาสตร์: ทราบ Public Key ไม่สามารถคำนวณ Private Key ได้ในเวลาที่เป็นไปได้
หลักการทำงาน
- Encryption: Alice ใช้ Pub_B เข้ารหัส → Bob ใช้ Prv_B ถอดรหัส
- Digital Signature: Alice ใช้ Prv_A เซ็น → Bob ใช้ Pub_A ตรวจสอบ
- คุณสมบัติ: Trapdoor One-way Function (ง่ายหนึ่งทาง ยากอีกทาง ถ้าไม่มี Trapdoor/Private Key)
คุณสมบัติของระบบที่แข็งแกร่ง (Strong Public-Key System)
- ทราบ Algorithm + Public Key → ไม่ได้ข้อมูล เกี่ยวกับ Private Key
- ไม่สามารถถอดรหัสได้โดยไม่มี Private Key
- พื้นฐานความปลอดภัย: Hard Mathematical Problems (IFP, DLP, LWE, Code-based, Hash-based)
ขนาดกุญแจทั่วไป
| อัลกอริทึม | Key Size (Bits) | Security Level (Bits) | Post-Quantum |
|---|---|---|---|
| RSA | 2048, 3072, 4096 | 112, 128, 150 | ❌ Broken by Shor |
| ECC (P-256, P-384) | 256, 384 | 128, 192 | ❌ Broken by Shor |
| ECC (Curve25519, P-521) | 256, 521 | 128, 256 | ❌ Broken by Shor |
| ML-KEM (Kyber) | 768, 1024, 1536 (Ciphertext) | 128, 192, 256 | ✅ Lattice-based |
| ML-DSA (Dilithium) | 1312, 1952, 2592 (Sig) | 128, 192, 256 | ✅ Lattice-based |
การจัดเก็บกุญแจ
- Private Key ต้องเก็บใน HSM (Hardware Security Module), TEE (Trusted Execution Environment), Secure Enclave, USB Token (YubiKey, Nitrokey)
- ไม่ควรเก็บเป็น Plaintext ใน Disk/Database
โจมตีและการป้องกัน
Man-in-the-Middle (MITM)
- โจมตีแทนที่ Public Key ใน Directory/Channel
- ป้องกัน: PKI (X.509 Certificates), TOFU (SSH), Key Transparency, Out-of-band Verification (Signal Safety Numbers)
Side-Channel Attacks
- Timing, Power, EM, Cache → ดึง Private Key
- ป้องกัน: Constant-time Implementation, Masking, Blinding, HSM
การประยุกต์หลัก
- TLS/HTTPS: Server Auth (Cert), Key Exchange (ECDHE), AEAD (AES-GCM/ChaCha20-Poly1305)
- SSH: Host Key, User Key, Key Exchange
- Email Security: S/MIME, PGP/GPG
- Code Signing: Authenticode, APK Signing, RPM Sign
- Blockchain/Crypto: ECDSA/secp256k1 (Bitcoin, Ethereum), Ed25519 (Solana, Cardano)