Azure HSM Key Rotation Process - 2.40.02 onwards
📌 Overview
The Azure HSM re-encryption flow ensures that secrets stored in Azure Key Vault are securely migrated and updated using Hardware Security Module (HSM)-backed keys.
This mechanism enforces compliance, strengthens security, and simplifies key lifecycle management.
Re-encryption guarantees that:
- ✅ Sensitive data is always protected by HSM keys
- ✅ Key rotation and migrations are handled in a controlled, auditable process
- ✅ Organizations remain compliant with security & regulatory mandates
📆 When to Re-encrypt
Re-encryption can be triggered under several scenarios:
- 🔄 Scheduled Key Rotation → Routine maintenance (quarterly/annually)
- 📜 Compliance Requirements → Regulatory or audit-driven demands
- 🛡 Security Incidents → Suspected/confirmed key compromise
- ⚙️ Policy Updates → Adopting stronger encryption algorithms/standards
📋 Prerequisites
- Azure HSM Key Vault instance
- Azure Standard Key Vault for secret storage
- Service principal with key management permissions
- Secure network connectivity to Azure services
🌐 API Endpoint
URL:
POST https://<KeyManagementService>/api/vault/migration/re-encrypt
Purpose:
Triggers re-encryption of all secrets using new HSM-backed keys.
📤 Request Configuration
{
"connectionType": "azurehsm",
"azureHsmKeyVaultUrl": "https://your-hsm.vault.azure.net/",
"azureHsmKeyVaultClientId": "hsm-client-id",
"azureHsmKeyVaultClientSecret": "hsm-secret",
"azureHsmKeyVaultClientTenantId": "tenant-id",
"azureKeyVaultUrl": "https://your-vault.vault.azure.net/",
"azureKeyVaultClientId": "vault-client-id",
"azureKeyVaultClientSecret": "vault-secret",
"azureKeyVaultClientTenantId": "tenant-id",
"masterKeyName": "master-keys",
"masterKeyVersion": "88ec4ffe54054e38bf2bec749664d63d",
}
Note:
masterKeyName is required for custom master key
masterKeyVersion is Optional
⚙️ Configuration Notes
- 🔐 HSM Vault → manages encryption keys in hardware
- 📦 Standard Vault → stores encrypted secrets with HSM-backed keys
- 🔑 Dual Authentication → both vaults require separate credentials
🔄 Process Flow
1. Connection Setup
- Connect to Azure HSM Key Vault (for keys)
- Connect to Azure Standard Key Vault (for secrets)
2. Key Generation
- Create a new HSM master key (
RSA_HSM)
3. Secret Retrieval
- Read existing secrets from the standard vault
4. Re-encryption
- Decrypt with old key(s)
- Encrypt using new HSM-backed key
5. Secret Storage
- Save updated, re-encrypted secrets back into the vault
6. Verification
- Confirm that all secrets were successfully migrated
🔑 Key Components & Naming Conventions
-
HSM Transit Keys
-
Prefix:
master-keys - Type:
RSA_HSM(hardware-backed) - Pattern:
master-keys-{version} -
Example:
master-keys-1,master-keys-2 -
Software Transit Keys
-
Prefix:
transit-keys - Type:
RSA(software-backed) - Pattern:
transit-keys-{version} -
Example:
transit-keys-1,transit-keys-2 -
Other Prefixes
-
Execution Area:
ex-* - Data Subject:
ds-* - Format Preserving Encryption:
fpe-* - Metadata:
mdt-* - Nonces:
nonce-* - Salts:
salt-*
🛠️ Re-encryption Flow Sequence
-
Pre-Encryption Phase
-
Validate environment configuration
- Initialize connections to both vaults
-
Prepare transit key service with HSM enabled
-
Key Creation
-
Generate new RSA_HSM key in HSM vault
- Apply naming pattern →
master-keys-{next_version} -
Increment version sequentially
-
Data Migration
-
Identify current key version in use
- Decrypt with old key (software or HSM)
- Re-encrypt with new HSM-backed key
-
Maintain mapping between old & new key versions
-
Key Lifecycle
-
Optionally disable old keys
- Track active key versions
- Archive deprecated key versions
- Validate all re-encrypted data
✅ Success Response
{
"message": "Vault re-encryption process completed successfully. All secrets have been securely migrated and re-encrypted using the new encryption key."
}
🔐 Security Notes
- 🔑 Use service principals with minimal required permissions
- 📊 Monitor re-encryption activities through Azure logs
- 🗝 Follow organizational key retention policies
- 🌐 Implement network restrictions where applicable
- 📝 Maintain an audit trail of all key operations