OpenSSLPBEParametersGeneratorpublic class OpenSSLPBEParametersGenerator extends org.bouncycastle.crypto.PBEParametersGenerator Generator for PBE derived keys and ivs as usd by OpenSSL.
The scheme is a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an
iteration count of 1.
|
Fields Summary |
---|
private org.bouncycastle.crypto.Digest | digest |
Constructors Summary |
---|
public OpenSSLPBEParametersGenerator()Construct a OpenSSL Parameters generator.
|
Methods Summary |
---|
private byte[] | generateDerivedKey(int bytesNeeded)the derived key function, the ith hash of the password and the salt.
byte[] buf = new byte[digest.getDigestSize()];
byte[] key = new byte[bytesNeeded];
int offset = 0;
for (;;)
{
digest.update(password, 0, password.length);
digest.update(salt, 0, salt.length);
digest.doFinal(buf, 0);
int len = (bytesNeeded > buf.length) ? buf.length : bytesNeeded;
System.arraycopy(buf, 0, key, offset, len);
offset += len;
// check if we need any more
bytesNeeded -= len;
if (bytesNeeded == 0)
{
break;
}
// do another round
digest.reset();
digest.update(buf, 0, buf.length);
}
return key;
| public org.bouncycastle.crypto.CipherParameters | generateDerivedMacParameters(int keySize)Generate a key parameter for use with a MAC derived from the password,
salt, and iteration count we are currently initialised with.
return generateDerivedParameters(keySize);
| public org.bouncycastle.crypto.CipherParameters | generateDerivedParameters(int keySize)Generate a key parameter derived from the password, salt, and iteration
count we are currently initialised with.
keySize = keySize / 8;
byte[] dKey = generateDerivedKey(keySize);
return new KeyParameter(dKey, 0, keySize);
| public org.bouncycastle.crypto.CipherParameters | generateDerivedParameters(int keySize, int ivSize)Generate a key with initialisation vector parameter derived from
the password, salt, and iteration count we are currently initialised
with.
keySize = keySize / 8;
ivSize = ivSize / 8;
byte[] dKey = generateDerivedKey(keySize + ivSize);
return new ParametersWithIV(new KeyParameter(dKey, 0, keySize), dKey, keySize, ivSize);
| public void | init(byte[] password, byte[] salt)Initialise - note the iteration count for this algorithm is fixed at 1.
super.init(password, salt, 1);
|
|