Skip to content

Feature: Key Management Service (KMS) - #12711

Merged
harikrishna-patnala merged 43 commits into
apache:mainfrom
shapeblue:feature-kms
Jun 30, 2026
Merged

Feature: Key Management Service (KMS)#12711
harikrishna-patnala merged 43 commits into
apache:mainfrom
shapeblue:feature-kms

Conversation

@vishesh92

@vishesh92vishesh92 commented Feb 26, 2026

Copy link
Copy Markdown
Member

Key Management Service (KMS) with HSM Integration

Description

Introduces a Key Management Service (KMS) framework for CloudStack that provides envelope encryption for volume encryption. KEKs (Key Encryption Keys) stored in PKCS#11-compliant HSMs or the CloudStack database wrap per-volume DEKs (Data Encryption Keys), ensuring key material is never stored in plaintext.

Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Key+Management+Service+%28KMS%29+with+HSM+Integration
Docs PR: apache/cloudstack-documentation#634

New APIs

APIAuthDescription
createKMSKeyAll usersCreate a KMS key (KEK) bound to an HSM profile
listKMSKeysAll usersList KMS keys
updateKMSKeyAll usersUpdate name, description, or enabled state
deleteKMSKeyAll usersDelete a KMS key (if not in use)
rotateKMSKeyAdminRotate KEK with optional cross-HSM migration
migrateVolumesToKMSAdminMigrate passphrase-encrypted volumes to KMS
addHSMProfileAdminAdd HSM profile configuration
listHSMProfilesAll usersList available HSM profiles
updateHSMProfileAdminUpdate HSM profile
deleteHSMProfileAdminDelete HSM profile

New Database Tables

kms_hsm_profiles, kms_hsm_profile_details, kms_keys, kms_kek_versions, kms_wrapped_key, kms_database_kek_objects

Modified: cloud.volumes — added kms_key_id and kms_wrapped_key_id columns.

New Global Settings

SettingDefaultDescription
kms.dek.size.bits256DEK size in bits
kms.retry.count3Retry attempts for transient failures
kms.retry.delay.ms1000Delay between retries
kms.operation.timeout.sec30Per-operation timeout
kms.rewrap.batch.size50Keys rewrapped per background batch
kms.rewrap.interval.ms300000Background rewrap interval

UI Changes

  • New KMS top-level menu with KMS Keys and HSM Profiles sub-sections
  • KMS key selection in Deploy VM and Create Volume wizards
  • HSM profile management restricted to Admin users in UI

How to Test

Tested with:

# 1. Add an HSM profile (use SoftHSM2 for testing)# 2. Create a KMS key with HSM profile# 3. Create a disk offering with Encryption enabled# 4. Deploy a VM/create a volume and specify the KMS key

@codecov

codecovBot commented Feb 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.45926% with 2752 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.74%. Comparing base (be51948) to head (7410669).
⚠️ Report is 16 commits behind head on main.

Files with missing linesPatch %Lines
...java/org/apache/cloudstack/kms/KMSManagerImpl.java34.21%718 Missing and 32 partials ⚠️
...udstack/kms/provider/pkcs11/PKCS11HSMProvider.java13.32%428 Missing and 8 partials ⚠️
...e/cloudstack/kms/provider/DatabaseKMSProvider.java0.00%145 Missing ⚠️
...apache/cloudstack/api/response/KMSKeyResponse.java0.00%115 Missing ⚠️
.../kms/provider/database/KMSDatabaseKekObjectVO.java0.00%106 Missing ⚠️
.../main/java/org/apache/cloudstack/kms/KMSKeyVO.java19.46%91 Missing ⚠️
...he/cloudstack/api/response/HSMProfileResponse.java23.85%83 Missing ⚠️
...n/java/org/apache/cloudstack/kms/HSMProfileVO.java0.00%76 Missing ⚠️
...ava/org/apache/cloudstack/kms/KMSWrappedKeyVO.java11.53%68 Missing and 1 partial ⚠️
...stack/engine/orchestration/VolumeOrchestrator.java8.92%50 Missing and 1 partial ⚠️
... and 51 more
Additional details and impacted files
@@ Coverage Diff @@## main #12711 +/- ##
============================================
+ Coverage 18.10% 18.74% +0.63% - Complexity 16750 18063 +1313 
============================================
Files 6037 6189 +152 Lines 542798 556031 +13233 Branches 66457 67678 +1221 ============================================
+ Hits 98298 104247 +5949 - Misses 433453 440338 +6885 - Partials 11047 11446 +399 
FlagCoverage Δ
uitests3.51% <ø> (-0.01%)⬇️
unittests19.94% <18.45%> (+0.66%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a comprehensive Key Management Service (KMS) framework for CloudStack that provides envelope encryption for volume encryption. KEKs (Key Encryption Keys) stored in PKCS#11-compliant HSMs or the CloudStack database wrap per-volume DEKs (Data Encryption Keys), ensuring key material is never stored in plaintext.

Changes:

  • Adds KMS framework with HSM integration for envelope encryption
  • Introduces 8 new admin/user APIs for KMS key and HSM profile management
  • Creates 6 new database tables for storing KMS metadata
  • Adds UI support for KMS key selection in volume and VM deployment workflows

Reviewed changes

Copilot reviewed 123 out of 123 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
framework/kms/Core KMS framework interfaces and exceptions
plugins/kms/Database and PKCS#11 KMS provider implementations
engine/schema/Database entities and DAOs for KMS tables
api/src/main/java/org/apache/cloudstack/api/command/New API commands for KMS operations
ui/src/views/UI components for KMS key selection
server/src/main/java/KMS manager implementation and integration
Test filesUnit tests for KMS retry logic and key creation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vishesh92vishesh92 changed the title Feature kmsFeature: Key Management Service (KMS)Feb 26, 2026
@apacheapache deleted a comment from blueorangutanFeb 26, 2026
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16962

@weizhouapacheweizhouapache added this to the 4.23.0 milestone Feb 26, 2026
@vishesh92
vishesh92force-pushed the feature-kms branch 3 times, most recently from 8ea09bb to df2df4bCompareMarch 2, 2026 10:36
@vishesh92
vishesh92 requested a review from CopilotMarch 2, 2026 11:40

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 124 out of 124 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadtools/apidoc/gen_toc.py Outdated
Comment threadui/src/views/compute/DeployVM.vue
Comment threadserver/src/main/java/com/cloud/api/ApiResponseHelper.java Outdated
@vishesh92
vishesh92force-pushed the feature-kms branch 2 times, most recently from 75519c2 to 1fce0b2CompareMarch 4, 2026 06:38
@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16998

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17008

@apacheapache deleted a comment from blueorangutanMar 5, 2026
@apacheapache deleted a comment from blueorangutanMar 5, 2026
@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18184

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16259)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52077 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12711-t16259-kvm-ol8.zip
Smoke tests completed. 152 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18207

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18214

@kiranchavalakiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Tested the HSM, and kms key generation feature with Bouncy Castle, Soft HSM and the internal database HSM provider .

https://github.com/harrison314/BouncyHsm
https://github.com/softhsm/SoftHSMv2

Test Case ExecutionResult
Test the api addHSMProfilePass
Test the api listHSMProfilesPass
Test the api updateHSMProfilePass
Test the api deleteHSMProfilePass
Test the createKMSKey api callPass
Test the api call listKMSKeysPass
Test the api call updateKMSKeyPass
Test the api call rotateKMSKeyPass
Test the api call deleteKMSKeyPass
Test the api call migrateVolumesToKMSPass
Test the creation of kms key from the database providerPass
Deploy VM with encrypted root and data volume using KMS keyPass
Deploy VM with encrypted root volume using KMS key from database providerPass
Deploy VM with encrypted root volume using legacy encryptionPass
Background rewrap processes wrapped keys in batchesPass
validation of kms.dek.size.bitsPass
KMS operation retries on transient failurePass
Perform stop/start/migrate of the vm deployed with kms keyPass
Change the hsm profile of a kms keyPass
Test the kms key and hsm profile eventsPass

The kms key option is provided when deploying vm and also when creating a data volume.

ImageImageImageImageImageImage

@weizhouapache

Copy link
Copy Markdown
Member

@harikrishna-patnala
can you review ?

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@weizhouapache

Copy link
Copy Markdown
Member

this is ready for review

@blueorangutan package

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@weizhouapache

Copy link
Copy Markdown
Member

@harikrishna-patnala
could you please review ?

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18347

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16421)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53060 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12711-t16421-kvm-ol8.zip
Smoke tests completed. 152 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@harikrishna-patnalaharikrishna-patnala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@vishesh92@blueorangutan@weizhouapache@DaanHoogland@kiranchavala@harikrishna-patnala@sureshanaparti@winterhazel