September 26, 2021

Key Management


Cryptographic keys shall be generated within cryptographic module with at least a FIPS 140-2 compliance. For explanatory purposes, consider the cryptographic module in which a key is generated to be the key-generating module.

Any random value required by the key-generating module shall be generated within that module; that is, the Random Bit Generator that generates the random value shall be implemented within cryptographic module with at least a FIPS 140-2 compliance that generates the key.

Hardware cryptographic modules are preferred over software cryptographic modules for protection.


The generated keys shall be transported (when necessary) using secure channels and shall be used by their associated cryptographic algorithm within at least a FIPS 140-2 compliant cryptographic modules. For additional detail for the recommendations in this section refer to NIST Special Paper 800-133.


  1. Developers must understand where cryptographic keys are stored within the application. Understand what memory devices the keys are stored on.
  2. Keys must be protected on both volatile and persistent memory, ideally processed within secure cryptographic modules.
  3. Keys should never be stored in plaintext format.
  4. Ensure all keys are stored in cryptographic vault, such as a hardware security module (HSM) or isolated cryptographic service.
  5. If you are planning on storing keys in offline devices/databases, then encrypt the keys using Key Encryption Keys (KEKs) prior to the export of the key material. KEK length (and algorithm) should be equivalent to or greater in strength than the keys being protected.
  6. Ensure that keys have integrity protections applied while in storage (consider dual purpose algorithms that support encryption and Message Code Authentication (MAC)).
  7. Ensure that standard application level code never reads or uses cryptographic keys in any way and use key management libraries.
  8. Ensure that keys and cryptographic operation is done inside the sealed vault.
  9. All work should be done in the vault (such as key access, encryption, decryption, signing, etc).





  • Restrict API keys:
    • Source IP
    • referrer URLS
    • Mobile App
  • Unique API keys per application
  • Monitor API usage
  • Don’t put API keys in code, put them in environment variables instead