Monday, June 16, 2025
HomeJavaIntroduction of Key Encapsulation Mechanisms API

Introduction of Key Encapsulation Mechanisms API


JEP 452, Key Encapsulation Mechanism API, has been promoted from Focused to Accomplished for JDK 21. This JEP introduces an API for Key Encapsulation Mechanisms (KEMs), a contemporary encryption method for securing symmetric keys utilizing public key cryptography. The brand new API goals to allow functions to make use of KEM algorithms reminiscent of RSA Key Encapsulation Mechanism (RSA-KEM), Elliptic Curve Built-in Encryption Scheme (ECIES), and candidate KEM algorithms for the Nationwide Institute of Requirements and Expertise (NIST) Publish-Quantum Cryptography standardization course of.

KEMs are an important software for defending in opposition to quantum assaults. The standard strategy of securing symmetric keys includes encrypting a randomly generated symmetric key with a public key. Nevertheless, this requires padding and may be difficult to show safe. KEMs, then again, use properties of the general public key to derive a associated symmetric key, eliminating the necessity for padding.

The brand new API will even allow using KEMs in higher-level protocols reminiscent of Transport Stage Safety (TLS) and in cryptographic schemes reminiscent of Hybrid Public Key Encryption (HPKE, RFC 9180). It should enable safety suppliers to implement KEM algorithms in both Java code or native code. Nevertheless, it isn’t a objective to incorporate key pair technology within the KEM API, as the prevailing KeyPairGenerator API is adequate.

The KEM API consists of three capabilities: a key pair technology operate, a key encapsulation operate, and a key decapsulation operate. The important thing pair technology operate is roofed by the prevailing KeyPairGenerator API, whereas the encapsulation and decapsulation capabilities are outlined in a brand new class, KEM. Take into account the next code snippets:


bundle javax.crypto;

public class DecapsulateException extends GeneralSecurityException;

public last class KEM {

    public static KEM getInstance(String alg)
        throws NoSuchAlgorithmException;
    public static KEM getInstance(String alg, Supplier p)
        throws NoSuchAlgorithmException;
    public static KEM getInstance(String alg, String p)
        throws NoSuchAlgorithmException, NoSuchProviderException;

    public static last class Encapsulated {
        public Encapsulated(SecretKey key, byte[] encapsulation, byte[] params);
        public SecretKey key();
        public byte[] encapsulation();
        public byte[] params();
    }

    public static last class Encapsulator {
        String providerName();
        int secretSize();           // Dimension of the shared secret
        int encapsulationSize();    // Dimension of the important thing encapsulation message
        Encapsulated encapsulate();
        Encapsulated encapsulate(int from, int to, String algorithm);
    }

    public Encapsulator newEncapsulator(PublicKey pk)
            throws InvalidKeyException;
    public Encapsulator newEncapsulator(PublicKey pk, SecureRandom sr)
            throws InvalidKeyException;
    public Encapsulator newEncapsulator(PublicKey pk, AlgorithmParameterSpec spec,
                                        SecureRandom sr)
            throws InvalidAlgorithmParameterException, InvalidKeyException;

    public static last class Decapsulator {
        String providerName();
        int secretSize();           // Dimension of the shared secret
        int encapsulationSize();    // Dimension of the important thing encapsulation message
        SecretKey decapsulate(byte[] encapsulation) throws DecapsulateException;
        SecretKey decapsulate(byte[] encapsulation, int from, int to,
                              String algorithm)
                throws DecapsulateException;
    }

    public Decapsulator newDecapsulator(PrivateKey sk)
            throws InvalidKeyException;
    public Decapsulator newDecapsulator(PrivateKey sk, AlgorithmParameterSpec spec)
            throws InvalidAlgorithmParameterException, InvalidKeyException;

}

The getInstance strategies create a brand new KEM object that implements the desired algorithm. The sender calls one of many newEncapsulator strategies, which takes the receiver’s public key and returns an Encapsulator object. The sender can then name one among that object’s encapsulate strategies to get an Encapsulated object, which incorporates a SecretKey and a key encapsulation message.

The receiver calls one of many newDecapsulator strategies, which takes the receiver’s non-public key and returns a Decapsulator object. The receiver can then name one among that object’s decapsulate strategies, which takes the acquired key encapsulation message and returns the shared secret.


The introduction of the KEM API in OpenJDK is a major step ahead in trendy cryptography, offering a safer and environment friendly approach to safe symmetric keys utilizing public key cryptography. It’s anticipated to play an important position in defending in opposition to quantum assaults and enhancing the safety of higher-level protocols and cryptographic schemes.

 



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments