KeySpec
Represents key specifications with algorithm validation support.
This class provides type-safe validation that a requested algorithm is compatible with a key's actual algorithm. It prevents accidental use of incompatible algorithms during signing operations.
Example Usage:
when (val result = kms.getPublicKey(keyId)) {
is GetPublicKeyResult.Success -> {
val keySpec = KeySpec.fromKeyHandle(result.keyHandle)
// Validate algorithm before signing
val algorithm = Algorithm.Ed25519
if (keySpec.supports(algorithm)) {
// Proceed with signing
} else {
// Handle unsupported algorithm
}
}
is GetPublicKeyResult.Failure.KeyNotFound -> {
// Handle key not found
}
}Content copied to clipboard