Class KEM

java.lang.Object
javacardx.crypto.kem.KEM

public abstract class KEM extends Object
KEM is a preview API of the Java Card platform.
Programs can only use KEM when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java Card platform.
The KEM class provides methods for obtaining objects that implement Key Encapsulation Mechanism (KEM) operations, such as DHKEM (RFC 9180) and ML-KEM (FIPS 203). KEMs are used to securely transport symmetric key material (shared secrets) between a sender and a receiver using asymmetric cryptography.

In a typical usage, the sender calls the encapsulate method with the receiver’s public key to generate a key encapsulation message (ciphertext) along with a shared secret. The receiver then calls the decapsulate method with the matching private key to recover the shared secret from the key encapsulation message.

The main steps for using a KEM instance are:

  • Instance Creation
    Create an instance using the factory method getInstance(short, AlgorithmParameterSpec, short).

    • Depending on the selected mode (KEM.MODE_ENCAPSULATION or KEM.MODE_DECAPSULATION), the returned instance implements the KEM.EncapsulatorPREVIEW or KEM.DecapsulatorPREVIEW interface, respectively.
    • Additionaly, KEM.MODE_DECAPSULATION can be combined with KEM.MODE_EXPAND to return an instance supporting key expansion.
  • Key Encapsulation or Decapsulation
    Use the appropriate encapsulate or decapsulate method, providing all required keys and parameters in the method call.

Since:
preview
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Preview.
    The Decapsulator interface is implemented by KEMPREVIEW instances that support the key decapsulation operation of Key Encapsulation Mechanism (KEM) algorithms.
    static interface 
    Preview.
    The Encapsulator interface is implemented by KEMPREVIEW instances that support the key encapsulation operation of Key Encapsulation Mechanism (KEM) algorithms.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
    DH Key Encapsulation Mechanism (DHKEM), as defined in RFC 9180 chapters 4.1 and 7.1.
    static final short
    Module-Lattice-Based Key Encapsulation Mechanism (ML-KEM) as defined in FIPS 203.
    static final short
    Specifies decapsulation mode for use as the mode parameter in the getInstance(short, AlgorithmParameterSpec, short) factory method.
    static final short
    Specifies encapsulation mode for use as the mode parameter in the getInstance(short, AlgorithmParameterSpec, short) factory method.
    static final short
    Specifies that the KEM instance supports key expansion.
  • Method Summary

    Modifier and Type
    Method
    Description
    static KEMPREVIEW
    getInstance(short algorithm, AlgorithmParameterSpec params, short mode)
    Obtains a KEM object instance for the selected algorithm, algorithm parameters, and mode.

    Methods inherited from class Object

    equals
    Modifier and Type
    Method
    Description
    boolean
    Compares two Objects for equality.