public abstract class OpenPGPImplementation
extends java.lang.Object
JCA/JCEimplementation makes use of Java Cryptography Architecture and the Java Cryptography Extension, while
Bcuses Bouncy Castles Lightweight Cryptography API. The purpose of
OpenPGPImplementation
is to define a shared interface for instantiating concrete
objects of either API.
It is advised to define the desired implementation by calling setInstance(OpenPGPImplementation)
and
acquiring it via getInstance()
, as swapping out the entire implementation can then be done by
replacing the instance in one single place.
This pattern was successfully explored by PGPainless.Constructor and Description |
---|
OpenPGPImplementation() |
Modifier and Type | Method and Description |
---|---|
static OpenPGPImplementation |
getInstance()
Return the currently set
OpenPGPImplementation instance. |
abstract KeyFingerPrintCalculator |
keyFingerPrintCalculator() |
abstract PBEDataDecryptorFactory |
pbeDataDecryptorFactory(char[] messagePassphrase)
Return an instance of the
PBEDataDecryptorFactory , which is responsible for providing concrete
implementations needed to decrypt OpenPGP messages that were encrypted symmetrically with a passphrase. |
abstract PBEKeyEncryptionMethodGenerator |
pbeKeyEncryptionMethodGenerator(char[] messagePassphrase)
Return an instance of
PBEKeyEncryptionMethodGenerator which is responsible for creating
symmetric-key-based encryptors for OpenPGP messages, using S2K.SALTED_AND_ITERATED mode. |
abstract PBEKeyEncryptionMethodGenerator |
pbeKeyEncryptionMethodGenerator(char[] messagePassphrase,
S2K.Argon2Params argon2Params)
Return an instance of
PBEKeyEncryptionMethodGenerator which is responsible for creating
symmetric-key-based encryptors for OpenPGP messages, using S2K.ARGON_2 mode. |
abstract PBESecretKeyDecryptorBuilderProvider |
pbeSecretKeyDecryptorBuilderProvider()
Return an instance of
PBESecretKeyDecryptorBuilderProvider which is responsible for providing
implementations needed for secret key unlocking. |
abstract PBESecretKeyEncryptorFactory |
pbeSecretKeyEncryptorFactory(boolean aead) |
abstract PBESecretKeyEncryptorFactory |
pbeSecretKeyEncryptorFactory(boolean aead,
int symmetricKeyAlgorithm,
int iterationCount) |
abstract PGPContentSignerBuilder |
pgpContentSignerBuilder(int publicKeyAlgorithm,
int hashAlgorithm)
Return an instance of
PGPContentSignerBuilder , which is responsible for providing concrete
implementations needed for signature creation. |
abstract PGPContentSignerBuilderProvider |
pgpContentSignerBuilderProvider(int hashAlgorithmId) |
abstract PGPContentVerifierBuilderProvider |
pgpContentVerifierBuilderProvider()
Return an instance of
PGPContentVerifierBuilderProvider which is responsible for providing
implementations needed for signature verification. |
abstract PGPDataEncryptorBuilder |
pgpDataEncryptorBuilder(int symmetricKeyAlgorithm)
Return an instance of
PGPDataEncryptorBuilder which is responsible for providing implementations
needed for creating encrypted data packets. |
abstract PGPDigestCalculatorProvider |
pgpDigestCalculatorProvider()
Return an instance of the
PGPDigestCalculatorProvider , which is responsible for providing
concrete PGPDigestCalculator implementations. |
abstract PGPKeyPairGeneratorProvider |
pgpKeyPairGeneratorProvider() |
abstract PGPObjectFactory |
pgpObjectFactory(java.io.InputStream packetInputStream)
Return an instance of
PGPObjectFactory based on the given InputStream . |
OpenPGPPolicy |
policy() |
abstract PublicKeyDataDecryptorFactory |
publicKeyDataDecryptorFactory(PGPPrivateKey decryptionKey)
Return an instance of the
PublicKeyDataDecryptorFactory , which is responsible for providing
concrete implementations needed to decrypt OpenPGP messages using a PGPPrivateKey . |
abstract PublicKeyKeyEncryptionMethodGenerator |
publicKeyKeyEncryptionMethodGenerator(PGPPublicKey encryptionSubkey)
Return an instance of
PublicKeyKeyEncryptionMethodGenerator which is responsible for
creating public-key-based encryptors for OpenPGP messages. |
abstract SessionKeyDataDecryptorFactory |
sessionKeyDataDecryptorFactory(PGPSessionKey sessionKey)
Return an instance of the
SessionKeyDataDecryptorFactory , which is responsible for providing
concrete implementations needed to decrypt OpenPGP messages using a PGPSessionKey . |
static void |
setInstance(OpenPGPImplementation implementation)
Replace the
OpenPGPImplementation instance that is returned by getInstance() . |
OpenPGPImplementation |
setPolicy(OpenPGPPolicy policy) |
public static void setInstance(OpenPGPImplementation implementation)
OpenPGPImplementation
instance that is returned by getInstance()
.implementation
- instancepublic static OpenPGPImplementation getInstance()
OpenPGPImplementation
instance.
The default is BcOpenPGPImplementation
.public OpenPGPPolicy policy()
public OpenPGPImplementation setPolicy(OpenPGPPolicy policy)
public abstract PGPObjectFactory pgpObjectFactory(java.io.InputStream packetInputStream)
PGPObjectFactory
based on the given InputStream
.packetInputStream
- packet input streampublic abstract PGPContentVerifierBuilderProvider pgpContentVerifierBuilderProvider()
PGPContentVerifierBuilderProvider
which is responsible for providing
implementations needed for signature verification.public abstract PBESecretKeyDecryptorBuilderProvider pbeSecretKeyDecryptorBuilderProvider()
PBESecretKeyDecryptorBuilderProvider
which is responsible for providing
implementations needed for secret key unlocking.public abstract PGPDataEncryptorBuilder pgpDataEncryptorBuilder(int symmetricKeyAlgorithm)
PGPDataEncryptorBuilder
which is responsible for providing implementations
needed for creating encrypted data packets.symmetricKeyAlgorithm
- symmetric encryption algorithmpublic abstract PublicKeyKeyEncryptionMethodGenerator publicKeyKeyEncryptionMethodGenerator(PGPPublicKey encryptionSubkey)
PublicKeyKeyEncryptionMethodGenerator
which is responsible for
creating public-key-based encryptors for OpenPGP messages.
Public-key-based encryptors are used when a message is encrypted for a recipients public key.encryptionSubkey
- subkey for which a message shall be encryptedpublic abstract PBEKeyEncryptionMethodGenerator pbeKeyEncryptionMethodGenerator(char[] messagePassphrase)
PBEKeyEncryptionMethodGenerator
which is responsible for creating
symmetric-key-based encryptors for OpenPGP messages, using S2K.SALTED_AND_ITERATED
mode.
Symmetric-key-based encryptors are used when a message is encrypted using a passphrase.messagePassphrase
- passphrase to encrypt the message withpublic abstract PBEKeyEncryptionMethodGenerator pbeKeyEncryptionMethodGenerator(char[] messagePassphrase, S2K.Argon2Params argon2Params)
PBEKeyEncryptionMethodGenerator
which is responsible for creating
symmetric-key-based encryptors for OpenPGP messages, using S2K.ARGON_2
mode.
Symmetric-key-based encryptors are used when a message is encrypted using a passphrase.messagePassphrase
- passphrase to encrypt the message withargon2Params
- parameters for the Argon2 hash functionpublic abstract PGPContentSignerBuilder pgpContentSignerBuilder(int publicKeyAlgorithm, int hashAlgorithm)
PGPContentSignerBuilder
, which is responsible for providing concrete
implementations needed for signature creation.publicKeyAlgorithm
- the signing-keys public-key algorithmhashAlgorithm
- signature hash algorithmpublic abstract PBEDataDecryptorFactory pbeDataDecryptorFactory(char[] messagePassphrase) throws PGPException
PBEDataDecryptorFactory
, which is responsible for providing concrete
implementations needed to decrypt OpenPGP messages that were encrypted symmetrically with a passphrase.messagePassphrase
- message passphrasePGPException
- if the factory cannot be instantiatedpublic abstract SessionKeyDataDecryptorFactory sessionKeyDataDecryptorFactory(PGPSessionKey sessionKey)
SessionKeyDataDecryptorFactory
, which is responsible for providing
concrete implementations needed to decrypt OpenPGP messages using a PGPSessionKey
.sessionKey
- session keypublic abstract PublicKeyDataDecryptorFactory publicKeyDataDecryptorFactory(PGPPrivateKey decryptionKey)
PublicKeyDataDecryptorFactory
, which is responsible for providing
concrete implementations needed to decrypt OpenPGP messages using a PGPPrivateKey
.decryptionKey
- private decryption keypublic abstract PGPDigestCalculatorProvider pgpDigestCalculatorProvider() throws PGPException
PGPDigestCalculatorProvider
, which is responsible for providing
concrete PGPDigestCalculator
implementations.PGPException
- if the provider cannot be instantiatedpublic abstract PGPKeyPairGeneratorProvider pgpKeyPairGeneratorProvider()
public abstract PGPContentSignerBuilderProvider pgpContentSignerBuilderProvider(int hashAlgorithmId)
public abstract KeyFingerPrintCalculator keyFingerPrintCalculator()
public abstract PBESecretKeyEncryptorFactory pbeSecretKeyEncryptorFactory(boolean aead) throws PGPException
PGPException
public abstract PBESecretKeyEncryptorFactory pbeSecretKeyEncryptorFactory(boolean aead, int symmetricKeyAlgorithm, int iterationCount) throws PGPException
PGPException