KMS Providers
The IDK supports multiple key management system (KMS) providers, allowing you to store cryptographic keys in the most appropriate backend for your use case. Multiple providers can be active simultaneously.
Available Providers
| Provider Type | Platforms | Use Case |
|---|---|---|
SOFTWARE | All | In-memory or file-based keys for development and testing |
MOBILE | iOS, Android | Hardware-backed keys using Secure Enclave or Android Keystore |
AWS_KMS | JVM | Cloud-hosted HSM keys with AWS Key Management Service |
AZURE_KEYVAULT | JVM, JS | Cloud-hosted HSM keys with Azure Key Vault |
REST | All | Remote KMS accessed via REST API |
Provider Capabilities Comparison
Platform Availability
| Provider | Android | iOS | JVM/Server | Web/JS |
|---|---|---|---|---|
| Software | ✓ | ✓ (Keychain) | ✓ | ✓ (WebCrypto) |
| Mobile | ✓ (Keystore) | ✓ (Secure Enclave) | ✗ | ✗ |
| AWS KMS | ✗ | ✗ | ✓ | ✗ |
| Azure Key Vault | ✗ | ✗ | ✓ | ✓ |
| REST Client | ✓ | ✓ | ✓ | ✓ |
Key Operations
| Operation | Software | Mobile | AWS KMS | Azure | REST |
|---|---|---|---|---|---|
| Generate Key | ✓ | ✓ | ✓ | ✓ | ✓ |
| Import Key | ✓ | ✗ | ✓ | ✓ | ✓ |
| Export Key | ✓ | ✗ | ✗ | ✗ | ✓ |
| Delete Key | ✓ | ✓ | ✓ | ✓ | ✓ |
| List Keys | ✓ | ✓ | ✓ | ✓ | ✓ |
Cryptographic Operations
| Operation | Software | Mobile | AWS KMS | Azure | REST |
|---|---|---|---|---|---|
| Sign | ✓ | ✓ | ✓ | ✓ | ✓ |
| Verify | ✓ | ✓ | ✓ | ✓ | ✓ |
| Encrypt | ✓ (GCM) | ✗ | ✓ | ✓ | ✗ |
| Decrypt | ✓ (GCM) | ✗ | ✓ | ✓ | ✗ |
| Key Wrap | ✓ (RSA-OAEP, AES-KW) | ✗ | ✓ | ✓ | ✗ |
| Key Unwrap | ✓ (RSA-OAEP, AES-KW) | ✗ | ✓ | ✓ | ✗ |
| Key Agreement (ECDH) | ✓ | ✗ | ✓ | ✗ | ✗ |
Supported Key Types and Curves
| Provider | EC Curves | RSA Key Sizes |
|---|---|---|
| Software | P-256, P-384, P-521 | 2048, 3072, 4096 |
| Mobile | P-256, P-384, P-521 | 2048, 3072, 4096 |
| AWS KMS | P-256, P-384, P-521 | 2048, 3072, 4096 |
| Azure Key Vault | P-256, P-384, P-521, secp256k1 | 2048 |
| REST Client | P-256, P-384, P-521 | 2048, 3072, 4096 |
Signature Algorithms
| Algorithm | Software | Mobile | AWS KMS | Azure | REST |
|---|---|---|---|---|---|
| ECDSA + SHA-256 | ✓ | ✓ | ✓ | ✓ | ✓ |
| ECDSA + SHA-384 | ✓ | ✓ | ✓ | ✓ | ✓ |
| ECDSA + SHA-512 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA PKCS#1 + SHA-256 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA PKCS#1 + SHA-384 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA PKCS#1 + SHA-512 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA-PSS + SHA-256 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA-PSS + SHA-384 | ✓ | ✓ | ✓ | ✓ | ✓ |
| RSA-PSS + SHA-512 | ✓ | ✓ | ✓ | ✓ | ✓ |
Content Encryption Algorithms
| Algorithm | Software | Mobile | AWS KMS | Azure |
|---|---|---|---|---|
| A128GCM | ✓ | ✗ | ✓ | ✓ |
| A192GCM | ✓ | ✗ | ✓ | ✓ |
| A256GCM | ✓ | ✗ | ✓ | ✓ |
| A128CBC-HS256 | ✗ | ✗ | ✓ | ✓ |
| A192CBC-HS384 | ✗ | ✗ | ✓ | ✓ |
| A256CBC-HS512 | ✗ | ✗ | ✓ | ✓ |
Key Wrapping Algorithms
| Algorithm | Software | Mobile | AWS KMS | Azure |
|---|---|---|---|---|
| RSA-OAEP | ✓ | ✗ | ✓ | ✓ |
| RSA-OAEP-256 | ✓ | ✗ | ✓ | ✓ |
| RSA-OAEP-512 | ✓ | ✗ | ✗ | ✗ |
| RSA1_5 | ✗ | ✗ | ✗ | ✓ |
| A128KW | ✓ | ✗ | ✓ | ✓ |
| A192KW | ✓ | ✗ | ✓ | ✓ |
| A256KW | ✓ | ✗ | ✓ | ✓ |
Key Agreement Algorithms
| Algorithm | Software | Mobile | AWS KMS | Azure |
|---|---|---|---|---|
| ECDH-ES | ✓ | ✗ | ✓ | ✗ |
| ECDH-ES+A128KW | ✓ | ✗ | ✗ | ✗ |
| ECDH-ES+A192KW | ✓ | ✗ | ✗ | ✗ |
| ECDH-ES+A256KW | ✓ | ✗ | ✗ | ✗ |
Storage and Security
| Feature | Software | Mobile | AWS KMS | Azure | REST |
|---|---|---|---|---|---|
| Hardware Backing | Optional | ✓ | ✓ (HSM) | ✓ (HSM) | Depends on backend |
| Private Key Export | ✓ | ✗ | ✗ | ✗ | Depends on backend |
| Persistent Storage | ✓ | ✓ | ✓ | ✓ | ✓ |
| Ephemeral Storage | ✓ | ✓ | ✗ | ✗ | ✓ |
| Certificate Generation | ✓ | ✗ | ✗ | ✗ | ✗ |
| Certificate Import | ✓ | ✗ | ✗ | ✗ | ✗ |
Provider Selection Quick Reference
| Use Case | Recommended Provider |
|---|---|
| Production mobile wallet | Mobile |
| Development and testing | Software |
| Server-side with AWS infrastructure | AWS KMS |
| Server-side with Azure infrastructure | Azure Key Vault |
| Delegated signing to remote service | REST Client |
| Cross-platform with hardware preference | Software (uses native APIs when available) |
Provider Capabilities
Each provider declares its capabilities. Query them to understand what operations are available:
- Android/Kotlin
- iOS/Swift
val provider = keyManager.getProviderById("software")
val capabilities = provider.getCapabilities()
// Storage capabilities
println("Storage types: ${capabilities.storageTypes.joinToString()}") // PERSISTENT, EPHEMERAL
println("Supports import: ${capabilities.supportsKeyImport}")
println("Supports export: ${capabilities.supportsKeyExport}")
println("Exposes private keys: ${capabilities.exposePrivateKeys}")
// Cryptographic capabilities
println("Key types: ${capabilities.supportedKeyTypes.joinToString()}") // EC, RSA
println("Curves: ${capabilities.supportedCurves.joinToString()}") // P_256, P_384, P_521
println("Digests: ${capabilities.supportedDigestAlgorithms.joinToString()}")
// Operations
println("Supports signing: ${capabilities.supportsSigning()}")
println("Supports encryption: ${capabilities.supportsEncryption()}")
println("Supports key agreement: ${capabilities.supportsKeyAgreement()}")
println("Hardware backing: ${capabilities.supportsHardwareBacking}")
println("X.509 support: ${capabilities.supportsX509}")
let provider = keyManager.getProviderById(id: "software")
let capabilities = provider.getCapabilities()
// Storage capabilities
print("Storage types: \(capabilities.storageTypes)") // PERSISTENT, EPHEMERAL
print("Supports import: \(capabilities.supportsKeyImport)")
print("Supports export: \(capabilities.supportsKeyExport)")
print("Exposes private keys: \(capabilities.exposePrivateKeys)")
// Cryptographic capabilities
print("Key types: \(capabilities.supportedKeyTypes)") // EC, RSA
print("Curves: \(capabilities.supportedCurves)") // P_256, P_384, P_521
print("Digests: \(capabilities.supportedDigestAlgorithms)")
// Operations
print("Supports signing: \(capabilities.supportsSigning())")
print("Supports encryption: \(capabilities.supportsEncryption())")
print("Supports key agreement: \(capabilities.supportsKeyAgreement())")
print("Hardware backing: \(capabilities.supportsHardwareBacking)")
print("X.509 support: \(capabilities.supportsX509)")
Software Provider
The software provider stores keys in memory or on the filesystem. It's suitable for development, testing, and scenarios where hardware-backed storage isn't required.
Capabilities
- Storage: Persistent and ephemeral
- Key Types: EC, RSA, Symmetric (oct)
- Curves: P-256, P-384, P-521
- Operations: Generate, import, export, delete, sign, verify, encrypt, decrypt, wrap, unwrap, key agreement
- Signature Algorithms: ECDSA (SHA-256/384/512), RSA (SHA-256/384/512), RSA-PSS
- Encryption Algorithms: A128GCM, A192GCM, A256GCM
- Key Wrap Algorithms: RSA-OAEP, RSA-OAEP-256, RSA-OAEP-512, A128KW, A192KW, A256KW
- Key Agreement: ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW
Configuration
- Android/Kotlin
- iOS/Swift
import com.sphereon.crypto.kms.provider.software.SoftwareKmsProviderConfig
import com.sphereon.crypto.kms.provider.software.SoftwareKmsProviderFactory
// Create software provider configuration
val softwareConfig = SoftwareKmsProviderConfig(
id = "software",
exposePrivateKeysDuringGeneration = true,
keyStore = KeyStoreConfig(
path = "/data/app/keys",
overwriteAlias = true
)
)
// Factory creates the provider instance
val factory: SoftwareKmsProviderFactory = ...
val softwareProvider = factory.create(softwareConfig, session.execution)
// Register with key manager
keyManager.registerProvider(softwareProvider, makeDefaultKms = true)
import SphereonCrypto
// Create software provider configuration
let softwareConfig = SoftwareKmsProviderConfig(
id: "software",
exposePrivateKeysDuringGeneration: true,
keyStore: KeyStoreConfig(
path: "/data/app/keys",
overwriteAlias: true
)
)
// Factory creates the provider instance
let factory: SoftwareKmsProviderFactory = ...
let softwareProvider = factory.create(config: softwareConfig, execution: session.execution)
// Register with key manager
keyManager.registerProvider(provider: softwareProvider, makeDefaultKms: true)
Mobile Provider
The mobile provider uses platform-specific secure storage:
- iOS: Secure Enclave for private key operations
- Android: Android Keystore with hardware backing when available
This is the recommended provider for production mobile applications.
Capabilities
- Storage: Hardware-backed persistent
- Key Types: EC (platform-dependent)
- Curves: P-256 (most common)
- Operations: Generate, sign, verify (no export of private keys)
- Hardware Backing: Yes
- Attestation: Platform-dependent
Key Characteristics
- Private keys never leave the secure hardware
- Keys are bound to the device and cannot be exported
- Biometric authentication can be required for key use
- Keys persist across app restarts but may be deleted with app uninstall
AWS KMS Provider
The AWS KMS provider integrates with Amazon Web Services Key Management Service.
Configuration
- Android/Kotlin
- iOS/Swift
import com.sphereon.crypto.kms.provider.aws.AwsKmsProviderConfig
val awsConfig = AwsKmsProviderConfig(
id = "aws",
region = "us-east-1",
accessKeyId = System.getenv("AWS_ACCESS_KEY_ID"),
secretAccessKey = System.getenv("AWS_SECRET_ACCESS_KEY"),
endpointOverride = null // Optional: for LocalStack testing
)
import SphereonCrypto
let awsConfig = AwsKmsProviderConfig(
id: "aws",
region: "us-east-1",
accessKeyId: ProcessInfo.processInfo.environment["AWS_ACCESS_KEY_ID"] ?? "",
secretAccessKey: ProcessInfo.processInfo.environment["AWS_SECRET_ACCESS_KEY"] ?? "",
endpointOverride: nil // Optional: for LocalStack testing
)
IAM Permissions
The AWS credentials must have permissions for the following KMS actions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:CreateKey",
"kms:Sign",
"kms:Verify",
"kms:GetPublicKey",
"kms:DescribeKey",
"kms:ScheduleKeyDeletion"
],
"Resource": "*"
}
]
}
Azure Key Vault Provider
The Azure provider integrates with Azure Key Vault.
Configuration
- Android/Kotlin
- iOS/Swift
import com.sphereon.crypto.kms.provider.azure.AzureKmsProviderConfig
val azureConfig = AzureKmsProviderConfig(
id = "azure",
vaultUrl = "https://my-vault.vault.azure.net",
tenantId = "12345678-1234-1234-1234-123456789012",
clientId = "87654321-4321-4321-4321-210987654321",
clientSecret = System.getenv("AZURE_CLIENT_SECRET")
)
import SphereonCrypto
let azureConfig = AzureKmsProviderConfig(
id: "azure",
vaultUrl: "https://my-vault.vault.azure.net",
tenantId: "12345678-1234-1234-1234-123456789012",
clientId: "87654321-4321-4321-4321-210987654321",
clientSecret: ProcessInfo.processInfo.environment["AZURE_CLIENT_SECRET"] ?? ""
)
Using Multiple Providers
The KeyManagerService can work with multiple providers simultaneously. Specify the provider when generating keys:
- Android/Kotlin
- iOS/Swift
// Generate a key using the default provider
val defaultKey = keyManager.generateKeyAsync(
providerId = null, // Uses default
alias = "default-key",
alg = SignatureAlgorithm.ECDSA_SHA256
)
// Generate a key in AWS KMS
val awsKey = keyManager.generateKeyAsync(
providerId = "aws",
alias = "aws-key",
alg = SignatureAlgorithm.ECDSA_SHA256
)
// Generate a key in Azure Key Vault
val azureKey = keyManager.generateKeyAsync(
providerId = "azure",
alias = "azure-key",
alg = SignatureAlgorithm.ECDSA_SHA256
)
// Generate a key in software provider
val softwareKey = keyManager.generateKeyAsync(
providerId = "software",
alias = "software-key",
alg = SignatureAlgorithm.ECDSA_SHA256
)
// Generate a key using the default provider
let defaultKey = try await keyManager.generateKeyAsync(
providerId: nil, // Uses default
alias: "default-key",
alg: .ecdsaSha256
)
// Generate a key in AWS KMS
let awsKey = try await keyManager.generateKeyAsync(
providerId: "aws",
alias: "aws-key",
alg: .ecdsaSha256
)
// Generate a key in Azure Key Vault
let azureKey = try await keyManager.generateKeyAsync(
providerId: "azure",
alias: "azure-key",
alg: .ecdsaSha256
)
// Generate a key in software provider
let softwareKey = try await keyManager.generateKeyAsync(
providerId: "software",
alias: "software-key",
alg: .ecdsaSha256
)
Registering Providers
Register custom or additional providers with the key manager:
- Android/Kotlin
- iOS/Swift
// Register a provider
keyManager.registerProvider(
provider = myCustomProvider,
makeDefaultKms = false
)
// Register and make it the default
keyManager.registerProvider(
provider = softwareProvider,
makeDefaultKms = true
)
// Check the default provider
val defaultId = keyManager.defaultProviderId()
println("Default provider: $defaultId")
// Register a provider
keyManager.registerProvider(
provider: myCustomProvider,
makeDefaultKms: false
)
// Register and make it the default
keyManager.registerProvider(
provider: softwareProvider,
makeDefaultKms: true
)
// Check the default provider
let defaultId = keyManager.defaultProviderId()
print("Default provider: \(defaultId)")
Provider Selection Guidelines
When choosing a KMS provider:
Mobile Provider: Use for production mobile apps. Keys are hardware-backed and cannot be extracted, providing strong security guarantees.
Software Provider: Use for development, testing, or when you need to export keys. Not recommended for production mobile apps holding sensitive keys.
AWS KMS: Use when you need centralized key management, audit logging, or when keys must be accessible from multiple services.
Azure Key Vault: Similar to AWS KMS, use for Azure-centric architectures or when Azure compliance certifications are required.
Storage Types
Providers support different storage types:
| Type | Description |
|---|---|
NONE | No storage, ephemeral keys only |
EPHEMERAL | Session-scoped, keys lost on restart |
PERSISTENT | Disk or database storage, keys survive restart |
HARDWARE | HSM, Secure Enclave, or TPM backed |
Supported Operations
Providers may support different operations:
| Operation | Description |
|---|---|
GENERATE_KEY | Create new key pairs |
IMPORT_KEY | Import existing keys |
EXPORT_KEY | Export keys (if allowed) |
DELETE_KEY | Remove keys from storage |
SIGN | Create signatures |
VERIFY | Verify signatures |
ENCRYPT | Content encryption |
DECRYPT | Content decryption |
WRAP_KEY | Key wrapping |
UNWRAP_KEY | Key unwrapping |
KEY_AGREEMENT | ECDH key agreement |