Class KeyDecryptionKey

All Implemented Interfaces:
AutoCloseable, DecryptionKey<KeyDecryptionKey>

public class KeyDecryptionKey extends CryptoKey implements DecryptionKey<KeyDecryptionKey>
A key that is used to decrypt (or "unwrap") other keys that have been encrypted with a KeyEncryptionKey.
  • Constructor Details

    • KeyDecryptionKey

      public KeyDecryptionKey(SecretBuilder builder) throws NoSuchSecretException
      Initialises the key with the given secret data.
      Parameters:
      builder - the builder object.
      Throws:
      NoSuchSecretException - if the secret could not be constructed from the builder.
  • Method Details

    • getCipher

      public Cipher getCipher()
      Returns an initialized cipher object for an appropriate default algorithm and parameters. A best-effort attempt will be made to pick a strong cipher algorithm based on the type of key.
      Returns:
      the initialized cipher object.
    • asCryptoKey

      public KeyDecryptionKey asCryptoKey()
      Description copied from interface: DecryptionKey
      Returns the same object as a specific CryptoKey subclass.
      Specified by:
      asCryptoKey in interface DecryptionKey<KeyDecryptionKey>
      Returns:
      the same key as a CryptoKey.
    • getCipher

      public Cipher getCipher(String algorithm, AlgorithmParameterSpec parameterSpec)
      Returns an initialized cipher object for the given algorithm and parameters.
      Parameters:
      algorithm - the cipher algorithm.
      parameterSpec - the parameters to initialise the cipher with.
      Returns:
      the initialized cipher object.
    • getCipher

      public Cipher getCipher(String algorithm, AlgorithmParameters parameters)
      Returns an initialized cipher object for the given algorithm and parameters.
      Parameters:
      algorithm - the cipher algorithm.
      parameters - the parameters to initialise the cipher with.
      Returns:
      the initialized cipher object.
    • getCipher

      public Cipher getCipher(String algorithm)
      Returns an initialized cipher object with default parameters.
      Parameters:
      algorithm - the cipher algorithm.
      Returns:
      the initialized cipher object.