Top Description Fields Constructors Methods
org.bouncycastle.openpgp.operator

public abstract Class PBEKeyEncryptionMethodGenerator

extends PGPKeyEncryptionMethodGenerator
Class Inheritance
Known Direct Subclasses
org.bouncycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator
Imports
java.security.SecureRandom, org.bouncycastle.bcpg.ContainedPacket, .S2K, .SymmetricKeyAlgorithmTags, .SymmetricKeyEncSessionPacket, org.bouncycastle.openpgp.PGPException

PGP style PBE encryption method.

A pass phrase is used to generate an encryption key using the PGP string-to-key method. This class always uses the salted and iterated form of the S2K algorithm.

Note that the iteration count provided to this method is a single byte as described by the S2K algorithm, and the actual iteration count ranges exponentially from 0x01 == 1088 to 0xFF == 65,011,712.

Field Summary

Modifier and TypeField and Description
private char[]
private SecureRandom
private S2K
private int
private PGPDigestCalculator

Constructor Summary

AccessConstructor and Description
protected
PBEKeyEncryptionMethodGenerator(char[]
the pass phrase to encrypt with.
passPhrase
,
PGPDigestCalculator
a digest calculator to use in the string-to-key function.
s2kDigestCalculator
)

Construct a PBE key generator using the default iteration count (0x60 == 65536 iterations).

protected
PBEKeyEncryptionMethodGenerator(char[]
passphrase
passPhrase
,
S2K.Argon2Params
argon2 parameters
params
)

Construct a PBE key generator using Argon2 as S2K mechanism.

protected
PBEKeyEncryptionMethodGenerator(char[]
the pass phrase to encrypt with.
passPhrase
,
PGPDigestCalculator
a digest calculator to use in the string-to-key function.
s2kDigestCalculator
,
int
a single byte S2K iteration count specifier, which is translated to an actual iteration count by the S2K class.
s2kCount
)

Construct a PBE key generator using a specific iteration level.

Method Summary

Modifier and TypeMethod and Description
protected abstract byte[]
encryptSessionInfo(int encAlgorithm, byte[] key, byte[] sessionInfo)

public ContainedPacket
generate(int
the encryption algorithm being used
encAlgorithm
,
byte[]
session data generated by the encrypted data generator.
sessionInfo
)

Implements abstract org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator.generate.

Generates a packet encoding the details of this encryption method.
public byte[]

Returns:

the bytes of the generated key.
getKey
(int
the encryption algorithm to generate the key for.
encAlgorithm
)

Generate a key for a symmetric encryption algorithm using the PBE configuration in this method.

public PBEKeyEncryptionMethodGenerator

Returns:

the current generator.
setSecureRandom
(SecureRandom random)

Sets a user defined source of randomness.

Field Detail

passPhraseback to summary
private char[] passPhrase
randomback to summary
private SecureRandom random
s2kback to summary
private S2K s2k
s2kCountback to summary
private int s2kCount
s2kDigestCalculatorback to summary
private PGPDigestCalculator s2kDigestCalculator

Constructor Detail

PBEKeyEncryptionMethodGeneratorback to summary
protected PBEKeyEncryptionMethodGenerator(char[] passPhrase, PGPDigestCalculator s2kDigestCalculator)

Construct a PBE key generator using the default iteration count (0x60 == 65536 iterations).

Parameters
passPhrase:char[]

the pass phrase to encrypt with.

s2kDigestCalculator:PGPDigestCalculator

a digest calculator to use in the string-to-key function.

PBEKeyEncryptionMethodGeneratorback to summary
protected PBEKeyEncryptionMethodGenerator(char[] passPhrase, S2K.Argon2Params params)

Construct a PBE key generator using Argon2 as S2K mechanism.

Parameters
passPhrase:char[]

passphrase

params:S2K.Argon2Params

argon2 parameters

PBEKeyEncryptionMethodGeneratorback to summary
protected PBEKeyEncryptionMethodGenerator(char[] passPhrase, PGPDigestCalculator s2kDigestCalculator, int s2kCount)

Construct a PBE key generator using a specific iteration level.

Parameters
passPhrase:char[]

the pass phrase to encrypt with.

s2kDigestCalculator:PGPDigestCalculator

a digest calculator to use in the string-to-key function.

s2kCount:int

a single byte S2K iteration count specifier, which is translated to an actual iteration count by the S2K class.

Method Detail

encryptSessionInfoback to summary
protected abstract byte[] encryptSessionInfo(int encAlgorithm, byte[] key, byte[] sessionInfo) throws PGPException
generateback to summary
public ContainedPacket generate(int encAlgorithm, byte[] sessionInfo) throws PGPException

Implements abstract org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator.generate.

Doc from org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator.generate.

Generates a packet encoding the details of this encryption method.

Parameters
encAlgorithm:int

the encryption algorithm being used

sessionInfo:byte[]

session data generated by the encrypted data generator.

Returns:ContainedPacket

a packet encoding the provided information and the configuration of this instance.

Exceptions
PGPException:
if an error occurs constructing the packet.
getKeyback to summary
public byte[] getKey(int encAlgorithm) throws PGPException

Generate a key for a symmetric encryption algorithm using the PBE configuration in this method.

Parameters
encAlgorithm:int

the encryption algorithm to generate the key for.

Returns:byte[]

the bytes of the generated key.

Exceptions
PGPException:
if an error occurs performing the string-to-key generation.
setSecureRandomback to summary
public PBEKeyEncryptionMethodGenerator setSecureRandom(SecureRandom random)

Sets a user defined source of randomness.

If no SecureRandom is configured, a default SecureRandom will be used.

Returns:PBEKeyEncryptionMethodGenerator

the current generator.