Cryptographic key management¶
Name¶
Cryptographic key management
Summary¶
When integrating cryptographic primitives into a system a crucial aspect is correctly managing any cryptographic keys this will involve. In most circumstances cryptographic keys should be kept confidential and their integrity should be protected throughout their life cycle. For some types of keys, such as the public key in an asymmetric key pair, the confidentiality requirement can be relaxed.
Parent¶
None
Problem¶
This pattern does not directly address a security problem of this catalogue, but encapsulates common issues when applying solutions involving cryptography.
Solution¶
Proper key management is one of the most crucial aspects when applying cryptography to mitigate (potential) security problems. Any security guarantees provided by a cryptosystem can be nullified if an attacker can obtain or tamper with the used cryptographic key(s). For example, an attacker that obtains a, supposedly, secret session key will be able to decrypt all messages encrypted with that key.
This pattern encapsulates the commonalities between the two most common implementations for managing cryptographic keys. To this end, we only consider an abstract cryptographic action, i.e. an generic action involving a cryptographic key, in this pattern. The Cryptographic action pattern and its children address further security considerations with respect specific cryptographic actions such as encryption and generating digital signatures.
Roles¶
- Entity (: Entity) the entity that wants to generate a cryptographic key to be used in one or more cryptographic actions
- Cryptographer (: Cryptographic primitive) the cryptographic library actually generating the key and performing cryptographic actions
Actions¶
- generate_key (: Action) generate a new cryptographic key according to the given configuration, if provided
- crypto_action (: Action) request to perform a cryptographic action, e.g. encryption or generating a digital signature, on a given input using the identified key
Data elements¶
- keyConf (: Data) the configuration according to which the key must be generated, e.g. symmetric or asymmetric and desired key length (Optional)
- Tags: Untampered
- keyInfo (: Data) information on the cryptographic key to be used when performing a cryptographic action.
Depending on the chosen pattern implementation this can be an identifier so that the
Cryptographerknows which key to use or the cryptographic key itself.- Tags: Untampered[, Secret]
- input (: Data) the plaintext input on which the cryptographic action should be performed
- output (: Data) the result of performing the requested cryptographic action, e.g. a ciphertext or digital signature
- config (: Data) the configuration for the
Cryptographercontaining, for example, the desired cipher (mode) (Optional)- Tags: Untampered
Behaviour¶
The generation of a new cryptographic key at least involves two steps:
- The
Entityrequests theCryptographerto generate a new key that, if provided, satisfies a given configuration. - The
Cryptographergenerates the requested key and replies the information theEntityneeds to used the key in future actions requests. The exact information replied depends on the implementation that is selected.
In order to use a previously generated key the Entity must use the keyInfo received on generation.
The behaviour described below is further refined to specific cryptographic actions in the Cryptographic action
pattern and its implementations.
- The
Entityrequests theCryptographerto perform a cryptographic action and provides at least the input on which the action must be performed as well as the information necessary to identify the desired key. The exact information depends on the implementation that is selected. - The
Cryptographerperforms the requested operation and replies the result to theEntity.

Role considerations¶
The implementations of this pattern address the appropriate role considerations.
Data considerations¶
keyConf¶
If provided, the key configuration should be protected from undetected tampering while transmitted over an uncontrolled channel and/or persistently stored by the Entity.
For example, an attacker may change the key configuration to generate a shorter key than advised, allowing him or her to more easily break any ciphertexts encrypted with this shorter key.
keyInfo¶
After generating a key the Entity receives cryptographic key information from the Cryptographer which the Entity will process and use in further interactions with the Cryptographer.
The exact information and necessary security measures depend on the chosen pattern implementation.
In any case, additional precautions should be taken to detect unauthorised tampering when keyInfo is transmitted over an uncontrolled channel and/or it the if the Entity stores it persistently.
An attacker that can influence the keyInfo at any point might change the key used to one that is under his or her control.
For example, in case of encryption the attacker might tamper with the keyInfo such that a key is used that the attacker also knows such that it can decrypt the ciphertext.
config¶
See Cryptographic action.config
Implementations¶
References¶
Some pointers to concrete libraries and services are provided in the references sections of the implementing patterns.