in src/java/org/apache/fulcrum/jce/crypto/algo/CryptoStreamPBEImpl.java [125:155]
protected Key createKey( char[] password, byte[] salt )
throws GeneralSecurityException
{
SecretKeyFactory keyFactory;
String algorithm = this.getAlgorithm();
PBEKeySpec keySpec = new PBEKeySpec(password, (salt == null)? this.getSalt(): salt.clone(), this.getCount(), KEY_SIZE );
byte[] encodedTmp = null;
try {
if( this.getProviderName() == null )
{
keyFactory = SecretKeyFactory.getInstance( algorithm );
}
else
{
keyFactory = SecretKeyFactory.getInstance( algorithm, this.getProviderName() );
}
return keyFactory.generateSecret(keySpec);
} catch (NoSuchAlgorithmException e) {
throw new GeneralSecurityException(e);
} finally {
if (encodedTmp != null) {
Arrays.fill(encodedTmp, (byte)0);
}
if (keySpec != null) {
keySpec.clearPassword();
}
}
}