Master Key trong Mật mã học (Cryptography) là gì?
Là khóa cấp cao nhất trong hệ thống phân cấp khóa (Key Hierarchy). Dùng để mã hóa (encrypt/protect) các khóa khác (Data Encryption Keys - DEK, Key Encryption Keys - KEK, Session Keys). Master Key thường được lưu trữ trong phần cứng bảo mật: HSM (Hardware Security Module), TPM, Secure Enclave, KMS (Key Management Service).
Master Key vs Session Key
| Đặc điểm | Master Key (Khóa chính) | Session Key (Khóa phiên) |
| Vòng đời | Dài (năm), xoay vòng định kỳ (key rotation) | Ngắn (một phiên/kết nối), dùng xong hủy |
| Mục đích | Bảo vệ các khóa con (KEK, DEK), ký chứng chỉ CA | Mã hóa dữ liệu truyền tải (TLS, IPsec, SSH) |
| Lưu trữ | HSM, KMS, TPM, offline root CA | Memory (RAM), không ghi disk |
| Ví dụ | AWS KMS CMK, Root CA Key, KMIP Master Key | TLS Session Key, IPsec SA Key, SSH Session Key |
Master Key trong các hệ thống thực tế
- AWS KMS: Customer Master Key (CMK) - mã hóa DEK dùng cho S3, EBS, RDS encryption. CMK không rời HSM.
- PKI/CA: Root CA Private Key = Master Key ký Intermediate CA → ký End-entity Cert (TLS/SSL, Code Signing, Document).
- Database TDE (Transparent Data Encryption): Database Master Key (DMK) bảo vệ Certificate/Asymmetric Key → bảo vệ DEK mã hóa data file.
- Password Manager: Master Password → derive Master Key (PBKDF2/Argon2) →encrypt vault (DEK).
- Signal/Double Ratchet: Root Key (Master) → Chain Key → Message Key (per message).
Key Hierarchy (Phân cấp khóa) tiêu chuẩn
Root Master Key (Offline HSM/Root CA)
│
├── Key Encryption Key (KEK) - Online HSM/KMS
│ │
│ ├── Data Encryption Key (DEK) - Per dataset/file/volume
│ │ │
│ │ └── Data (AES-256-GCM/ChaCha20-Poly1305)
│ │
│ └── Session Key (TLS, IPsec, SSH) - Ephemeral
│
└── Signing Key (Code Signing, Doc Signing, Timestamp)
Yêu cầu bảo vệ Master Key
- Phân tách nhiệm vụ: Không ai một mình truy xuất được (M-of-N, Shamir Secret Sharing).
- HSM FIPS 140-2 Level 3/4: Tamper-evident, tamper-responsive, zeroization.
- Key Rotation: Xoay vòng Master Key/KEK định kỳ (1-3 năm), re-encrypt DEK.
- Audit Trail: Log mọi thao tác: generate, export, encrypt, decrypt, rotate, destroy.
- Backup an toàn: Split knowledge, encrypted backup, offline storage, geo-redundant.
CMK (Customer Master Key) trong Cloud
Khái niệm BYOK (Bring Your Own Key) / HYOK (Hold Your Own Key). Khách hàng tự tạo/quản lý Master Key trong HSM của mình hoặc Cloud HSM chuyên dụng (AWS CloudHSM, Azure Dedicated HSM, Google Cloud HSM), cloud provider chỉ dùng để encrypt/decrypt DEK theo yêu cầu, không thấy plaintext Master Key.