KeySpec

data class KeySpec(val id: KeyId, val algorithm: Algorithm)

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
}
}

Constructors

Link copied to clipboard
constructor(id: KeyId, algorithm: Algorithm)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The cryptographic algorithm this key supports.

Link copied to clipboard
val id: KeyId

The key identifier.

Functions

Link copied to clipboard
fun requireSupports(required: Algorithm)

Validates that this key spec supports the given algorithm.

Link copied to clipboard
fun supports(required: Algorithm): Boolean

Checks if this key spec supports the given algorithm.