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

Symmetric Encryption (การเข้ารหัสแบบสมมาตร) ในความปลอดภัยเครือข่าย คืออะไร? ต่างจาก Asymmetric อย่างไร?

Symmetric Encryption คืออะไร?

Symmetric Encryption (การเข้ารหัสแบบสมมาตร) เป็นวิธีเข้ารหัสที่ใช้ คีย์เดียว (Secret Key) ทั้งในการเข้ารหัส (Encryption) และถอดรหัส (Decryption) ทั้งผู้ส่งและผู้รับต้องมีคีย์เดียวกันนี้ล่วงหน้า

ลักษณะสำคัญ

  • Speed: เร็วมาก (ประมาณ 1000-10000x Asymmetric) เหมาะเข้ารหัสข้อมูลปริมาณมาก
  • Key Size: สั้นกว่า Asymmetric (เช่น AES-256 ใช้ 256-bit vs RSA 3072-bit)
  • Key Distribution Problem: จุดอ่อนหลัก - ต้องส่งคีย์ลับให้ผู้รับอย่างปลอดภัย (Out-of-band หรือผ่าน Asymmetric Key Exchange)
  • ไม่ให้ Non-repudiation: ใครมีคีย์ก็สามารถเข้ารหัส/ถอดรหัสได้ ไม่พิสูจน์ตัวตนผู้ส่งได้

อัลกอริทึม Symmetric ยอดนิยม

อัลกอริทึมประเภทKey Sizeสถานะ/การใช้งาน
AES (Advanced Encryption Standard)Block Cipher128, 192, 256-bitมาตรฐานโลก (FIPS 197) ใช้ใน TLS, IPsec, BitLocker, FileVault, Signal
ChaCha20Stream Cipher256-bitทันสมัย เร็วบน CPU ไม่มี AES-NI ใช้ใน TLS 1.3, WireGuard, SSH
3DES (Triple DES)Block Cipher168-bit (eff. 112)ล้าสมัย ช้า มีช่องโหว่ Sweet32 ห้ามใช้ใหม่
Blowfish / TwofishBlock Cipherตัวแปรเก่า กำลังถูกแทนที่ด้วย AES/ChaCha20
RC4Stream Cipher40-2048-bitแตกแล้ว ห้ามใช้

โหมดการทำงานของ Block Cipher (Modes of Operation)

โหมดคุณสมบัติใช้งาน
ECBไม่ควรใช้ (รูปแบบข้อมูลซ้ำเห็นได้)ห้ามใช้
CBCต้องมี IV, Sequential, Padding Oracle attacksTLS 1.2 (Legacy)
GCM (Galois/Counter Mode)AEAD: Encrypt + Auth ในขั้นเดียว, Parallel, เร็วTLS 1.3, IPsec, SSH, 標準推薦
CTRStream-like, Parallel, ต้องแยก MACSpecial cases

Symmetric vs Asymmetric Encryption

ด้านเปรียบเทียบSymmetricAsymmetric (Public Key)
จำนวนคีย์1 คีย์ (Secret Key)คู่คีย์: Public + Private
ความเร็วเร็วมากช้า (คณิตศาสตร์ซับซ้อน)
ขนาดคีย์สั้น (128-256-bit)ยาว (2048-4096-bit RSA, 256-bit ECC)
Key Exchangeยาก (ต้องมีช่องทางปลอดภัย)ง่าย (Public Key ส่งสาธารณะได้)
Non-repudiationไม่มีมี (Digital Signature)
Use Case หลักเข้ารหัสข้อมูลปริมาณมาก (Data at rest, Data in transit)Key Exchange, Digital Signature, PKI, TLS Handshake

Hybrid Encryption: รวมข้อดีทั้งสอง

ระบบจริงใช้ Hybrid Approach:

  1. ใช้ Asymmetric (เช่น ECDH, RSA-KEM) เพื่อ Key Exchange สร้าง Shared Secret
  2. นำ Shared Secret มา derive เป็น Symmetric Key (AES-GCM, ChaCha20-Poly1305)
  3. ใช้ Symmetric Key เข้ารหัสข้อมูลจริง (Bulk Encryption)

ตัวอย่าง: TLS 1.3, Signal Protocol, SSH, IPsec IKEv2, PGP/GPG

HTTPS ใช้ Symmetric หรือ Asymmetric?

ทั้งคู่ Handshake ใช้ Asymmetric (ECDHE/RSA) เพื่อแลกเปลี่ยนคีย์ แล้ว Session ใช้ Symmetric (AES-GCM/ChaCha20-Poly1305) เข้ารหัส HTTP Traffic

Best Practices 2024

  • ใช้ AES-256-GCM หรือ ChaCha20-Poly1305 (AEAD modes)
  • ไม่ใช้ ECB, CBC (โดยไม่มี MAC), 3DES, RC4, Blowfish
  • Key Management: ใช้ HSM/KMS (AWS KMS, Azure Key Vault, HashiCorp Vault)
  • Key Rotation: หมุนเวียนคีย์เป็นระยะ (90-365 วัน)
  • ใช้ Library มาตรฐาน: libsodium, OpenSSL, Bouncy Castle, Go crypto, Python cryptography อย่าเขียน Crypto เอง