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.
- Developers must understand where cryptographic keys are stored within the application. Understand what memory devices the keys are stored on.
- Keys must be protected on both volatile and persistent memory, ideally processed within secure cryptographic modules.
- Keys should never be stored in plaintext format.
- Ensure all keys are stored in cryptographic vault, such as a hardware security module (HSM) or isolated cryptographic service.
- 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.
- Ensure that keys have integrity protections applied while in storage (consider dual purpose algorithms that support encryption and Message Code Authentication (MAC)).
- Ensure that standard application level code never reads or uses cryptographic keys in any way and use key management libraries.
- Ensure that keys and cryptographic operation is done inside the sealed vault.
- 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