Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบเครือข่าย >> ความปลอดภัยเครือข่าย

อัลกอริทึมคีย์ลับ (Secret Key Algorithm) ในความปลอดภัยเครือข่ายคืออะไร?

Secret Key Algorithm (Symmetric Encryption Algorithm) คืออะไร?

Secret Key Algorithm หรือ Symmetric Encryption Algorithm คือ อัลกอริทึมเข้ารหัสที่ใช้ คีย์เดียวกัน (Single Key / Secret Key / Private Key) สำหรับทั้ง การเข้ารหัส (Encryption) และ การถอดรหัส (Decryption) คีย์นี้ต้องเก็บความลับและแบ่งปันระหว่างฝ่ายสื่อสารอย่างปลอดภัย

🔐 หลักการทำงาน

Plaintext + Secret Key + Algorithm → Ciphertext
Ciphertext + Secret Key + Algorithm → Plaintext
  • ความเร็วสูง (เหมาะกับข้อมูลขนาดใหญ่ / Bulk Encryption)
  • ต้องมีวิธีแลกเปลี่ยนคีย์อย่างปลอดภัย (Key Exchange Problem) → ใช้ Asymmetric Crypto (Diffie-Hellman, RSA) หรือ Key Distribution Center (KDC/Kerberos)
  • ใช้ร่วมกับ Mode of Operation (CBC, GCM, CTR, CCM) และ Padding (PKCS#7)

📋 อัลกอริทึมสำคัญ (Standard Algorithms)

อัลกอริทึมKey SizeBlock Sizeสถานะ/การใช้งาน
AES (Advanced Encryption Standard) 🏆128, 192, 256 bits128 bitsมาตรฐานโลก (FIPS 197) ใช้ทุกที่: TLS, IPsec, Wi-Fi (WPA2/3), Disk Encryption (BitLocker, FileVault), SSH, ZIP
ChaCha20-Poly1305 🏆256 bitsStream (512 bits)เร็วกว่า AES บน CPU ไม่มี AES-NI ใช้ใน TLS 1.3, WireGuard, SSH, QUIC
3DES (Triple DES)168 bits (Effective 112)64 bits❌ Deprecated (NIST SP 800-131A) ช้า, Sweet32 Attack ยกเลิก TLS 1.2/1.3
RC440-2048 bitsStream❌ ห้ามใช้ Bias Attacks, ทิ้งทิ้งแล้ว
Blowfish / Twofish32-448 / 128-256 bits64 / 128 bitsLegacy / ไม่ใช่มาตรฐาน Twofish รองใน AES Contest
Camellia128, 192, 256 bits128 bitsมาตรฐานญี่ปุ่น/สากล (ISO/IEC 18033-3) ใช้ใน TLS, IPsec, NESSIE
SM4128 bits128 bitsมาตรฐานจีน (GB/T 32907) ใช้ใน China National Standards

🔧 Modes of Operation (สำคัญมาก!)

🔑 การจัดการคีย์ (Key Management) - จุดอ่อนหลัก

  • Key Generation: CSPRNG (Cryptographically Secure PRNG) /dev/urandom, BCryptGenRandom, getrandom()
  • Key Exchange: Diffie-Hellman (ECDHE, FFDHE), RSA Key Transport, KEM (Kyber - PQC), Kerberos, PAKE (OPAQUE, SPAKE2)
  • Key Derivation: HKDF, PBKDF2, Argon2, scrypt (จาก Password/Master Key)
  • Key Storage: HSM (Hardware Security Module), TPM, Secure Enclave, KMS (AWS KMS, Azure Key Vault, HashiCorp Vault), Key Vaults
  • Key Rotation: เปลี่ยนคีย์เป็นระยะ (NIST: 1-2 ปีสำหรับ Symmetric Keys) Automated
  • Key Destruction: Secure Erase (Crypto-shredding) เมื่อหมดอายุ

🛡️ การใช้งานจริง (Real-world Usage)

  • TLS 1.3: AES-GCM / ChaCha20-Poly1305 (AEAD) กับ Session Keys จาก ECDHE
  • IPsec ESP: AES-GCM / AES-CBC+HMAC / ChaCha20-Poly1305
  • Wi-Fi (WPA2/WPA3): AES-CCMP (WPA2), AES-GCMP (WPA3) + SAE
  • Disk Encryption: BitLocker (AES-XTS), FileVault (AES-XTS), LUKS (AES-XTS/GCM)
  • Database/Application Encryption: AES-GCM (AEAD) สำหรับ Field-level Encryption
  • Messaging (Signal, WhatsApp): Double Ratchet (Chain of Symmetric Keys from DH)

⚡ Symmetric vs Asymmetric

ModeลักษณะIV/NonceParallelIntegrityใช้งาน
ECBแต่ละ Block แยกกันไม่ต้องการ✅❌❌ ห้ามใช้ (Pattern Leak)
CBCChain ต่อกันIV (Random)❌ Enc / ✅ Dec❌Legacy (TLS 1.2, File Enc) ต้องมี Padding
CTRCounter Mode (Stream-like)Nonce + Counter✅❌Disk Enc, IPsec, TLS 1.2 (with HMAC)
GCM (Galois/Counter Mode) 🏆AEAD (Auth + Enc)Nonce (96-bit)✅✅ Built-inมาตรฐานปัจจุบัน TLS 1.3, SSH, IPsec, WPA3, QUIC
CCMAEAD (CBC-MAC + CTR)Nonce❌✅Wi-Fi (WPA2 CCMP), Zigbee, BLE
OCBAEAD (Efficient)Nonce✅✅Patented (Exp 2020) ใช้ได้น้อย

🔮 อนาคต: Post-Quantum Cryptography (PQC)

  • NIST PQC Standards (2024): ML-KEM (Kyber - KEM), ML-DSA (Dilithium - Signature), SLH-DSA (SPHINCS+ - Signature)
  • Symmetric: AES-256, ChaCha20 ยังปลอดภัย (Grover's Algorithm ลดความแข็งแกร่งเหลือครึ่ง Key Size → ใช้ 256-bit)
  • Hybrid Approaches: Classical + PQC (X25519+Kyber, ECDSA+Dilithium) ใน TLS 1.3, SSH, Signal

💡 สรุป

Secret Key Algorithm = Symmetric Encryption = ใช้คีย์เดียวกันเข้ารหัส/ถอดรหัส AES-GCM และ ChaCha20-Poly1305 เป็นมาตรฐานทองคำปัจจุบัน (AEAD: Authenticated Encryption with Associated Data) จุดสำคัญ: Key Management (Generation, Exchange, Storage, Rotation, Destruction) และการเลือก Mode ที่ถูกต้อง (อย่าใช้ ECB, ควรใช้ GCM/CCM)

คุณสมบัติSymmetric (Secret Key)Asymmetric (Public Key)
Speed⚡ เร็วมาก (1000-10000x)🐢 ช้า
Key Distribution😫 ยาก (Key Exchange Problem)😊 ง่าย (Public Key แจกได้)
Scalability (N parties)O(N²) KeysO(N) Key Pairs
Non-repudiation❌ ไม่ได้ (Shared Secret)✅ ได้ (Digital Signature)
Typical UseBulk Data EncryptionKey Exchange, Digital Signatures, Certificates