return MaskedPassword.isMaskedAlgorithm(algorithm) && password instanceof MaskedPassword && algorithm.equals(password.getAlgorithm());
Object writeReplace() { return MaskedPassword.createRaw(algorithm, initialKeyMaterial.clone(), iterationCount, salt.clone(), maskedPasswordBytes.clone()); }
MaskedPasswordImpl(final MaskedPassword password) throws InvalidKeySpecException { this(password.getAlgorithm(), password.getInitialKeyMaterial().clone(), password.getIterationCount(), password.getSalt().clone(), password.getMaskedPasswordBytes().clone(), false); }
default MaskedPasswordAlgorithmSpec getParameterSpec() { return new MaskedPasswordAlgorithmSpec(getInitialKeyMaterial(), getIterationCount(), getSalt()); }
/** * 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; }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof MaskedPasswordAlgorithmSpec) { MaskedPasswordAlgorithmSpec spec = (MaskedPasswordAlgorithmSpec) parameterSpec; return Arrays.equals(getInitialKeyMaterial(), spec.getInitialKeyMaterial()) && getIterationCount() <= spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { final SaltedPasswordAlgorithmSpec spec = (SaltedPasswordAlgorithmSpec) parameterSpec; return Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { final IteratedPasswordAlgorithmSpec spec = (IteratedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount(); } else if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return Arrays.equals(getSalt(), spec.getSalt()) && getIterationCount() <= spec.getIterationCount(); } else { return false; } }
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); } }
MaskedPasswordImpl(final MaskedPassword password) throws InvalidKeySpecException { this(password.getAlgorithm(), password.getInitialKeyMaterial().clone(), password.getIterationCount(), password.getSalt().clone(), password.getMaskedPasswordBytes().clone(), false); }
default MaskedPasswordAlgorithmSpec getParameterSpec() { return new MaskedPasswordAlgorithmSpec(getInitialKeyMaterial(), getIterationCount(), getSalt()); }
if (MaskedPassword.isMaskedAlgorithm(algorithm)) { if (password instanceof MaskedPasswordImpl && algorithm.equals(password.getAlgorithm())) { return password;
/** * 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; }
Object writeReplace() { return MaskedPassword.createRaw(algorithm, initialKeyMaterial.clone(), iterationCount, salt.clone(), maskedPasswordBytes.clone()); }
MaskedPasswordImpl(final MaskedPassword password) throws InvalidKeySpecException { this(password.getAlgorithm(), password.getInitialKeyMaterial().clone(), password.getIterationCount(), password.getSalt().clone(), password.getMaskedPasswordBytes().clone(), false); }
default MaskedPasswordAlgorithmSpec getParameterSpec() { return new MaskedPasswordAlgorithmSpec(getInitialKeyMaterial(), getIterationCount(), getSalt()); }
if (MaskedPassword.isMaskedAlgorithm(matchedAlgorithm)) { decoder.startSequence(); final char[] initialKeyMaterial = decoder.decodeOctetStringAsString().toCharArray();
/** * 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; }
Object writeReplace() { return MaskedPassword.createRaw(algorithm, initialKeyMaterial.clone(), iterationCount, salt.clone(), maskedPasswordBytes.clone()); }
MaskedPasswordImpl(final MaskedPassword password) throws InvalidKeySpecException { this(password.getAlgorithm(), password.getInitialKeyMaterial().clone(), password.getIterationCount(), password.getSalt().clone(), password.getMaskedPasswordBytes().clone(), false); }
default MaskedPasswordAlgorithmSpec getParameterSpec() { return new MaskedPasswordAlgorithmSpec(getInitialKeyMaterial(), getIterationCount(), getSalt()); }
if (MaskedPassword.isMaskedAlgorithm(algorithmName)) { final MaskedPasswordSpec passwordSpec = passwordFactory.getKeySpec(passwordFactory.translate(password), MaskedPasswordSpec.class); encoder.startSequence();