Object writeReplace() { return UnixDESCryptPassword.createRaw(getAlgorithm(), salt, hash); }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); return parameterSpec.equals(getParameterSpec()); }
default SaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[2]; // Big-endian format saltBytes[0] = (byte) (salt >>> 8 & 0xff); saltBytes[1] = (byte) (salt & 0xff); return new SaltedPasswordAlgorithmSpec(saltBytes); }
default SaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[2]; // Big-endian format saltBytes[0] = (byte) (salt >>> 8 & 0xff); saltBytes[1] = (byte) (salt & 0xff); return new SaltedPasswordAlgorithmSpec(saltBytes); }
private static void composeCryptBasedPassword(ByteArrayOutputStream out, UnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
private static Password createCryptBasedPassword(byte[] userPassword) throws InvalidKeySpecException { if (userPassword.length != 20) { throw log.insufficientDataToFormDigestAndSalt(); } final int lo = ModularCrypt.MOD_CRYPT.decode(userPassword[7] & 0xff); final int hi = ModularCrypt.MOD_CRYPT.decode(userPassword[8] & 0xff); if (lo == -1 || hi == -1) { throw log.invalidSalt((char) lo, (char) hi); } short salt = (short) (lo | hi << 6); byte[] hash = CodePointIterator.ofUtf8Bytes(userPassword, 9, 11).base64Decode(ModularCrypt.MOD_CRYPT, false).drain(); return UnixDESCryptPassword.createRaw(ALGORITHM_CRYPT_DES, salt, hash); }
default SaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[2]; // Big-endian format saltBytes[0] = (byte) (salt >>> 8 & 0xff); saltBytes[1] = (byte) (salt & 0xff); return new SaltedPasswordAlgorithmSpec(saltBytes); }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); return parameterSpec.equals(getParameterSpec()); }
private static Password parseUnixDESCryptPasswordString(char[] cryptString) throws InvalidKeySpecException { assert cryptString.length == 13; // previously tested by doIdentifyAlgorithm CodePointIterator r = CodePointIterator.ofChars(cryptString); // 12 bit salt int s0 = MOD_CRYPT.decode(r.next()); int s1 = MOD_CRYPT.decode(r.next()); short salt = (short) (s0 | s1 << 6); // 64 bit hash byte[] hash = r.base64Decode(MOD_CRYPT, false).limitedTo(8).drain(); return UnixDESCryptPassword.createRaw(UnixDESCryptPassword.ALGORITHM_CRYPT_DES, salt, hash); }
default SaltedPasswordAlgorithmSpec getParameterSpec() { final int salt = getSalt(); byte[] saltBytes = new byte[2]; // Big-endian format saltBytes[0] = (byte) (salt >>> 8 & 0xff); saltBytes[1] = (byte) (salt & 0xff); return new SaltedPasswordAlgorithmSpec(saltBytes); }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); return parameterSpec.equals(getParameterSpec()); }
Object writeReplace() { return UnixDESCryptPassword.createRaw(getAlgorithm(), salt, hash); }
default boolean impliesParameters(AlgorithmParameterSpec parameterSpec) { Assert.checkNotNullParam("parameterSpec", parameterSpec); return parameterSpec.equals(getParameterSpec()); }
Object writeReplace() { return UnixDESCryptPassword.createRaw(getAlgorithm(), salt, hash); }
private static void composeCryptBasedPassword(ByteArrayOutputStream out, UnixDESCryptPassword password) throws IOException { out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() & 0x3f)); out.write(ModularCrypt.MOD_CRYPT.encode(password.getSalt() >> 6 & 0x3f)); out.write(ByteIterator.ofBytes(password.getHash()).base64Encode(ModularCrypt.MOD_CRYPT, false).asUtf8().drain()); }
Object writeReplace() { return UnixDESCryptPassword.createRaw(getAlgorithm(), salt, hash); }