Package org.bouncycastle
Class CachingBcPublicKeyDataDecryptorFactory
java.lang.Object
org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory
org.bouncycastle.CachingBcPublicKeyDataDecryptorFactory
- All Implemented Interfaces:
org.bouncycastle.openpgp.operator.PGPDataDecryptorFactory
,org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory
,CustomPublicKeyDataDecryptorFactory
public class CachingBcPublicKeyDataDecryptorFactory
extends org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory
implements 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 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
ConstructorsConstructorDescriptionCachingBcPublicKeyDataDecryptorFactory
(org.bouncycastle.openpgp.PGPPrivateKey privateKey, SubkeyIdentifier decryptionKey) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
byte[]
costlyRecoverSessionData
(int keyAlgorithm, byte[][] secKeyData) Return theSubkeyIdentifier
for which this particularCustomPublicKeyDataDecryptorFactory
is intended.byte[]
recoverSessionData
(int keyAlgorithm, byte[][] secKeyData) Methods inherited from class org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory
createDataDecryptor, createDataDecryptor, createDataDecryptor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bouncycastle.openpgp.operator.PGPDataDecryptorFactory
createDataDecryptor, createDataDecryptor, createDataDecryptor
-
Constructor Details
-
CachingBcPublicKeyDataDecryptorFactory
public CachingBcPublicKeyDataDecryptorFactory(org.bouncycastle.openpgp.PGPPrivateKey privateKey, SubkeyIdentifier decryptionKey)
-
-
Method Details
-
recoverSessionData
public byte[] recoverSessionData(int keyAlgorithm, byte[][] secKeyData) throws org.bouncycastle.openpgp.PGPException - Specified by:
recoverSessionData
in interfaceorg.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory
- Overrides:
recoverSessionData
in classorg.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory
- Throws:
org.bouncycastle.openpgp.PGPException
-
costlyRecoverSessionData
public byte[] costlyRecoverSessionData(int keyAlgorithm, byte[][] secKeyData) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
clear
public void clear() -
getSubkeyIdentifier
Description copied from interface:CustomPublicKeyDataDecryptorFactory
Return theSubkeyIdentifier
for which this particularCustomPublicKeyDataDecryptorFactory
is intended.- Specified by:
getSubkeyIdentifier
in interfaceCustomPublicKeyDataDecryptorFactory
- Returns:
- subkey identifier
-