← Back to section · Digital Security
HSMs and Cloud KMS: Choosing a Hardware Vault for Your Keys
The trust boundary of a hardware security module, FIPS 140-3 levels, the custody models of cloud KMS including bring-your-own-key, and why envelope encryption is the common language of both.
Where keys live determines the root of trust of the whole key-management system. A private key in an application server’s configuration file is copied the moment the server is breached. A key inside dedicated hardware can, at worst, be used by an attacker who has taken over the application layer — it cannot be carried away. Hardware security modules (HSMs) and cloud key management services (KMS) are two generations of products built around this idea: the first is a dedicated appliance, the second turns the same boundary into a cloud service.
The HSM trust boundary
An HSM is a dedicated computer containing cryptographic accelerators, a true random number generator, and a tamper-resistant enclosure. Its core promise fits in one sentence: keys are generated inside the module, used inside the module, and in principle never leave it in plaintext. Outside systems submit operation requests through PKCS#11, KMIP, or a vendor API — “sign this data with this key” — and the module returns the result. Even if the caller’s host is fully compromised, the attacker can only abuse the interface during the compromise; the key cannot be copied offline for use elsewhere, and the audit log shows how many times the interface was called.
Physical protection is what separates an HSM from an ordinary server: opening the case, drilling, abnormal voltage, or temperature excursions trigger zeroization of the keys. That is why procuring an HSM is never just buying a device — data-centre access control, dual-operator procedures, and the management of backup tokens are all part of the boundary.
What the FIPS 140-3 levels actually say
FIPS 140-3 is the US federal standard of security requirements for cryptographic modules, superseding FIPS 140-2, and it grades modules into four levels. Level 1 is the baseline: approved algorithms on a general-purpose computing platform. Level 2 adds tamper evidence (such as seals) and role-based authentication. Level 3 requires stronger physical protection — tamper detection with zeroization, identity-based authentication, and physical or logical separation for key entry and output. Level 4 targets hostile physical environments, with comprehensive protection against voltage, temperature, and other environmental anomalies.
Keep a clear head when choosing: the level certifies the product under laboratory conditions, not your deployment. A Level 3 HSM sitting in an unattended room with a default administrative password has an actual security level unrelated to its certificate. Certification also takes time — modules commonly spend years between submission and certificate — so verify that the certificate covers the exact firmware version you are buying and that the version is still on NIST’s validated list.
Backup, clustering, and disaster recovery: the lesson procurement most often skips
Keys cannot leave an HSM — that is a security feature, and it also means backups must travel through the module’s own channels. Mainstream approaches include backup tokens that receive encrypted key material, cloning domains that let a group of HSMs share the same keys for high-availability clustering, and smart-card shares holding exported material. During selection, verify item by item: who custodies the backup media, which roles must be present to restore a brand-new device, and whether keys move between cluster members only in wrapped form. More important still is rehearsal: a disaster-recovery plan that says “restore from backup” is not the same as having restored. Run the exercise — rebuild an HSM from the backup token and successfully decrypt historical data — at least once a year, and record the recovery time and failure points. Many organizations discover only when a real incident hits that the backup token’s custodian has left the company, or that the backup’s firmware version is incompatible with the replacement device. Folding restore rehearsal into procurement acceptance and the annual plan costs far less than discovering it live during an outage.
Three custody models in cloud KMS
Cloud KMS turns clusters of HSMs into a multi-tenant service: applications call APIs to encrypt, decrypt, and sign, and get audit logs, automatic rotation, and access policies almost for free. On top of that, providers offer three models with different allocations of trust. In the provider-managed model, the master key is generated and held in the provider’s own HSMs; you hold usage rights and audit rights, but the key material never passes through your hands. In bring your own key (BYOK), you generate the master key in your own HSM or environment and import it into the cloud KMS, protected during import by a cloud-side public key; the advantage is that you can destroy the source material at origin and thereby invalidate the cloud copy, the cost is a more complex import process and availability management. In hold your own key (HYOK) style models, the key never leaves your own HSM and the cloud service must call back to your equipment for every use — maximum control, but availability and latency become your problem.
None of the three is absolutely better; they trade trust against operational cost. Heavily regulated industries lean towards BYOK or even HYOK to satisfy key-sovereignty requirements. For ordinary workloads, provider-managed keys with effort spent on access policy and auditing is usually the more pragmatic choice.
Envelope encryption: the common language
Whether the backend is a local HSM or a cloud KMS, real architectures almost always converge on envelope encryption: data is encrypted directly by a data key (DEK), and the DEK is wrapped by a master key (KEK) and stored alongside the ciphertext. To read the data, you call the KMS to unwrap the DEK, then decrypt locally. The reason is practical: the master key must not leave the HSM boundary, yet bulk data encryption cannot possibly run inside the HSM at the required throughput. DEKs live briefly in memory and are discarded after use; rotating the master key only requires re-wrapping DEKs, not re-encrypting all the data.
So the real question when evaluating key infrastructure is not “HSM or KMS?” It is: where is the master key’s boundary drawn, who may call it, is every call logged, and are DEKs generated and cached properly? Devices and services are only the carriers of the boundary — the boundary itself is the security goal.
Tags: HSMKMSFIPS 140-3Envelope Encryption