RSAKeyEncapsulation (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.kems

## Class RSAKeyEncapsulation

- java.lang.Object
- - org.bouncycastle.crypto.kems.RSAKeyEncapsulation

- All Implemented Interfaces:
    KeyEncapsulation

  Deprecated.
  use RSAKEMGenerator, RSAKEMExtractor

      public class RSAKeyEncapsulation
      extends java.lang.Object
      implements KeyEncapsulation

  The RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RSAKeyEncapsulation(DerivationFunction kdf, java.security.SecureRandom rnd)` Deprecated. Set up the RSA-KEM.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `CipherParameters` | `decrypt(byte[] in, int keyLen)` Deprecated. Decrypt an encapsulated session key.
    `CipherParameters` | `decrypt(byte[] in, int inOff, int inLen, int keyLen)` Deprecated. Decrypt an encapsulated session key.
    `CipherParameters` | `encrypt(byte[] out, int keyLen)` Deprecated. Generate and encapsulate a random session key.
    `CipherParameters` | `encrypt(byte[] out, int outOff, int keyLen)` Deprecated. Generate and encapsulate a random session key.
    `void` | `init(CipherParameters key)` Deprecated. Initialise the RSA-KEM.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RSAKeyEncapsulation

          public RSAKeyEncapsulation(DerivationFunction kdf,
                                     java.security.SecureRandom rnd)

      Deprecated.
      Set up the RSA-KEM.
      Parameters:
        `kdf` - the key derivation function to be used.
        `rnd` - the random source for the session key.

  - ### Method Detail

    - #### init

          public void init(CipherParameters key)
                    throws java.lang.IllegalArgumentException

      Deprecated.
      Initialise the RSA-KEM.
      Specified by:
        `init` in interface `KeyEncapsulation`
      Parameters:
        `key` - the recipient's public (for encryption) or private (for decryption) key.
      Throws:
        `java.lang.IllegalArgumentException`

    - #### encrypt

          public CipherParameters encrypt(byte[] out,
                                          int outOff,
                                          int keyLen)
                                   throws java.lang.IllegalArgumentException

      Deprecated.
      Generate and encapsulate a random session key.
      Specified by:
        `encrypt` in interface `KeyEncapsulation`
      Parameters:
        `out` - the output buffer for the encapsulated key.
        `outOff` - the offset for the output buffer.
        `keyLen` - the length of the random session key.
      Returns:
        the random session key.
      Throws:
        `java.lang.IllegalArgumentException`

    - #### encrypt

          public CipherParameters encrypt(byte[] out,
                                          int keyLen)

      Deprecated.
      Generate and encapsulate a random session key.
      Parameters:
        `out` - the output buffer for the encapsulated key.
        `keyLen` - the length of the random session key.
      Returns:
        the random session key.

    - #### decrypt

          public CipherParameters decrypt(byte[] in,
                                          int inOff,
                                          int inLen,
                                          int keyLen)
                                   throws java.lang.IllegalArgumentException

      Deprecated.
      Decrypt an encapsulated session key.
      Specified by:
        `decrypt` in interface `KeyEncapsulation`
      Parameters:
        `in` - the input buffer for the encapsulated key.
        `inOff` - the offset for the input buffer.
        `inLen` - the length of the encapsulated key.
        `keyLen` - the length of the session key.
      Returns:
        the session key.
      Throws:
        `java.lang.IllegalArgumentException`

    - #### decrypt

          public CipherParameters decrypt(byte[] in,
                                          int keyLen)

      Deprecated.
      Decrypt an encapsulated session key.
      Parameters:
        `in` - the input buffer for the encapsulated key.
        `keyLen` - the length of the session key.
      Returns:
        the session key.