Public Key Cryptography (Asymmetric Cryptography)
ใช้คู่กุญแจ: Public Key (เผยแพร่ได้) และ Private Key (เก็บความลับ) ให้บริการความปลอดภัยหลายมิติ
การประยุกต์ใช้หลัก
1. ลายเซ็นดิจิทัล (Digital Signatures)
- เซ็นด้วย Private Key → ใครก็ตรวจสอบได้ด้วย Public Key
- ให้: Authentication, Integrity, Non-repudiation
- กระบวนการ: Hash(Message) → Sign(Hash, Private Key) → Signature
- อัลกอริทึม: RSA-PSS, ECDSA, EdDSA (Ed25519)
2. การเข้ารหัส (Encryption)
- เข้ารหัสด้วย Public Key ของผู้รับ → ถอดรหัสได้เฉพาะ Private Key ของผู้รับ
- ให้: Confidentiality
- ใช้จริง: Hybrid Encryption (RSA/ECC เข้ารหัส Session Key, AES เข้ารหัสข้อมูล)
3. การยืนยันตัวตน (Authentication)
- Entity Authentication: TLS Client Cert, SSH Keys, FIDO2/WebAuthn
- Message Authentication: Digital Signature, HMAC (Symmetric)
4. การไม่สามารถปฏิเสธได้ (Non-repudiation)
- เฉพาะ Digital Signature (Asymmetric) เท่านั้น
- Symmetric MAC (HMAC) ไม่ให้ Non-repudiation (กุญแจร่วม)
5. ความสมบูรณ์ (Integrity)
- Digital Signature ให้ Integrity (Hash ส่วนของข้อความ)
- Authenticated Encryption (AES-GCM, ChaCha20-Poly1305) ให้ Integrity + Confidentiality
6. ความลับ (Confidentiality)
- Public Key Encryption (RSA-OAEP, ECIES)
- Key Encapsulation Mechanism (KEM): Kyber (PQC)
7. การสร้างกุญแจ (Key Generation)
- แต่ละฝ่ายสร้าง Key Pair เอง (Private Key ไม่ออกจากอุปกรณ์)
- Public Key แจกจ่ายผ่าน Certificate (PKI) หรือ TOFU (Trust On First Use)
8. Key Agreement / Exchange
- Diffie-Hellman (DH), ECDH, X25519
- สร้าง Shared Secret ผ่านช่องทางไม่ปลอดภัย
- Forward Secrecy: Ephemeral Keys (DHE, ECDHE)
โครงสร้าง PKI (Public Key Infrastructure)
- CA (Certificate Authority): ออก Certificate (X.509) ผูก Identity กับ Public Key
- Certificate: Subject, Public Key, Issuer, Validity, Signature, Extensions
- Chain of Trust: Root CA → Intermediate CA → Leaf Certificate
- Revocation: CRL, OCSP
มาตรฐานและโปรโตคอล
- TLS 1.3 (HTTPS), SSH, IPsec, S/MIME, PGP/GPG, DNSSEC, JWT
- Post-Quantum: ML-KEM (Kyber), ML-DSA (Dilithium), SLH-DSA (SPHINCS+)