|
| 1 | +.. Licensed to the Apache Software Foundation (ASF) under one |
| 2 | + or more contributor license agreements. See the NOTICE file |
| 3 | + distributed with this work for additional information |
| 4 | + regarding copyright ownership. The ASF licenses this file |
| 5 | + to you under the Apache License, Version 2.0 (the |
| 6 | + "License"); you may not use this file except in compliance |
| 7 | + with the License. You may obtain a copy of the License at |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + Unless required by applicable law or agreed to in writing, |
| 10 | + software distributed under the License is distributed on an |
| 11 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 12 | + KIND, either express or implied. See the License for the |
| 13 | + specific language governing permissions and limitations |
| 14 | + under the License. |
| 15 | +
|
| 16 | +.. _key-management-system: |
| 17 | + |
| 18 | +Key Management System (KMS) |
| 19 | +============================ |
| 20 | + |
| 21 | +Introduced in Apache CloudStack 4.23, the Key Management System (KMS) lets you encrypt |
| 22 | +storage volumes using keys stored in a hardware security module (HSM). |
| 23 | +Previously, volume passphrases were encrypted with a single key stored in the |
| 24 | +database. If no KMS key is provided, CloudStack falls back to this legacy behavior. |
| 25 | + |
| 26 | +.. _kms-architecture: |
| 27 | + |
| 28 | +Architecture and Design |
| 29 | +----------------------- |
| 30 | + |
| 31 | +KMS is built around a two-tier key hierarchy to protect data at rest: |
| 32 | + |
| 33 | +- **KEK (Key Encryption Key)** — The master key that never leaves the secure backend. KEKs |
| 34 | + are stored in and managed by the configured KMS provider. |
| 35 | +- **DEK (Data Encryption Key)** — The key that encrypts the actual data (e.g., Volumes). |
| 36 | + DEKs are stored wrapped by the KEK and are only decrypted in memory when needed. |
| 37 | + |
| 38 | +.. image:: /_static/images/kms-architecture.png |
| 39 | + :align: center |
| 40 | + :alt: KMS architecture diagram showing providers, KEK, DEK, and Volume Data layers |
| 41 | + |
| 42 | + |
| 43 | +Pluggable Provider Framework |
| 44 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 45 | + |
| 46 | +The KMS architecture is designed to be extensible. CloudStack currently ships two providers: |
| 47 | + |
| 48 | +- **Database Provider** — A built-in fallback provider that stores |
| 49 | + wrapped keys in the CloudStack database. Suitable for environments without dedicated HSM |
| 50 | + hardware. |
| 51 | +- **PKCS#11 HSM Provider** — Integrates with dedicated Hardware |
| 52 | + Security Module devices via the PKCS#11 standard allowing integration with |
| 53 | + various HSM providers. |
| 54 | + |
| 55 | +HSM Profiles |
| 56 | +^^^^^^^^^^^^ |
| 57 | +Each KMS Key is stored in a Hardware Security Module. The root admin registers |
| 58 | +**HSM Profiles** that capture the connection configuration for a specific HSM device |
| 59 | +(e.g., PKCS#11 library path, slot, PIN). Sensitive fields such as |
| 60 | +PINs and passwords are automatically encrypted at rest and masked in responses. |
| 61 | + |
| 62 | +.. note:: |
| 63 | + HSM Profiles can be created only by root administrators and can be scoped to a zone, |
| 64 | + account, or can be made global (available to all zones). |
| 65 | + |
| 66 | +.. _kms-hsm-profiles: |
| 67 | + |
| 68 | +Managing HSM Profiles |
| 69 | +--------------------- |
| 70 | + |
| 71 | +Before creating a KMS key, an administrator must register an HSM |
| 72 | +Profile. |
| 73 | + |
| 74 | +Adding an HSM Profile |
| 75 | +^^^^^^^^^^^^^^^^^^^^^ |
| 76 | + |
| 77 | +#. Log in to the CloudStack UI as a root administrator. |
| 78 | + |
| 79 | +#. In the left navigation bar, click **HSM Profile** under **Key Management**. |
| 80 | + |
| 81 | +#. Click on **Add HSM Profile +**. |
| 82 | + |
| 83 | +#. Provide the following details: |
| 84 | + |
| 85 | + - **Name** — A unique name for the profile. |
| 86 | + - **Zone** — The zone this profile is scoped to. Leave blank to make it available to all zones. |
| 87 | + - **Vendor Name** — The HSM device vendor. |
| 88 | + - **System** — Check this to make the profile globally available. Uncheck to scope it to an account or zone. |
| 89 | + - **Details** — Protocol-specific key-value pairs such as ``library``, ``slot``, and |
| 90 | + ``pin`` for PKCS#11. |
| 91 | + |
| 92 | + .. image:: /_static/images/kms-add-hsm-profile.png |
| 93 | + :align: center |
| 94 | + :alt: Add HSM Profile dialog |
| 95 | + |
| 96 | +#. Click **OK**. |
| 97 | + |
| 98 | + |
| 99 | +.. note:: |
| 100 | + If access to the HSM is lost, CloudStack will be unable to access |
| 101 | + volumes encrypted with the keys managed by this HSM profile and the |
| 102 | + volumes will be inaccessible. |
| 103 | + |
| 104 | +.. note:: |
| 105 | + Sensitive fields (PINs, passwords) are automatically masked in the UI and API responses |
| 106 | + after the profile is created. |
| 107 | + |
| 108 | +.. note:: |
| 109 | + The operator has to ensure that the required HSM libraries are installed on |
| 110 | + all the management servers and depending on the HSM provider, there might be |
| 111 | + some additional configuration required on each of the management servers. |
| 112 | + |
| 113 | +.. _kms-key-lifecycle: |
| 114 | + |
| 115 | +Managing KMS Keys |
| 116 | +----------------- |
| 117 | + |
| 118 | +KMS Keys (Key Encryption Keys / KEKs) are **zone-scoped**: a key created in one zone |
| 119 | +cannot be used in another. Keys can be created by users and administrators. |
| 120 | + |
| 121 | +Creating a KMS Key |
| 122 | +^^^^^^^^^^^^^^^^^^ |
| 123 | + |
| 124 | +#. Log in to the CloudStack UI. |
| 125 | + |
| 126 | +#. In the left navigation bar, click **KMS Keys** under **Key Management**. |
| 127 | + |
| 128 | +#. Click **Create KMS Key +**. |
| 129 | + |
| 130 | +#. Provide the following details: |
| 131 | + |
| 132 | + - **Name** — A name for the key. |
| 133 | + - **Description** — An optional description. |
| 134 | + - **Zone** — The zone in which the key will be valid. |
| 135 | + - **HSM Profile** — The HSM profile to use as the backend for this key. |
| 136 | + - **Key Size** — Bits for the KEK: ``128``, ``192``, or ``256`` (default). |
| 137 | + |
| 138 | + .. image:: /_static/images/kms-create-key.png |
| 139 | + :align: center |
| 140 | + :alt: Create KMS Key dialog |
| 141 | + |
| 142 | +#. Click **OK**. The key is created in the specified HSM and becomes available for |
| 143 | + encrypting volumes in the selected zone. |
| 144 | + |
| 145 | +.. _kms-key-rotation: |
| 146 | + |
| 147 | +Rotating a KMS Key |
| 148 | +^^^^^^^^^^^^^^^^^^ |
| 149 | + |
| 150 | +Key rotation generates a new version of the KEK and automatically schedules background |
| 151 | +re-encryption of all DEKs protected by the old version. This is an asynchronous operation. |
| 152 | + |
| 153 | + |
| 154 | +#. In the left navigation bar, click **KMS Keys** under **Key Management**. |
| 155 | + |
| 156 | +#. Open the Details page for the key you want to rotate. |
| 157 | + |
| 158 | +#. Click the **Rotate KMS Key** button. |
| 159 | + |
| 160 | + .. image:: /_static/images/kms-rotate-key.png |
| 161 | + :align: center |
| 162 | + :alt: Rotate Key option in KMS Keys list |
| 163 | + |
| 164 | +#. Confirm the rotation. A background job is created that progressively rewraps all DEKs |
| 165 | + to the new KEK version without ever exposing the plaintext DEKs. |
| 166 | + |
| 167 | +.. note:: |
| 168 | + The rewrapping job runs in batches. The ``kms.rewrap.batch.size`` and |
| 169 | + ``kms.rewrap.interval.ms`` settings control how quickly DEKs are re-encrypted |
| 170 | + after rotation (see :ref:`kms-configuration`). |
| 171 | + |
| 172 | +.. _kms-volume-migration: |
| 173 | + |
| 174 | +Migrating Existing Volumes to KMS |
| 175 | +---------------------------------- |
| 176 | + |
| 177 | +Existing volumes that use older passphrase-based encryption can be migrated to KMS-managed |
| 178 | +envelope encryption without data loss. This is an administrator-only operation and is |
| 179 | +performed using the ``migrateVolumesToKMS`` API. The migration runs as an asynchronous |
| 180 | +background job. |
| 181 | + |
| 182 | +.. note:: |
| 183 | + Migrated volumes will be re-encrypted under the KMS envelope encryption model, removing |
| 184 | + the dependency on a static passphrase. Scope the migration by zone, account, or domain, |
| 185 | + or provide specific volume IDs for selective migration. |
| 186 | + |
| 187 | +For full API parameter details, see the |
| 188 | +`CloudStack API Reference <https://cloudstack.apache.org/api/>`_. |
| 189 | + |
| 190 | +.. _kms-configuration: |
| 191 | + |
| 192 | +KMS Configuration Settings |
| 193 | +-------------------------- |
| 194 | + |
| 195 | +The following global configuration settings are available to tune KMS behaviour. They can |
| 196 | +be found under **Global Settings** in the CloudStack UI. |
| 197 | + |
| 198 | +.. cssclass:: table-striped table-bordered table-hover |
| 199 | + |
| 200 | +=============================== ============= ================================================= |
| 201 | +Configuration Default Description |
| 202 | +=============================== ============= ================================================= |
| 203 | +``kms.dek.size.bits`` ``256`` Size of generated DEKs in bits. Valid values |
| 204 | + are ``128``, ``192``, and ``256``. |
| 205 | +``kms.retry.count`` ``3`` Number of retry attempts on transient KMS |
| 206 | + operation failures. |
| 207 | +``kms.retry.delay.ms`` ``1000`` Base delay in milliseconds for exponential |
| 208 | + back-off between retry attempts. |
| 209 | +``kms.operation.timeout.sec`` ``30`` Timeout in seconds for a single KMS |
| 210 | + cryptographic operation. |
| 211 | +``kms.rewrap.batch.size`` ``50`` Number of DEKs to rewrap per background job |
| 212 | + iteration during KEK rotation. |
| 213 | +``kms.rewrap.interval.ms`` ``300000`` Interval in milliseconds between background |
| 214 | + DEK rewrapping runs (default: 5 minutes). |
| 215 | +=============================== ============= ================================================= |
0 commit comments