Class BcPublicKeyDataDecryptorFactory

java.lang.Object
org.bouncycastle.openpgp.operator.AbstractPublicKeyDataDecryptorFactory
org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory
All Implemented Interfaces:
PGPDataDecryptorFactory, PublicKeyDataDecryptorFactory
Direct Known Subclasses:
BcExternalPublicKeyDataDecryptorFactory

public class BcPublicKeyDataDecryptorFactory extends AbstractPublicKeyDataDecryptorFactory
A decryptor factory for handling public key decryption operations.
  • Constructor Details

    • BcPublicKeyDataDecryptorFactory

      @Deprecated public BcPublicKeyDataDecryptorFactory(PGPPrivateKey pgpPrivKey)
      Deprecated.
      in favor of constructor taking PGPKeyPair.
      Deprecated constructor.
      Parameters:
      pgpPrivKey -
    • BcPublicKeyDataDecryptorFactory

      public BcPublicKeyDataDecryptorFactory(PGPKeyPair pgpKeyPair)
  • Method Details

    • recoverSessionData

      public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion) throws PGPException
      Description copied from interface: PublicKeyDataDecryptorFactory
      Recover the plain session info by decrypting the encrypted session key. This method returns the decrypted session info as-is (without prefixing missing cipher algorithm), so the return value is:
      [sym-alg]?[session-key][checksum]?
      Parameters:
      keyAlgorithm - public key algorithm
      secKeyData - encrypted session key data
      pkeskVersion - version of the PKESK packet
      Returns:
      decrypted session info
      Throws:
      PGPException
    • createDataDecryptor

      public PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, int encAlgorithm, byte[] key) throws PGPException
      Description copied from interface: PGPDataDecryptorFactory
      Constructs a data decryptor for SED or v1 SEIPD packets.
      Parameters:
      withIntegrityPacket - true if the packet to be decrypted has integrity checking enabled.
      encAlgorithm - the identifier of the encryption algorithm to decrypt with.
      key - the bytes of the key for the cipher.
      Returns:
      a data decryptor that can decrypt (and verify) streams of encrypted data.
      Throws:
      PGPException - if an error occurs initialising the decryption and integrity checking functions.
    • createDataDecryptor

      public PGPDataDecryptor createDataDecryptor(AEADEncDataPacket aeadEncDataPacket, PGPSessionKey sessionKey) throws PGPException
      Description copied from interface: PGPDataDecryptorFactory
      Constructs a data decryptor for AEAD Encrypted Data packets. This method is used with OpenPGP v5 AEAD.
      Parameters:
      aeadEncDataPacket - AEAD encrypted data packet
      sessionKey - decrypted session key
      Returns:
      a data decryptor that can decrypt (and verify) streams of encrypted data.
      Throws:
      PGPException - if an error occurs initialising the decryption and integrity checking functions.
    • createDataDecryptor

      public PGPDataDecryptor createDataDecryptor(SymmetricEncIntegrityPacket seipd, PGPSessionKey sessionKey) throws PGPException
      Description copied from interface: PGPDataDecryptorFactory
      Constructs a data decryptor for v2 SEIPD packets. This method is used with OpenPGP v6 AEAD.
      Parameters:
      seipd - version 2 symmetrically encrypted integrity-protected data packet using AEAD.
      sessionKey - decrypted session key
      Returns:
      a data decryptor that can decrypt (and verify) streams of encrypted data.
      Throws:
      PGPException - if an error occurs initialising the decryption and integrity checking functions.
    • getCryptoCallback

      protected BcPublicKeyCryptoCallback getCryptoCallback()
      Return the callback used for the raw private-key operations. Subclasses backing the key with a hardware device override this to route those operations to the device.
      Returns:
      crypto callback
    • unwrapSessionData

      public static byte[] unwrapSessionData(byte[] keyEnc, int symmetricKeyAlgorithm, org.bouncycastle.crypto.params.KeyParameter key) throws PGPException, org.bouncycastle.crypto.InvalidCipherTextException
      Throws:
      PGPException
      org.bouncycastle.crypto.InvalidCipherTextException