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

Master Key ใน Network Security และ Cryptography คืออะไร? หน้าที่ และการจัดการ

Master Key (คีย์หลัก) ใน Cryptography และ Network Security คืออะไร?

Master Key (MK) คือ คีย์ความลับระดับสูงสุด (Root Key) ที่ใช้สำหรับ เข้ารหัส (Encrypt) และถอดรหัส (Decrypt) คีย์อื่นๆ (Subordinate Keys, Session Keys, Data Encryption Keys) ในระบบจัดการคีย์ (Key Management System - KMS) หรือ Hardware Security Module (HSM)

บทบาทและหน้าที่ของ Master Key

  1. Key Encryption Key (KEK): เข้ารหัส Data Encryption Keys (DEKs) ก่อนเก็บไว้ใน Database/Storage
  2. Key Wrapping/Unwrapping: บรรจุ/เปิดบรรจุคีย์อื่นเพื่อส่งต่อหรือเก็บรักษาอย่างปลอดภัย (NIST SP 800-38F)
  3. Root of Trust: จุดเริ่มต้นของ Chain of Trust ใน PKI / HSM / KMS
  4. Derivation: สร้างคีย์ลูก (Child Keys) ผ่าน Key Derivation Function (KDF) เช่น HKDF, PBKDF2

Master Key vs Session Key vs Data Encryption Key (DEK)

คีย์หน้าที่อายุการใช้งานการเก็บรักษา
Master Key (MK/KEK)Encrypt/Wrap คีย์อื่นๆ Root of Trustยาวนาน (Years) Rotate ต่อปีHSM / TPM / KMS (Hardware-protected) ไม่ออกนอก
Data Encryption Key (DEK)Encrypt ข้อมูลจริง (Files, Databases, Disks)กลาง (Months-Years) Per DatasetEncrypted by MK (Wrapped) เก็บได้ใน DB/Storage
Session KeyEncrypt Traffic ใน Session เดียว (TLS, IPsec, SSH)สั้น (Minutes-Hours) Per SessionMemory Only (Ephemeral) Derived from Master/Key Exchange

Master Key ในบริบทต่างๆ

1. Hardware Security Module (HSM) / KMS

  • Master Key (Root Key): เก็บใน HSM FIPS 140-2 Level 3/4 ไม่ออกนอก HSM לעולם
  • ใช้ Wrap/Unwrap DEKs สำหรับ Application/Database Encryption
  • ตัวอย่าง: AWS KMS (Customer Master Key - CMK), Azure Key Vault, Google Cloud KMS, Thales Luna, nCipher, Utimaco

2. Database Encryption (TDE - Transparent Data Encryption)

  • Database Master Key (DMK): ปกป้อง Certificate/Asymmetric Keys ใน Database
  • Certificate: ปกป้อง Database Encryption Key (DEK)
  • DEK: เข้ารหัส Data/Log Files (AES-256)
  • SQL Server: CREATE MASTER KEY ENCRYPTION BY PASSWORD = '...'

3. TLS/SSL & PKI (Certificate Authority)

  • Root CA Private Key: Master Key ระดับบนสุด - ลงนาม Intermediate CA
  • Intermediate CA Key: ลงนาม End-Entity Certificates (Server/Client)
  • Private Key ของ Server Cert: ใช้ใน TLS Handshake (Key Exchange)
  • Root CA Key เก็บ Offline/HSM - ไม่เคยออนไลน์

4. Payment / Financial (EMV, PCI DSS)

  • Master Key (TMK/ZMK): Key Exchange Keys ระหว่าง HSMs (Key Ceremony)
  • Session Keys: Derive จาก TMK สำหรับแต่ละ Transaction (DUKPT - Derived Unique Key Per Transaction)
  • PCI DSS Requirement: Master Key Split Knowledge & Dual Control

5. Wireless (WPA2/WPA3 Enterprise)

  • Master Session Key (MSK): สร้างจาก EAP Authentication (RADIUS)
  • Pairwise Master Key (PMK): Derive จาก MSK
  • Pairwise Transient Key (PTK): Derive จาก PMK + Nonces - ใช้เข้ารหัส Data Frames

6. Apple Notarization / Code Signing

  • Apple Root CA → Developer ID Certification Authority → Developer ID Application Certificate
  • Notarization Ticket = Apple ลงนาม Hash ของ Binary + Timestamp

การจัดการ Master Key (Key Management Best Practices)

Controlคำอธิบาย
Generationใน HSM/TRNG (True Random) - ไม่เคย Generate นอก HSM
StorageHSM, TPM, Cloud KMS (Hardware-backed) - ไม่เก็บใน File/DB/Code
Access ControlDual Control, Split Knowledge, MFA, Role-based (Admin vs Crypto Officer)
Backup/ExportEncrypted Backup (Key Wrapping) เฉพาะ Disaster Recovery - Offline, Multi-party
Rotationทุก 1-3 ปี (NIST SP 800-57) - Re-encrypt DEKs ด้วย MK ใหม่
DestructionZeroize (HSM Command) - ไม่คืนค่าได้ ต้องมี Audit Trail
Audit/Loggingทุก Operation: Generate, Wrap, Unwrap, Export, Rotate, Destroy

Customer Master Key (CMK) / Bring Your Own Key (BYOK)

  • CMK (AWS KMS term): Logical Key Representation - Backed by Physical Master Key ใน HSM ของ AWS
  • BYOK / BYOE: ลูกค้านำ Master Key เอง (Generate ใน HSM On-prem) → Import เข้า Cloud KMS (Key Import)
  • Hold Your Own Key (HYOK): Key อยู่ On-prem HSM Cloud เรียกใช้ผ่าน API (External Key Store)

Master Key Compromise = Game Over

หาก Master Key ถูกขโมย/รั่วไหล:

  • ทุก DEK ที่ถูก Wrap ด้วย MK นั้น ถูก Compromise ทั้งหมด
  • ต้อง Rotate Master Key ทันที + Re-encrypt ทุก DEK (Massive Operation)
  • Revocation/Re-issue Certificates (ถ้าเป็น CA Root Key)
  • Financial Loss, Reputation, Legal, Regulatory Fines

💡 สรุป

Master Key คือ Heart of Cryptographic Security ปกป้องคีย์ทั้งหมดในระบบ ต้องได้รับการปกป้องสูงสุด: HSM, Dual Control, Split Knowledge, Regular Rotation, Immutable Audit Logs การออกแบบ Key Hierarchy (MK → KEK → DEK → Session Key) ให้ถูกต้อง เป็นหัวใจของ Enterprise Key Management และ Compliance (PCI DSS, FIPS, GDPR, ISO 27001)