default IteratedSaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[4]; // Big-endian format saltBytes[0] = (byte) (salt >>> 24 & 0xff); saltBytes[1] = (byte) (salt >>> 16 & 0xff); saltBytes[2] = (byte) (salt >>> 8 & 0xff); saltBytes[3] = (byte) (salt & 0xff); return new IteratedSaltedPasswordAlgorithmSpec(getIterationCount(), saltBytes); }
private static void composeBsdCryptBasedPassword(ByteArrayOutputStream out, BSDUnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 18 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 18 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
BSDUnixDESCryptPasswordImpl(final BSDUnixDESCryptPassword password) throws InvalidKeyException { this.salt = password.getSalt(); this.iterationCount = password.getIterationCount(); final byte[] hash = password.getHash(); if (hash == null || hash.length != BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE) { throw log.invalidKeyBsdDesCryptPasswordHashMustBeBytes(BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE); } this.hash = hash.clone(); }
default IteratedSaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[4]; // Big-endian format saltBytes[0] = (byte) (salt >>> 24 & 0xff); saltBytes[1] = (byte) (salt >>> 16 & 0xff); saltBytes[2] = (byte) (salt >>> 8 & 0xff); saltBytes[3] = (byte) (salt & 0xff); return new IteratedSaltedPasswordAlgorithmSpec(getIterationCount(), saltBytes); }
default IteratedSaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[4]; // Big-endian format saltBytes[0] = (byte) (salt >>> 24 & 0xff); saltBytes[1] = (byte) (salt >>> 16 & 0xff); saltBytes[2] = (byte) (salt >>> 8 & 0xff); saltBytes[3] = (byte) (salt & 0xff); return new IteratedSaltedPasswordAlgorithmSpec(getIterationCount(), saltBytes); }
default IteratedSaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[4]; // Big-endian format saltBytes[0] = (byte) (salt >>> 24 & 0xff); saltBytes[1] = (byte) (salt >>> 16 & 0xff); saltBytes[2] = (byte) (salt >>> 8 & 0xff); saltBytes[3] = (byte) (salt & 0xff); return new IteratedSaltedPasswordAlgorithmSpec(getIterationCount(), saltBytes); }
private static void composeBsdCryptBasedPassword(ByteArrayOutputStream out, BSDUnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 18 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 18 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
private static void composeBsdCryptBasedPassword(ByteArrayOutputStream out, BSDUnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 18 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 18 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
private static void composeBsdCryptBasedPassword(ByteArrayOutputStream out, BSDUnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getIterationCount() >> 18 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 12 & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 18 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
BSDUnixDESCryptPasswordImpl(final BSDUnixDESCryptPassword password) throws InvalidKeyException { this.salt = password.getSalt(); this.iterationCount = password.getIterationCount(); final byte[] hash = password.getHash(); if (hash == null || hash.length != BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE) { throw log.invalidKeyBsdDesCryptPasswordHashMustBeBytes(BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE); } this.hash = hash.clone(); }
BSDUnixDESCryptPasswordImpl(final BSDUnixDESCryptPassword password) throws InvalidKeyException { this.salt = password.getSalt(); this.iterationCount = password.getIterationCount(); final byte[] hash = password.getHash(); if (hash == null || hash.length != BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE) { throw log.invalidKeyBsdDesCryptPasswordHashMustBeBytes(BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE); } this.hash = hash.clone(); }
BSDUnixDESCryptPasswordImpl(final BSDUnixDESCryptPassword password) throws InvalidKeyException { this.salt = password.getSalt(); this.iterationCount = password.getIterationCount(); final byte[] hash = password.getHash(); if (hash == null || hash.length != BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE) { throw log.invalidKeyBsdDesCryptPasswordHashMustBeBytes(BSDUnixDESCryptPassword.BSD_CRYPT_DES_HASH_SIZE); } this.hash = hash.clone(); }