Class CachingBcPublicKeyDataDecryptorFactory

java.lang.Object
org.bouncycastle.openpgp.operator.AbstractPublicKeyDataDecryptorFactory
org.pgpainless.decryption_verification.CustomPublicKeyDataDecryptorFactory
org.pgpainless.decryption_verification.CachingBcPublicKeyDataDecryptorFactory
All Implemented Interfaces:
org.bouncycastle.openpgp.operator.PGPDataDecryptorFactory, org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory

public class CachingBcPublicKeyDataDecryptorFactory extends CustomPublicKeyDataDecryptorFactory
Implementation of the PublicKeyDataDecryptorFactory which caches decrypted session keys. That way, if a message needs to be decrypted multiple times, expensive private key operations can be omitted. This implementation changes the behavior or AbstractPublicKeyDataDecryptorFactory.recoverSessionData(int, byte[][]) to first return any cache hits. If no hit is found, the method call is delegated to the underlying PublicKeyDataDecryptorFactory. The result of that is then placed in the cache and returned.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CachingBcPublicKeyDataDecryptorFactory(org.bouncycastle.openpgp.PGPPrivateKey privateKey, SubkeyIdentifier decryptionKey)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    byte[]
    costlyRecoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion)
     
    org.bouncycastle.openpgp.operator.PGPDataDecryptor
    createDataDecryptor(boolean b, int i, byte[] bytes)
     
    org.bouncycastle.openpgp.operator.PGPDataDecryptor
    createDataDecryptor(org.bouncycastle.bcpg.AEADEncDataPacket aeadEncDataPacket, org.bouncycastle.openpgp.PGPSessionKey pgpSessionKey)
     
    org.bouncycastle.openpgp.operator.PGPDataDecryptor
    createDataDecryptor(org.bouncycastle.bcpg.SymmetricEncIntegrityPacket symmetricEncIntegrityPacket, org.bouncycastle.openpgp.PGPSessionKey pgpSessionKey)
     
     
    byte[]
    recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion)
     

    Methods inherited from class org.bouncycastle.openpgp.operator.AbstractPublicKeyDataDecryptorFactory

    checkRange, containsSKAlg, prependSKAlgorithmToSessionData, recoverSessionData, recoverSessionData

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CachingBcPublicKeyDataDecryptorFactory

      public CachingBcPublicKeyDataDecryptorFactory(org.bouncycastle.openpgp.PGPPrivateKey privateKey, SubkeyIdentifier decryptionKey)
  • Method Details

    • recoverSessionData

      public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion) throws org.bouncycastle.openpgp.PGPException
      Throws:
      org.bouncycastle.openpgp.PGPException
    • costlyRecoverSessionData

      public byte[] costlyRecoverSessionData(int keyAlgorithm, byte[][] secKeyData, int pkeskVersion) throws org.bouncycastle.openpgp.PGPException
      Throws:
      org.bouncycastle.openpgp.PGPException
    • clear

      public void clear()
    • getSubkeyIdentifier

      public SubkeyIdentifier getSubkeyIdentifier()
    • createDataDecryptor

      public org.bouncycastle.openpgp.operator.PGPDataDecryptor createDataDecryptor(boolean b, int i, byte[] bytes) throws org.bouncycastle.openpgp.PGPException
      Throws:
      org.bouncycastle.openpgp.PGPException
    • createDataDecryptor

      public org.bouncycastle.openpgp.operator.PGPDataDecryptor createDataDecryptor(org.bouncycastle.bcpg.AEADEncDataPacket aeadEncDataPacket, org.bouncycastle.openpgp.PGPSessionKey pgpSessionKey) throws org.bouncycastle.openpgp.PGPException
      Throws:
      org.bouncycastle.openpgp.PGPException
    • createDataDecryptor

      public org.bouncycastle.openpgp.operator.PGPDataDecryptor createDataDecryptor(org.bouncycastle.bcpg.SymmetricEncIntegrityPacket symmetricEncIntegrityPacket, org.bouncycastle.openpgp.PGPSessionKey pgpSessionKey) throws org.bouncycastle.openpgp.PGPException
      Throws:
      org.bouncycastle.openpgp.PGPException