Interface KeyManager
-
- All Implemented Interfaces:
public interface KeyManagerA key management interface that provides functionality for generating, storing, and utilizing private keys and their associated public keys. Implementations of this interface should handle the secure generation and storage of keys, providing mechanisms for utilizing them in cryptographic operations like signing.
Example implementations might provide key management through various Key Management Systems (KMS), such as AWS KMS, Google Cloud KMS, Hardware Security Modules (HSM), or simple in-memory storage, each adhering to the same consistent API for usage within applications.
-
-
Method Summary
Modifier and Type Method Description abstract StringgeneratePrivateKey(AlgorithmId algorithmId, KeyGenOptions options)Generates and securely stores a private key based on the provided algorithm and options, returning a unique alias that can be utilized to reference the generated key for future operations. abstract JwkgetPublicKey(String keyAlias)Retrieves the public key associated with a previously stored private key, identified by the provided alias. abstract ByteArraysign(String keyAlias, ByteArray signingInput)Signs the provided payload using the private key identified by the provided alias. abstract StringgetDeterministicAlias(Jwk publicKey)Return the alias of publicKey, as was originally returned by generatePrivateKey. -
-
Method Detail
-
generatePrivateKey
abstract String generatePrivateKey(AlgorithmId algorithmId, KeyGenOptions options)
Generates and securely stores a private key based on the provided algorithm and options, returning a unique alias that can be utilized to reference the generated key for future operations.
- Parameters:
algorithmId- The algorithmId to use for key generation.options- (Optional) Additional options to control key generation behavior.- Returns:
A unique alias (String) that can be used to reference the stored key.
Implementations should ensure secure storage of the generated keys, protecting against unauthorized access and ensuring cryptographic strength according to the provided parameters.
-
getPublicKey
abstract Jwk getPublicKey(String keyAlias)
Retrieves the public key associated with a previously stored private key, identified by the provided alias.
- Parameters:
keyAlias- The alias referencing the stored private key.- Returns:
The associated public key in Jwk (JSON Web Key) format.
The function should provide the public key in a format suitable for external sharing and usage, enabling others to perform operations like verifying signatures or encrypting data for the private key holder.
-
sign
abstract ByteArray sign(String keyAlias, ByteArray signingInput)
Signs the provided payload using the private key identified by the provided alias.
- Parameters:
keyAlias- The alias referencing the stored private key.signingInput- The data to be signed.- Returns:
The signature in JWS R+S format
Implementations should ensure that the signing process is secured, utilizing secure cryptographic practices and safeguarding the private key during the operation. The specific signing algorithm used may depend on the type and parameters of the stored key.
-
getDeterministicAlias
abstract String getDeterministicAlias(Jwk publicKey)
Return the alias of publicKey, as was originally returned by generatePrivateKey.
- Parameters:
publicKey- A public key in Jwk (JSON Web Key) format- Returns:
The alias belonging to publicKey
-
-
-
-