July 21, 2021 By Henrik Loeser 4 min read

Encrypt your cloud data with your own keys for more security.

Whether as consumers or developers, most of us use cloud services. In this blog post, I look at the developer side of securing data stored in cloud services. By default (and following best practices), cloud service providers encrypt stored data (“data at rest“). Encryption is performed with system keys. I, as a developer, don’t need to set or enable anything for that baseline protection.

With some configuration and starting from that baseline, I can transform my cloud account into a highly secured environment. I can use my own keys for data encryption. For that, I can even tap into the concept of BYOK (bring your own key); in other words, importing keys that I generated somewhere else, like in an on-premises key management system (KMS). IBM Cloud even has two KMSs — the IBM Key Protect for IBM Cloud service provides FIPS 140-2 Level 3 security and IBM Cloud Hyper Protect Crypto Services is even a FIPS 140-2 Level 4 certified security service.

In the following, I give an overview of encrypting data with your own keys and where to find the long list of supported services. Thereafter, I show what it takes to add your keys, both for creating and rotating root keys:

Bring your own keys to IBM Cloud.

Encrypt with your own keys

As a security best practice, all stored data should be encrypted; therefore, cloud providers encrypt all data at rest. By default, data is encrypted with system keys controlled by the cloud provider. To increase the security level, you should take control of the encryption keys. Typically, this is done by provisioning a key management system (KMS), creating your own root keys and configuring the data processing services to take your keys instead of the system root keys to encrypt the data.

IBM Cloud has two KMS offerings: IBM Key Protect for IBM Cloud and IBM Cloud Hyper Protect Crypto Services (HPCS). Both of them integrate with a long — but still growing list — of services (e.g., list of services for Key Protect, list of integrations for HPCS). The services have many similarities and even share the same CLI (command line interface) commands and API (Application Programming Interface), but they differ on the level of security. Key Protect is a KMS service on shared hardware (Hardware Security Module, HSM) whereas HPCS is a dedicated KMS and HSM offering. The result is different FIPS 140-2 certification levels (see above) and what the services provide: BYOK vs. KYOK.

In addition to generating new root keys in the KMS, you can import your own keys into that KMS. The KMS is backed by special tamper-proof hardware for performing cryptographic operations — the HSM. Before a HSM can be utilized, it needs to be initalized, the crypto unit imprinted, the master key loaded and the so-called root of trust established. For shared services like Key Protect, the cloud provider already has initialized the HSM and therefore owns the root of trust. Thus, as a user, you can bring your own key (BYOK), but you kind of hand it over to the cloud provider who manages the KMS.

To really keep your own key (KYOK), you need to control the HSM and initialize it. This can only be done when utilizing a dedicated HSM like, for example, IBM Cloud Hyper Protect Crypto Services. After provisioning the service, you or your crypto administrators have to perform the setup steps. As a result, you own the root of trust and, when importing your existing keys, can keep your own keys.

Securely import your keys

To utilize the BYOK/KYOK feature, you have to import your existing key (“key material”) when creating a key in the KMS. The actual transfer of that key material over the network, by default, is secured using the usual SSL/TLS encryption. That level of encryption might be ok for test environments and prototyping. For production systems, you should use an import token to protect your key material. The token is part of a cryptographic handshake protocol to both encrypt the key material and to make sure it originates from you. 

The process of securely importing a key involves a couple of steps:

  • Generate the import token consisting of a public/private key pair
  • Retrieve the public key and a nonce (i.e., a unique one-time passcode)
  • Encrypt your key material with the retrieved public key
  • Encrypt the retrieved nonce with your key (material) and create an initialization vector (IV)
  • Upload everything (encrypted key material, encrypted nonce, IV) to create or rotate the key

All those steps can be performed with the IBM Cloud CLI and the Key Protect plugin. Because you love automation like I do, I created two scripts that put the above steps for either creating or rotating a key together. Check them out for details on how to encrypt the required parts for the handshake.

Conclusions

Data encryption is key to cloud security. As a user, you can take control of encryption by replacing system-generated keys with your own keys. Depending on your required level of security and, hence, the provisioned key management system, you can either bring your own keys or even keep your own keys. When doing so, make use of import tokens for highest security. There are few steps involved, but they are easy to follow. See my scripts in the GitHub repository cloud-key-security for details.

If you have other feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn

Was this article helpful?
YesNo

More from Cloud

How a US bank modernized its mainframe applications with IBM Consulting and Microsoft Azure

9 min read - As organizations strive to stay ahead of the curve in today's fast-paced digital landscape, mainframe application modernization has emerged as a critical component of any digital transformation strategy. In this blog, we'll discuss the example of a US bank which embarked on a journey to modernize its mainframe applications. This strategic project has helped it to transform into a more modern, flexible and agile business. In looking at the ways in which it approached the problem, you’ll gain insights into…

The power of the mainframe and cloud-native applications 

4 min read - Mainframe modernization refers to the process of transforming legacy mainframe systems, applications and infrastructure to align with modern technology and business standards. This process unlocks the power of mainframe systems, enabling organizations to use their existing investments in mainframe technology and capitalize on the benefits of modernization. By modernizing mainframe systems, organizations can improve agility, increase efficiency, reduce costs, and enhance customer experience.  Mainframe modernization empowers organizations to harness the latest technologies and tools, such as cloud computing, artificial intelligence,…

Modernize your mainframe applications with Azure

4 min read - Mainframes continue to play a vital role in many businesses' core operations. According to new research from IBM's Institute for Business Value, a significant 7 out of 10 IT executives believe that mainframe-based applications are crucial to their business and technology strategies. However, the rapid pace of digital transformation is forcing companies to modernize across their IT landscape, and as the pace of innovation continuously accelerates, organizations must react and adapt to these changes or risk being left behind. Mainframe…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters