Class BcPublicKeyCryptoCallback

java.lang.Object
org.bouncycastle.openpgp.operator.bc.BcPublicKeyCryptoCallback

public abstract class BcPublicKeyCryptoCallback extends Object
Callback isolating the raw public-key operations performed while recovering an OpenPGP session key.

BcPublicKeyDataDecryptorFactory performs all packet parsing, length checking and KDF/key-unwrap work itself and delegates only the private-key operation - an RSA or ElGamal decryption, an ECDH / X25519 / X448 agreement, or an ML-KEM decapsulation - to an instance of this class. A subclass may therefore route that one operation to a hardware device (a smart card or HSM) without reimplementing any of the session-key recovery logic.

For the RFC 9980 ML-KEM + ECDH composites the factory makes two calls: decrypt(int, AsymmetricKeyParameter) with PublicKeyAlgorithmTags.X25519 or PublicKeyAlgorithmTags.X448 and the sender's ephemeral public key, returning the ECDH key share, and decrypt(int, byte[][]) with the composite algorithm ID and the ML-KEM ciphertext as the single element of the array, returning the ML-KEM key share. See org.bouncycastle.openpgp.api.operator.bc.BcExternalPublicKeyDataDecryptorFactory for the externally-backed-key base class built on this seam.

This is the lightweight (.bc) binding: keys are passed as AsymmetricKeyParameter. It deliberately lives in the .bc subpackage rather than alongside AbstractPublicKeyDataDecryptorFactory, because the top-level operator package is JCA-free and lightweight-crypto-free.

  • Constructor Details

    • BcPublicKeyCryptoCallback

      public BcPublicKeyCryptoCallback()
  • Method Details

    • decrypt

      public abstract byte[] decrypt(int keyAlgorithm, byte[][] pEnc) throws PGPException, org.bouncycastle.crypto.InvalidCipherTextException
      Throws:
      PGPException
      org.bouncycastle.crypto.InvalidCipherTextException
    • decrypt

      public abstract byte[] decrypt(int keyAlgorithm, org.bouncycastle.crypto.params.AsymmetricKeyParameter peerKey) throws PGPException, org.bouncycastle.crypto.InvalidCipherTextException
      Throws:
      PGPException
      org.bouncycastle.crypto.InvalidCipherTextException