I am trying to understand the internal storage scheme used by HSMs to store the private keys. My question is: are keys stored in plaintext inside an HSM? Are there any variations?


Every HSM will be a unique implementation.

I know that the IBM PCIe Cryptographic Coprocessor stores master keys inside the HSM, which are used to decrypt the keys that are kept encrypted in an external database. The older version used 3DES to encrypt the keys; I don't know if V2 still uses 3DES or if they're using AES now. Tampering with the HSM (or even violating its environmental envelope of temperature and humidity) securely destroys the internal keys and certificates, as well as rendering the HSM itself physically inoperable.

Inexpensive HSMs, such as a PIN pad you'd find at the grocery store, maintain their key state in battery-backed RAM. Note that because PIN pads are out on countertops where they can be stolen or tampered with, they aren't trusted with a "master" key that's the same for all PIN pads. Instead, they follow a key generation protocol called Derived Unique Key Per Transaction (DUKPT). DUKPT specifies that each pad has a unique key injected at a secure facility before being shipped to the stores. The PIN pad's unique key is derived from the system's base master key and the PIN pad's serial number, and DUKPT implements a "future key" generation scheme, which continually rotates forward with every use, destroying the old keys as it goes. Attempting to violate the case will result in the CPU quickly scrambling the RAM and then cutting power to it, wiping the future key state.

I'm sure other HSMs have different variations on the theme, but they all behave in a similarly self-protective fashion.

  • Thanks for your reply. However, what I wanted to know was whether the key is stored in plaintext or after encryption inside an HSM. I am sorry if I was not very clear in my original message.
    – Fakhar
    Feb 28 '17 at 9:58
  • The key exists in cleartext inside an operating HSM, or else the device is useless. And it doesn't really matter how the bits are kept in the storage medium. If it's stored on a separate chip from the CPU, whatever stored bits are transmitted to the CPU are the "key to the key". Whether it's stored on the same chip as the CPU, or baked into an FPGA, it still exists. For a more specific answer, you would have to ask your HSM vendor, as each device is free to implement their solution however they see fit. Feb 28 '17 at 18:58
  • That was exactly what I was looking for. Thanks for your help.
    – Fakhar
    Mar 1 '17 at 6:45
  • How the key is "stored" on the HSM is also vendor dependent. The device /probably/ has an internal master key that is used to encrypt anything "at rest" (keys have to survive a reboot, so they will be stored in flash or other nvram). When at rest, they should be encrypted using the internal master key, so that if the device is compromised the only thing that needs to be destroyed to protect the keys is the internal master key. With that gone, the data at rest is no longer useful. The architecture will cache keys in use, in ram, and those will probably be 'in plain'.
    – rip...
    Apr 27 '17 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.