/** * Determine if the given algorithm name is a valid masked password algorithm name. * * @param name the algorithm name * @return {@code true} if the algorithm name is valid for this password type, {@code false} otherwise */ static boolean isMaskedAlgorithm(String name) { return getPBEName(name) != null; }
private static Cipher getCipher(final String algorithm, final char[] initialKeyMaterial, final int iterationCount, final byte[] salt, final int mode) throws InvalidKeySpecException { try { // Create the factories first to fail fast final String pbeName = MaskedPassword.getPBEName(algorithm); Assert.assertNotNull(pbeName); final SecretKeyFactory factory = SecretKeyFactory.getInstance(pbeName); final Cipher cipher = Cipher.getInstance(pbeName); // Create the PBE secret key final PBEParameterSpec cipherSpec = new PBEParameterSpec(salt, iterationCount); final PBEKeySpec keySpec = new PBEKeySpec(initialKeyMaterial); final SecretKey cipherKey = factory.generateSecret(keySpec); cipher.init(mode, cipherKey, cipherSpec); return cipher; } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) { throw new InvalidKeySpecException(e); } }
/** * Determine if the given algorithm name is a valid masked password algorithm name. * * @param name the algorithm name * @return {@code true} if the algorithm name is valid for this password type, {@code false} otherwise */ static boolean isMaskedAlgorithm(String name) { return getPBEName(name) != null; }
/** * Determine if the given algorithm name is a valid masked password algorithm name. * * @param name the algorithm name * @return {@code true} if the algorithm name is valid for this password type, {@code false} otherwise */ static boolean isMaskedAlgorithm(String name) { return getPBEName(name) != null; }
/** * Determine if the given algorithm name is a valid masked password algorithm name. * * @param name the algorithm name * @return {@code true} if the algorithm name is valid for this password type, {@code false} otherwise */ static boolean isMaskedAlgorithm(String name) { return getPBEName(name) != null; }
private static Cipher getCipher(final String algorithm, final char[] initialKeyMaterial, final int iterationCount, final byte[] salt, final int mode) throws InvalidKeySpecException { try { // Create the factories first to fail fast final String pbeName = MaskedPassword.getPBEName(algorithm); Assert.assertNotNull(pbeName); final SecretKeyFactory factory = SecretKeyFactory.getInstance(pbeName); final Cipher cipher = Cipher.getInstance(pbeName); // Create the PBE secret key final PBEParameterSpec cipherSpec = new PBEParameterSpec(salt, iterationCount); final PBEKeySpec keySpec = new PBEKeySpec(initialKeyMaterial); final SecretKey cipherKey = factory.generateSecret(keySpec); cipher.init(mode, cipherKey, cipherSpec); return cipher; } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) { throw new InvalidKeySpecException(e); } }
private static Cipher getCipher(final String algorithm, final char[] initialKeyMaterial, final int iterationCount, final byte[] salt, final int mode) throws InvalidKeySpecException { try { // Create the factories first to fail fast final String pbeName = MaskedPassword.getPBEName(algorithm); Assert.assertNotNull(pbeName); final SecretKeyFactory factory = SecretKeyFactory.getInstance(pbeName); final Cipher cipher = Cipher.getInstance(pbeName); // Create the PBE secret key final PBEParameterSpec cipherSpec = new PBEParameterSpec(salt, iterationCount); final PBEKeySpec keySpec = new PBEKeySpec(initialKeyMaterial); final SecretKey cipherKey = factory.generateSecret(keySpec); cipher.init(mode, cipherKey, cipherSpec); return cipher; } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) { throw new InvalidKeySpecException(e); } }
private static Cipher getCipher(final String algorithm, final char[] initialKeyMaterial, final int iterationCount, final byte[] salt, final int mode) throws InvalidKeySpecException { try { // Create the factories first to fail fast final String pbeName = MaskedPassword.getPBEName(algorithm); Assert.assertNotNull(pbeName); final SecretKeyFactory factory = SecretKeyFactory.getInstance(pbeName); final Cipher cipher = Cipher.getInstance(pbeName); // Create the PBE secret key final PBEParameterSpec cipherSpec = new PBEParameterSpec(salt, iterationCount); final PBEKeySpec keySpec = new PBEKeySpec(initialKeyMaterial); final SecretKey cipherKey = factory.generateSecret(keySpec); cipher.init(mode, cipherKey, cipherSpec); return cipher; } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException e) { throw new InvalidKeySpecException(e); } }