Class KEM

java.lang.Object
org.bouncycastle.crypto.hpke.KEM

public abstract class KEM extends Object
Abstract base for HPKE Key Encapsulation Mechanisms per RFC 9180 §4.

Concrete subclass DHKEM implements the five DHKEM variants registered by RFC 9180 (P-256/P-384/P-521/X25519/X448); MLKEM and XWingKEM implement the post-quantum ML-KEM (draft-connolly-cfrg-hpke-mlkem) and hybrid X-Wing (draft-connolly-cfrg-xwing-kem) KEMs. Other external implementations can be plugged in by subclassing this class and passing the instance to the HPKE(mode, kemId, kdfId, aeadId, KEM, encSize) constructor; the framework only requires:

  • Encap / Decap — the basic KEM encapsulate / decapsulate pair returning [enc, sharedSecret].
  • Encap(pkR, kpE) — a sender-supplied-ephemeral variant used by the OHTTP test vectors and any deterministic KAT.
  • AuthEncap / AuthDecap — the authenticated variant used by mode_auth / mode_auth_psk.
  • GeneratePrivateKey / DeriveKeyPair(ikm) — fresh and deterministic key generation respectively.
  • SerializePublicKey / DeserializePublicKey / SerializePrivateKey / DeserializePrivateKey — the KEM-specific wire encoding.
  • getEncryptionSize — the byte-length of the enc output, used by the facade to allocate space.
  • Constructor Details

    • KEM

      public KEM()