ScramDigestPasswordImpl(final String algorithm, final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { this(algorithm, password, spec.getSalt(), DEFAULT_ITERATION_COUNT); }
UnixDESCryptPasswordImpl(final char[] passwordChars, SaltedPasswordAlgorithmSpec algorithmSpec) throws InvalidParameterSpecException, InvalidKeyException { this(algorithmSpec.getSalt(), passwordChars); }
UnixSHACryptPasswordImpl(final String algorithm, final SaltedPasswordAlgorithmSpec parameterSpec, final char[] password) throws NoSuchAlgorithmException { this(algorithm, truncatedClone(parameterSpec.getSalt()), DEFAULT_ITERATION_COUNT, password); }
UnixMD5CryptPasswordImpl(final char[] password, final SaltedPasswordAlgorithmSpec spec) throws NoSuchAlgorithmException { this(password, truncatedClone(spec.getSalt())); }
SunUnixMD5CryptPasswordImpl(final String algorithm, final char[] password, final SaltedPasswordAlgorithmSpec spec) throws NoSuchAlgorithmException { this(algorithm, password, spec.getSalt().clone(), DEFAULT_ITERATION_COUNT); }
SaltedSimpleDigestPasswordImpl(final String algorithm, final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this(algorithm, spec.getSalt().clone(), password); }
MaskedPasswordImpl(final String algorithm, final char[] clearPassword, final SaltedPasswordAlgorithmSpec parameterSpec) throws InvalidKeySpecException { this(algorithm, DEFAULT_PBE_KEY, DEFAULT_ITERATION_COUNT, parameterSpec.getSalt().clone(), clearPassword); }
protected void engineEncode(final ASN1Encoder encoder, final SaltedPasswordAlgorithmSpec parameterSpec) { encoder.encodeOctetString(parameterSpec.getSalt()); }
BSDUnixDESCryptPasswordImpl(final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException, InvalidParameterSpecException { this(password, getSaltValue(spec.getSalt()), DEFAULT_ITERATION_COUNT); }
BCryptPasswordImpl(final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = spec.getSalt().clone(); this.iterationCount = DEFAULT_ITERATION_COUNT; this.hash = bcrypt(this.iterationCount, this.salt, getNormalizedPasswordBytes(password)); }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; // iteration count has to match exactly since it's not flexible for this algorithm return ITERATION_COUNT == spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { // iteration count has to match exactly since it's not flexible for this algorithm return ITERATION_COUNT == ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { return getIterationCount() <= ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { return getIterationCount() <= ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { return getIterationCount() <= ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount() && Arrays.equals(getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { return getIterationCount() <= ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); if (parameterSpec instanceof IteratedSaltedPasswordAlgorithmSpec) { final IteratedSaltedPasswordAlgorithmSpec spec = (IteratedSaltedPasswordAlgorithmSpec) parameterSpec; return getIterationCount() <= spec.getIterationCount() && Arrays.equals(getParameterSpec().getSalt(), spec.getSalt()); } else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { return Arrays.equals(getParameterSpec().getSalt(), ((SaltedPasswordAlgorithmSpec) parameterSpec).getSalt()); } else if (parameterSpec instanceof IteratedPasswordAlgorithmSpec) { return getIterationCount() <= ((IteratedPasswordAlgorithmSpec) parameterSpec).getIterationCount(); } else { return false; } }
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; } }
} else if (parameterSpec instanceof SaltedPasswordAlgorithmSpec) { SaltedPasswordAlgorithmSpec updateSpec = (SaltedPasswordAlgorithmSpec) parameterSpec; byte[] updateSalt = updateSpec.getSalt(); if (updateSalt != null && ! Arrays.equals(updateSalt, salt)) { throw new InvalidAlgorithmParameterException();
BCryptPasswordImpl(final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = spec.getSalt().clone(); this.iterationCount = DEFAULT_ITERATION_COUNT; this.hash = bcrypt(this.iterationCount, this.salt, getNormalizedPasswordBytes(password)); }
BCryptPasswordImpl(final char[] password, final SaltedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = spec.getSalt().clone(); this.iterationCount = DEFAULT_ITERATION_COUNT; this.hash = bcrypt(this.iterationCount, this.salt, getNormalizedPasswordBytes(password)); }