Glossary

HSM (Hardware Security Module)

Last verified

Definition

HSM is a tamper-resistant hardware device that generates, stores and uses cryptographic keys internally so that private keys never leave it in plaintext.

A Hardware Security Module is a dedicated device (an appliance, PCIe card, USB token or cloud service) that performs cryptographic operations such as signing and decryption inside a protected boundary. Keys are generated inside the module and are normally marked non-extractable; applications send data in and receive results through interfaces such as PKCS #11. HSMs are usually validated under FIPS 140-2 or FIPS 140-3 through the NIST Cryptographic Module Validation Program or evaluated under Common Criteria.

Why it matters

HSMs anchor the most valuable keys in PKI. CA/Browser Forum requirements oblige CAs to generate and protect their CA private keys in certified hardware, and code signing rules now require subscribers' signing keys to live in hardware as well, which is why code signing certificates ship on tokens or through cloud signing services. Large TLS deployments, payment systems and banks also keep server keys in HSMs, sometimes combined with SSL offloading appliances.

Example

# create a non-extractable P-256 key on a PKCS #11 token (SoftHSM shown for testing)
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --login \
  --keypairgen --key-type EC:prime256v1 --label tls-key
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-objects

Common misconceptions

  • An HSM makes a compromised server harmless. It prevents key theft, but an attacker controlling the server can still ask the HSM to sign while they have access.
  • Only CAs need HSMs. Code signing keys must be hardware-protected too, and many regulated industries require HSMs for TLS or signing keys.
  • A TPM is the same as an HSM. A TPM is a small chip tied to one machine; HSMs are built for high-volume, multi-application key management.

See also