BSDUnixDESCryptPasswordImpl(final char[] password, final IteratedPasswordAlgorithmSpec spec) throws InvalidKeySpecException, InvalidParameterSpecException { this(password, ThreadLocalRandom.current().nextInt() & 0xffffff, spec.getIterationCount()); }
MaskedPasswordImpl(final String algorithm, final char[] clearPassword, final IteratedPasswordAlgorithmSpec parameterSpec) throws InvalidKeySpecException { this(algorithm, DEFAULT_PBE_KEY, parameterSpec.getIterationCount(), PasswordUtil.generateRandomSalt(DEFAULT_SALT_SIZE), clearPassword); }
protected void engineEncode(final ASN1Encoder encoder, final IteratedPasswordAlgorithmSpec parameterSpec) { encoder.encodeInteger(parameterSpec.getIterationCount()); }
ScramDigestPasswordImpl(final String algorithm, final char[] password, final IteratedPasswordAlgorithmSpec spec) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException { this(algorithm, password, PasswordUtil.generateRandomSalt(DEFAULT_SALT_SIZE), spec.getIterationCount()); }
SunUnixMD5CryptPasswordImpl(final String algorithm, final char[] password, final IteratedPasswordAlgorithmSpec spec) throws NoSuchAlgorithmException { this(algorithm, password, PasswordUtil.generateRandomSalt(DEFAULT_SALT_SIZE), spec.getIterationCount()); }
BCryptPasswordImpl(final char[] password, final IteratedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = PasswordUtil.generateRandomSalt(BCRYPT_SALT_SIZE); this.iterationCount = spec.getIterationCount(); 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 IteratedPasswordAlgorithmSpec) { final IteratedPasswordAlgorithmSpec updateSpec = (IteratedPasswordAlgorithmSpec) parameterSpec; int updateIterationCount = updateSpec.getIterationCount(); if (updateIterationCount < this.iterationCount) { throw new InvalidAlgorithmParameterException();
BCryptPasswordImpl(final char[] password, final IteratedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = PasswordUtil.generateRandomSalt(BCRYPT_SALT_SIZE); this.iterationCount = spec.getIterationCount(); this.hash = bcrypt(this.iterationCount, this.salt, getNormalizedPasswordBytes(password)); }
BCryptPasswordImpl(final char[] password, final IteratedPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.salt = PasswordUtil.generateRandomSalt(BCRYPT_SALT_SIZE); this.iterationCount = spec.getIterationCount(); 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; 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; } }