Object writeReplace() { return BSDUnixDESCryptPassword.createRaw(getAlgorithm(), hash, salt, iterationCount); }
private static Password createBsdCryptBasedPassword(byte[] userPassword) throws InvalidKeySpecException { if (userPassword.length != 27) { throw log.insufficientDataToFormDigestAndSalt(); } int b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[8] & 0xff); int b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[9] & 0xff); int b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[10] & 0xff); int b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[11] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidRounds((char) b0, (char) b1, (char) b2, (char) b3); } int iterationCount = b0 | b1 << 6 | b2 << 12 | b3 << 18; b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[12] & 0xff); b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[13] & 0xff); b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[14] & 0xff); b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[15] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidSalt((char) b0, (char) b1, (char) b2, (char) b3); } int salt = b0 | b1 << 6 | b2 << 12 | b3 << 18; byte[] hash = CodePointIterator.ofUtf8Bytes(userPassword, 16, 11).base64Decode(ModularCrypt.MOD_CRYPT, false).drain(); return BSDUnixDESCryptPassword.createRaw(ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password parseBSDUnixDESCryptPasswordString(char[] cryptString) throws InvalidKeySpecException { // Note that crypt strings have the format: "_{rounds}{salt}{hash}" as described // in the "DES Extended Format" section here: http://www.freebsd.org/cgi/man.cgi?crypt(3) assert cryptString.length == 20; assert cryptString[0] == '_'; // previously tested by doIdentifyAlgorithm CodePointIterator r = CodePointIterator.ofChars(cryptString, 1); // The next 4 characters correspond to the encoded number of rounds - this is decoded to a 24-bit integer int s0 = MOD_CRYPT.decode(r.next()); int s1 = MOD_CRYPT.decode(r.next()); int s2 = MOD_CRYPT.decode(r.next()); int s3 = MOD_CRYPT.decode(r.next()); int iterationCount = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The next 4 characters correspond to the encoded salt - this is decoded to a 24-bit integer s0 = MOD_CRYPT.decode(r.next()); s1 = MOD_CRYPT.decode(r.next()); s2 = MOD_CRYPT.decode(r.next()); s3 = MOD_CRYPT.decode(r.next()); int salt = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The final 11 characters correspond to the encoded password - this is decoded to a 64-bit hash byte[] hash = r.base64Decode(MOD_CRYPT, false).limitedTo(11).drain(); return BSDUnixDESCryptPassword.createRaw(BSDUnixDESCryptPassword.ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
Object writeReplace() { return BSDUnixDESCryptPassword.createRaw(getAlgorithm(), hash, salt, iterationCount); }
Object writeReplace() { return BSDUnixDESCryptPassword.createRaw(getAlgorithm(), hash, salt, iterationCount); }
Object writeReplace() { return BSDUnixDESCryptPassword.createRaw(getAlgorithm(), hash, salt, iterationCount); }
private static Password createBsdCryptBasedPassword(byte[] userPassword) throws InvalidKeySpecException { if (userPassword.length != 27) { throw log.insufficientDataToFormDigestAndSalt(); } int b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[8] & 0xff); int b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[9] & 0xff); int b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[10] & 0xff); int b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[11] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidRounds((char) b0, (char) b1, (char) b2, (char) b3); } int iterationCount = b0 | b1 << 6 | b2 << 12 | b3 << 18; b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[12] & 0xff); b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[13] & 0xff); b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[14] & 0xff); b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[15] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidSalt((char) b0, (char) b1, (char) b2, (char) b3); } int salt = b0 | b1 << 6 | b2 << 12 | b3 << 18; byte[] hash = CodePointIterator.ofUtf8Bytes(userPassword, 16, 11).base64Decode(ModularCrypt.MOD_CRYPT, false).drain(); return BSDUnixDESCryptPassword.createRaw(ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password createBsdCryptBasedPassword(byte[] userPassword) throws InvalidKeySpecException { if (userPassword.length != 27) { throw log.insufficientDataToFormDigestAndSalt(); } int b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[8] & 0xff); int b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[9] & 0xff); int b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[10] & 0xff); int b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[11] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidRounds((char) b0, (char) b1, (char) b2, (char) b3); } int iterationCount = b0 | b1 << 6 | b2 << 12 | b3 << 18; b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[12] & 0xff); b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[13] & 0xff); b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[14] & 0xff); b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[15] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidSalt((char) b0, (char) b1, (char) b2, (char) b3); } int salt = b0 | b1 << 6 | b2 << 12 | b3 << 18; byte[] hash = CodePointIterator.ofUtf8Bytes(userPassword, 16, 11).base64Decode(ModularCrypt.MOD_CRYPT, false).drain(); return BSDUnixDESCryptPassword.createRaw(ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password createBsdCryptBasedPassword(byte[] userPassword) throws InvalidKeySpecException { if (userPassword.length != 27) { throw log.insufficientDataToFormDigestAndSalt(); } int b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[8] & 0xff); int b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[9] & 0xff); int b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[10] & 0xff); int b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[11] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidRounds((char) b0, (char) b1, (char) b2, (char) b3); } int iterationCount = b0 | b1 << 6 | b2 << 12 | b3 << 18; b0 = ModularCrypt.MOD_CRYPT.decode(userPassword[12] & 0xff); b1 = ModularCrypt.MOD_CRYPT.decode(userPassword[13] & 0xff); b2 = ModularCrypt.MOD_CRYPT.decode(userPassword[14] & 0xff); b3 = ModularCrypt.MOD_CRYPT.decode(userPassword[15] & 0xff); if (b0 == -1 || b1 == -1 || b2 == -1 || b3 == -1) { throw log.invalidSalt((char) b0, (char) b1, (char) b2, (char) b3); } int salt = b0 | b1 << 6 | b2 << 12 | b3 << 18; byte[] hash = CodePointIterator.ofUtf8Bytes(userPassword, 16, 11).base64Decode(ModularCrypt.MOD_CRYPT, false).drain(); return BSDUnixDESCryptPassword.createRaw(ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password parseBSDUnixDESCryptPasswordString(char[] cryptString) throws InvalidKeySpecException { // Note that crypt strings have the format: "_{rounds}{salt}{hash}" as described // in the "DES Extended Format" section here: http://www.freebsd.org/cgi/man.cgi?crypt(3) assert cryptString.length == 20; assert cryptString[0] == '_'; // previously tested by doIdentifyAlgorithm CodePointIterator r = CodePointIterator.ofChars(cryptString, 1); // The next 4 characters correspond to the encoded number of rounds - this is decoded to a 24-bit integer int s0 = MOD_CRYPT.decode(r.next()); int s1 = MOD_CRYPT.decode(r.next()); int s2 = MOD_CRYPT.decode(r.next()); int s3 = MOD_CRYPT.decode(r.next()); int iterationCount = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The next 4 characters correspond to the encoded salt - this is decoded to a 24-bit integer s0 = MOD_CRYPT.decode(r.next()); s1 = MOD_CRYPT.decode(r.next()); s2 = MOD_CRYPT.decode(r.next()); s3 = MOD_CRYPT.decode(r.next()); int salt = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The final 11 characters correspond to the encoded password - this is decoded to a 64-bit hash byte[] hash = r.base64Decode(MOD_CRYPT, false).limitedTo(11).drain(); return BSDUnixDESCryptPassword.createRaw(BSDUnixDESCryptPassword.ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password parseBSDUnixDESCryptPasswordString(char[] cryptString) throws InvalidKeySpecException { // Note that crypt strings have the format: "_{rounds}{salt}{hash}" as described // in the "DES Extended Format" section here: http://www.freebsd.org/cgi/man.cgi?crypt(3) assert cryptString.length == 20; assert cryptString[0] == '_'; // previously tested by doIdentifyAlgorithm CodePointIterator r = CodePointIterator.ofChars(cryptString, 1); // The next 4 characters correspond to the encoded number of rounds - this is decoded to a 24-bit integer int s0 = MOD_CRYPT.decode(r.next()); int s1 = MOD_CRYPT.decode(r.next()); int s2 = MOD_CRYPT.decode(r.next()); int s3 = MOD_CRYPT.decode(r.next()); int iterationCount = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The next 4 characters correspond to the encoded salt - this is decoded to a 24-bit integer s0 = MOD_CRYPT.decode(r.next()); s1 = MOD_CRYPT.decode(r.next()); s2 = MOD_CRYPT.decode(r.next()); s3 = MOD_CRYPT.decode(r.next()); int salt = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The final 11 characters correspond to the encoded password - this is decoded to a 64-bit hash byte[] hash = r.base64Decode(MOD_CRYPT, false).limitedTo(11).drain(); return BSDUnixDESCryptPassword.createRaw(BSDUnixDESCryptPassword.ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }
private static Password parseBSDUnixDESCryptPasswordString(char[] cryptString) throws InvalidKeySpecException { // Note that crypt strings have the format: "_{rounds}{salt}{hash}" as described // in the "DES Extended Format" section here: http://www.freebsd.org/cgi/man.cgi?crypt(3) assert cryptString.length == 20; assert cryptString[0] == '_'; // previously tested by doIdentifyAlgorithm CodePointIterator r = CodePointIterator.ofChars(cryptString, 1); // The next 4 characters correspond to the encoded number of rounds - this is decoded to a 24-bit integer int s0 = MOD_CRYPT.decode(r.next()); int s1 = MOD_CRYPT.decode(r.next()); int s2 = MOD_CRYPT.decode(r.next()); int s3 = MOD_CRYPT.decode(r.next()); int iterationCount = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The next 4 characters correspond to the encoded salt - this is decoded to a 24-bit integer s0 = MOD_CRYPT.decode(r.next()); s1 = MOD_CRYPT.decode(r.next()); s2 = MOD_CRYPT.decode(r.next()); s3 = MOD_CRYPT.decode(r.next()); int salt = s0 | s1 << 6 | s2 << 12 | s3 << 18; // The final 11 characters correspond to the encoded password - this is decoded to a 64-bit hash byte[] hash = r.base64Decode(MOD_CRYPT, false).limitedTo(11).drain(); return BSDUnixDESCryptPassword.createRaw(BSDUnixDESCryptPassword.ALGORITHM_BSD_CRYPT_DES, hash, salt, iterationCount); }