Hardcoded Encryption Key Management

Diksha Gautam
Globant
Published in
5 min readSep 13, 2022
Key Management: Hardcoded Encryption Key
Photo by regularguy.eth on Unsplash

What is Encryption Key?

A Process that uses algorithms to encode data as cypher text. This cypher text can only be made meaningful again if the person or application accessing the information has the encryption keys necessary to decode the cypher text. So, if the info is stolen or accidentally shared, it’s protected because it’s indecipherable, because of encryption. An encryption strategy is simply pretty much as good because of the protection of the encryption keys.

Need for Key Management :

Since a cybercriminal may restore encrypted data to its initial unencrypted form using encryption keys, controlling and managing these keys is essential to any encryption strategy. The creation, exchange, storage, usage, destruction, and replacement of encryption keys are all part of an encryption key management system. Therefore, we must make improvements and adhere to certain procedures to guarantee the effective administration of encryption keys.

Key Considerations

Encryption Algorithms and sizes:

The appropriate algorithm and key size must be selected for each key set. This may depend on the intended use and may take into consideration a variety of things like performance, security, interoperability, lifespan, etc.

  • Algorithm Selection: A symmetric algorithm (like AES) or an asymmetric algorithm (like RSA or ECDSA) should be selected, as applicable.
  • Key size: the selection of key size (typically 128 or 256 bits for AES keys, or 2,048 or 4,096 bits for RSA keys) should be made carefully. The larger the key, the safer it’s and therefore the longer it’ll provide protection, but performance could also be impacted (especially with large asymmetric keys)
  • Flexibility: As algorithms deteriorate over time, be ready to change them as well as key sizes.

Secure storage:

Given the importance of encryption keys and their storage, which if not securely maintained might attract hackers, especially when several keys are stored in the same location. If the key must be physically stored, it is advisable to use a hardware security module (HSM), which provides very strong physical and logical security protection.KMS is another excellent method for virtually protecting and managing keys on cloud systems.

Key lifecycle management:

Each encryption key has a lifetime. As a result, it must be carefully regulated by following the methods outlined below:

  • Key Generation
  • Key Rotation
  • Key Deletion/Retirement
key lifecycle
Encryption key lifecycle

Centralize User Roles & Access:

Keys should only be accessible to those who need to know. You should specify these responsibilities inside the centralised key management so that only authorised users are granted access to encrypted data connected to that specific user profile, hence reducing the risk and/or effect of harmful activity. Furthermore, we should employ the twin control concept, which requires at least two approvers to approve essential activities such as key rotation, usage, or deletion.

Secure Distribution:

Keys are often conveyed from their origin to the system where they will be used. This is best performed by using a purpose-built secure API, such as the Key Management Interoperability Protocol (KMIP). If a key must be transported offline, it should be wrapped in a secure transit key and/or separated into two or three components — this employs the “split knowledge principle” to ensure that no one person has access to only one component, which is useless without the opposite component (s).

Key Usage:

Only utilise keys for their designated function. It is advisable to restrict each key’s permissions so that it is only used for that purpose (e.g. encryption, decryption, signing, verification, wrapping, unwrapping, etc.). Several “key block” formats are available to tie the permissions to the key if it has to be communicated to another system, such as ASC X9 TR-31 (used in the payments industry).

Availability:

Keys are kept somewhere, though, and they must always be accessible when needed for encryption to work. Therefore, high availability may be an important design factor. Similarly, keys must be protected against accidental loss, as this might render data inaccessible permanently; hence, secure backup is another critical feature.

Audit logs:

Audit logs should be retained, including a complete history of each key’s creation, use, and deletion. Every operation should be documented, including the action taken, who or what took it, and when it occurred. Should the key ever be compromised, this will be useful for compliance audits and forensic investigations. Integration with SIEM technologies is advantageous for merging numerous logs as well as for additional analysis and reporting.

Centralized Key Management System:

A centralised KMS becomes necessary when we have hundreds or thousands of encryption keys. To improve encryption key maintainability, we can employ third-party encryption key management services. These services securely keep all encryption keys and digital certificates in a key vault apart from the encrypted data and systems. This is frequently useful from a security standpoint since the keys are secured regardless of whether the information is hacked. Because the encryption keys are held centrally, the number of sites where the keys might be exposed to attackers is reduced. The centralised method is better in terms of security, but it also increases efficiency since encryption-decryption procedures occur locally where the information is kept

eg: AWS KMS

AWS KMS

External KMS: The best practice is to use a dedicated external KMS. There are four types :

  1. Use of HSM or other hardware key management appliance, which provides the highest level of physical security
  2. A key management virtual appliance
  3. Key management software, which can run either on a dedicated server or within a virtual/cloud server
  4. Key Management Software as a Service (SaaS)

Summary :

Having a hardcoded, null encryption key or putting an encryption key in a file and keeping it on the server or locally does not assure data or encryption key security. We always propose utilising a cloud-based cryptography solution based on the foregoing major considerations. The following are some cloud-based cryptography solutions:

--

--