Top Description Fields Constructors Methods
org.bouncycastle.crypto.general

pack-priv Class PKCS12ParametersGenerator<T extends Parameters>

extends PBEParametersGenerator<T extends Parameters>
Class Inheritance
Imports
org.bouncycastle.crypto.Parameters, org.bouncycastle.crypto.internal.CipherParameters, .Digest, .PBEParametersGenerator, org.bouncycastle.crypto.internal.params.KeyParameterImpl, .ParametersWithIV

Generator for PBE derived keys and ivs as defined by PKCS 12 V1.0.

The document this implementation is based on can be found at RSA's PKCS12 Page

Field Summary

Modifier and TypeField and Description
private final Digest
public static final int
public static final int
public static final int
private final int
u

private final int
v

Inherited from org.bouncycastle.crypto.internal.PBEParametersGenerator:
iterationCountpasswordsalt

Constructor Summary

AccessConstructor and Description
public
PKCS12ParametersGenerator(T
algorithm parameters.
parameters
,
Digest
the digest calculator to be used as the source of derived keys.
digest
)

Construct a PKCS 12 Parameters generator.

Method Summary

Modifier and TypeMethod and Description
private void
adjust(byte[] a, int aOff, byte[] b)

add a + b + 1, returning the result in a.

public byte[]
deriveKey(PasswordBasedDeriver.KeyType
type of key to be calculated.
keyType
,
int
the number of bytes to be produced.
keySizeInBytes
)

Implements org.bouncycastle.crypto.PasswordBasedDeriver.deriveKey.

Derive a key of the given keySizeInBytes length.
public byte[][]
deriveKeyAndIV(PasswordBasedDeriver.KeyType
type of key to be calculated.
keyType
,
int
the number of bytes to be produced.
keySizeInBytes
,
int
the number of bytes to be produced.
ivSizeInBytes
)

Implements org.bouncycastle.crypto.PasswordBasedDeriver.deriveKeyAndIV.

Derive a key of the given keySizeInBytes length and an iv of ivSizeInBytes length.
private byte[]
generateDerivedKey(int idByte, int n)

generation of a derived key ala PKCS12 V1.0.

public CipherParameters

Returns:

a KeyParameter object.
generateDerivedMacParameters
(int
the size of the key we want (in bits)
keySize
)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedMacParameters.

Generate a key parameter for use with a MAC derived from the password, salt, and iteration count we are currently initialised with.
public CipherParameters

Returns:

a KeyParameter object.
generateDerivedParameters
(int
the size of the key we want (in bits)
keySize
)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedParameters.

Generate a key parameter derived from the password, salt, and iteration count we are currently initialised with.
public CipherParameters

Returns:

a ParametersWithIV object.
generateDerivedParameters
(int
the size of the key we want (in bits)
keySize
,
int
the size of the iv we want (in bits)
ivSize
)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedParameters.

Generate a key with initialisation vector parameter derived from the password, salt, and iteration count we are currently initialised with.
Inherited from org.bouncycastle.crypto.internal.PBEParametersGenerator:
getIterationCountgetParametersgetPasswordgetSaltinitPKCS12PasswordToBytesPKCS5PasswordToBytesPKCS5PasswordToUTF8Bytes

Field Detail

digestback to summary
private final Digest digest
IV_MATERIALback to summary
public static final int IV_MATERIAL
KEY_MATERIALback to summary
public static final int KEY_MATERIAL
MAC_MATERIALback to summary
public static final int MAC_MATERIAL
uback to summary
private final int u
vback to summary
private final int v

Constructor Detail

PKCS12ParametersGeneratorback to summary
public PKCS12ParametersGenerator(T parameters, Digest digest)

Construct a PKCS 12 Parameters generator. This constructor will accept any digest which also implements ExtendedDigest.

Parameters
parameters:T

algorithm parameters.

digest:Digest

the digest calculator to be used as the source of derived keys.

Exceptions
IllegalArgumentException:
if an unknown digest is passed in.

Method Detail

adjustback to summary
private void adjust(byte[] a, int aOff, byte[] b)

add a + b + 1, returning the result in a. The a value is treated as a BigInteger of length (b.length * 8) bits. The result is modulo 2^b.length in case of overflow.

deriveKeyback to summary
public byte[] deriveKey(PasswordBasedDeriver.KeyType keyType, int keySizeInBytes)

Implements org.bouncycastle.crypto.PasswordBasedDeriver.deriveKey.

Doc from org.bouncycastle.crypto.PasswordBasedDeriver.deriveKey.

Derive a key of the given keySizeInBytes length.

Parameters
keyType:PasswordBasedDeriver.KeyType

type of key to be calculated.

keySizeInBytes:int

the number of bytes to be produced.

Returns:byte[]

a byte array containing the raw key data.

deriveKeyAndIVback to summary
public byte[][] deriveKeyAndIV(PasswordBasedDeriver.KeyType keyType, int keySizeInBytes, int ivSizeInBytes)

Implements org.bouncycastle.crypto.PasswordBasedDeriver.deriveKeyAndIV.

Doc from org.bouncycastle.crypto.PasswordBasedDeriver.deriveKeyAndIV.

Derive a key of the given keySizeInBytes length and an iv of ivSizeInBytes length.

Parameters
keyType:PasswordBasedDeriver.KeyType

type of key to be calculated.

keySizeInBytes:int

the number of bytes to be produced.

ivSizeInBytes:int

the number of bytes to be produced.

Returns:byte[][]

a 2 element byte[] array containing the raw key data in element 0, the iv in element 1.

generateDerivedKeyback to summary
private byte[] generateDerivedKey(int idByte, int n)

generation of a derived key ala PKCS12 V1.0.

generateDerivedMacParametersback to summary
public CipherParameters generateDerivedMacParameters(int keySize)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedMacParameters.

Generate a key parameter for use with a MAC derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

Returns:CipherParameters

a KeyParameter object.

generateDerivedParametersback to summary
public CipherParameters generateDerivedParameters(int keySize)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedParameters.

Generate a key parameter derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

Returns:CipherParameters

a KeyParameter object.

generateDerivedParametersback to summary
public CipherParameters generateDerivedParameters(int keySize, int ivSize)

Implements abstract org.bouncycastle.crypto.internal.PBEParametersGenerator.generateDerivedParameters.

Generate a key with initialisation vector parameter derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

ivSize:int

the size of the iv we want (in bits)

Returns:CipherParameters

a ParametersWithIV object.