Skip to content

Choosing an HSM: FIPS 140-3, PKCS#11 and form factors

A practitioner's guide to HSMs: what FIPS 140-3 levels actually certify, PKCS#11 and other APIs, network, PCIe, USB and cloud HSMs, quorum controls and key ceremonies.

Published on 6 min read

A hardware security module (HSM) is a hardened, tamper-responsive computer whose only job is to generate, store and use cryptographic keys without ever exposing them. HSMs sit behind certificate authorities, code-signing pipelines, payment networks, DNSSEC signers and cloud key management services. When a single private key would be catastrophic to lose or leak, it belongs in one.

This guide covers what to look for when you select an HSM, and how certifications, APIs and form factors map to real use cases.

What an HSM gives you that a server does not

  • Non-exportable keys. Keys are generated inside the boundary and can be marked non-extractable. Applications send data in and get signatures or ciphertext out.
  • Tamper response. Higher-assurance modules detect physical intrusion (drilling, opening, voltage or temperature abuse) and erase key material.
  • Role separation and quorum. Security officers, crypto officers and users are distinct roles; sensitive actions can require M of N smart cards or credentials.
  • Audit logs of key use and administration, signed or protected by the module.
  • Certified implementations of algorithms and random number generation.

FIPS 140-3 levels in plain language

FIPS 140-3 (which superseded FIPS 140-2 for new validations, aligned with ISO/IEC 19790) is run by the NIST Cryptographic Module Validation Program (CMVP). It defines four security levels:

LevelIn shortTypical products
1Approved algorithms, correct implementation; no physical security requirementSoftware crypto libraries
2Adds tamper evidence (seals, coatings) and role-based authenticationMany USB tokens and smart cards
3Adds tamper response, identity-based authentication, stronger separation of key entryMost network and PCIe HSMs for PKI and payments
4Adds protection against environmental attacks (voltage and temperature out of range) and a complete protective envelopeFew products; very high assurance use

Three details matter more than the headline number:

  1. Certificates are per module and firmware version. Look up the certificate number in the CMVP database and check the exact hardware and firmware versions listed.
  2. The security policy document defines the approved mode. Running the module outside that configuration can take you out of the validated state.
  3. Historical certificates move to the historical list after their sunset date. Existing deployments can often continue, but new procurements usually require an active certificate.

Other schemes you will see: Common Criteria evaluations (often EAL4+ against a protection profile such as EN 419221-5 for trust services in the EU), and PCI PTS HSM for payment HSMs.

Form factors

Form factorShapeGood forTrade-offs
Network HSM1U/2U appliance on the LANShared service for many applications, PKI, clusteringRequires rack space, network design, client software
PCIe cardCard inside one serverLow latency for a single host, offline root CAsTied to one machine; availability depends on that host
USB HSM / tokenSmall USB deviceOffline root CA, small teams, lab work, code signing on one workstationLower throughput, fewer management features
Cloud HSM (single-tenant)Dedicated HSM in a cloud regionCloud workloads that need their own module and PKCS#11You manage clusters and backups; the provider manages hardware
Cloud KMSMulti-tenant API backed by HSMsEnvelope encryption, most application keysYou do not control the module; limited algorithms and APIs

APIs and integration

The API decides how much work integration will be:

  • PKCS#11 (Cryptoki) is the lingua franca: OpenSSL (via a provider or engine), Java via SunPKCS11, EJBCA, HashiCorp Vault, BIND and OpenDNSSEC, signing tools and many databases speak it.
  • Microsoft CNG / KSP for Windows services such as AD CS and SignTool.
  • Java JCE/JCA providers for Java applications.
  • KMIP for key lifecycle management between a key manager and storage or database encryption.
  • Vendor REST or SDK APIs, increasingly common for cloud and newer appliances.

Before buying, list every application that will use the HSM and confirm the exact mechanism support (for example ECDSA on P-384, RSA-PSS, EdDSA, AES-GCM, or post-quantum algorithms such as ML-DSA if you plan to pilot them).

Developing against PKCS#11 without hardware

SoftHSM2 implements PKCS#11 in software, which makes it ideal for development and CI pipelines:

# Create a token
softhsm2-util --init-token --free --label dev-token --so-pin 0000 --pin 1234

# List slots and tokens with OpenSC's generic tool
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --list-slots

# Generate an EC P-256 key pair on the token
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --login --pin 1234 \
  --keypairgen --key-type EC:prime256v1 --label signing-key

# List objects
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --login --pin 1234 --list-objects

The module path varies by distribution (for example /usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so on Debian and Ubuntu). When you move to a real HSM, you change the module path and the credentials, not the application logic. The PINs above are throwaway development values.

Use cases and what they need

Use caseKey requirementTypical choice
Offline root CAHighest assurance, rarely used, strict ceremonyUSB or PCIe HSM in a safe, FIPS 140 Level 3
Issuing CAOnline, audited, highly availableNetwork HSM cluster
Public code signingIndustry rules require keys in hardwareFIPS 140 Level 2+ or Common Criteria EAL4+ token or HSM, or a cloud signing service backed by one
DNSSECAutomated signing, key rolloverNetwork HSM or cloud HSM with PKCS#11
Payments (PIN, card keys)PCI PTS HSM, payment-specific commandsDedicated payment HSM
Application secrets, database TDEEnvelope encryption at scaleCloud KMS or KMIP key manager backed by HSM

For publicly trusted code-signing certificates, the CA/Browser Forum baseline requirements have required private keys to be generated and stored in hardware meeting FIPS 140-2 Level 2 or Common Criteria EAL4+ since June 2023. That rule is why developers now receive signing certificates on tokens or use cloud signing services.

Key ceremonies and quorum

For root keys, the way you use the HSM matters as much as the HSM:

  1. Script the ceremony in advance: every command, every role, expected outputs.
  2. Use split knowledge and dual control. Quorum authentication (for example 3 of 5 cards) for key generation, backup and restore.
  3. Record everything. Video, signed logs, witness signatures, hashes of exported public keys and certificates.
  4. Back up keys to other HSMs using the vendor's wrapped backup mechanism, and store backup tokens in separate locations.
  5. Store credentials separately from the device: smart cards and PINs in different safes held by different people.

Selection checklist

  • Which regulation, certificate policy or contract sets the minimum assurance level?
  • Is there an active FIPS 140-3 (or required Common Criteria / PCI) certificate for the exact model and firmware?
  • Does it support every algorithm and API your applications need, today and on your cryptographic roadmap?
  • How are high availability, clustering, backup and disaster recovery handled?
  • What does role separation and quorum look like, and can it be enforced by policy?
  • How are firmware updates delivered and validated, and what happens to certification after an update?
  • What are the support lifetime and end-of-life policy, and how do you migrate keys to a successor model?
  • How does the device log, and can those logs reach your SIEM?

An HSM does not fix weak processes. It gives you a boundary that keys cannot leave; your ceremonies, access control and monitoring decide who gets to ask it to sign.

Related guides

U8 · Selection & supply chain
A vendor-neutral method for selecting security hardware: what FIPS 140-3, Common Criteria and FIDO certifications prove, supply-chain checks on delivery, firmware policy, spares and secure disposal.