Interface KeyManager

  • All Implemented Interfaces:

    
    public interface KeyManager
    
                        

    A 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      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.
      abstract Jwk getPublicKey(String keyAlias) Retrieves the public key associated with a previously stored private key, identified by the provided alias.
      abstract ByteArray sign(String keyAlias, ByteArray signingInput) Signs the provided payload using the private key identified by the provided alias.
      abstract String getDeterministicAlias(Jwk publicKey) Return the alias of publicKey, as was originally returned by generatePrivateKey.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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.