in src/java/org/apache/fulcrum/jce/crypto/extended/CryptoStreamFactoryJ8Template.java [269:306]
protected abstract Key createKey( char[] password, byte[] salt )
throws GeneralSecurityException;
/**
* Create a Cipher.
*
* @param is the input stream
* @param mode the cipher mode
* @param password the password
* @return an instance of a cipher
* @return the cipher as byte array
* @throws GeneralSecurityException creating a cipher failed
* @throws IOException creating a cipher failed
*/
protected abstract byte[] createCipher(InputStream is, int mode, char[] password )
throws GeneralSecurityException, IOException;
/**
* creates salt from {@link SecureRandom#getInstance(String)} by default was algorithm SHA1PRNG
*
* changed to {@link SecureRandom#getInstanceStrong()} and let the system decide, what PRNG to use for salt random.
*
* salt size is by default @link {@value #SALT_SIZE}.
*
* @return the generated salt as byte array
* @throws GeneralSecurityException if no algo could be found.
*/
protected static byte[] generateSalt() throws GeneralSecurityException {
SecureRandom random;
try {
random = SecureRandom.getInstanceStrong();
byte[] salt = new byte[SALT_SIZE ];
random.nextBytes(salt);
return salt;
} catch (NoSuchAlgorithmException e) {
throw new GeneralSecurityException(e);
}
}