Class KEM.Decapsulator

java.lang.Object
javax.crypto.KEM.Decapsulator
Enclosing class:
KEM

public static final class KEM.Decapsulator extends Object
A decapsulator, generated by KEM.newDecapsulator(java.security.PrivateKey) on the KEM receiver side.

This class represents the key decapsulation function of a KEM. An invocation of the decapsulate method recovers the secret key from the key encapsulation message.

Since:
21
  • Method Details

    • providerName

      public String providerName()
      Returns the name of the provider.
      Returns:
      the name of the provider
    • decapsulate

      public SecretKey decapsulate(byte[] encapsulation) throws DecapsulateException
      The key decapsulation function.

      This method is equivalent to decapsulate(encapsulation, 0, secretSize(), "Generic"). This combination of arguments must be supported by every implementation.

      The generated secret key is usually passed to a key derivation function (KDF) as the input keying material.

      Parameters:
      encapsulation - the key encapsulation message from the sender. The size must be equal to the value returned by encapsulationSize(), or a DecapsulateException will be thrown.
      Returns:
      the shared secret as a SecretKey with an algorithm name of "Generic"
      Throws:
      DecapsulateException - if an error occurs during the decapsulation process
      NullPointerException - if encapsulation is null
    • decapsulate

      public SecretKey decapsulate(byte[] encapsulation, int from, int to, String algorithm) throws DecapsulateException
      The key decapsulation function.

      An invocation of this method recovers the secret key from the key encapsulation message.

      An implementation may choose to not support arbitrary combinations of from, to, and algorithm.

      Parameters:
      encapsulation - the key encapsulation message from the sender. The size must be equal to the value returned by encapsulationSize(), or a DecapsulateException will be thrown.
      from - the initial index of the shared secret byte array to be returned, inclusive
      to - the final index of the shared secret byte array to be returned, exclusive
      algorithm - the algorithm name for the secret key that is returned
      Returns:
      a portion of the shared secret as a SecretKey containing the bytes of the secret ranging from from to to, exclusive, and an algorithm name as specified. For example, decapsulate(encapsulation, secretSize() - 16, secretSize(), "AES") uses the last 16 bytes of the shared secret as a 128-bit AES key.
      Throws:
      DecapsulateException - if an error occurs during the decapsulation process