private void initializeCipher(String kdfName, byte[] kdfOptions, Cipher cipher) throws Buffer.BufferException { if (kdfName.equals(BCRYPT)) { PlainBuffer opts = new PlainBuffer(kdfOptions); byte[] passphrase = new byte[0]; if (pwdf != null) { CharBuffer charBuffer = CharBuffer.wrap(pwdf.reqPassword(null)); ByteBuffer byteBuffer = Charset.forName("UTF-8").encode(charBuffer); passphrase = Arrays.copyOfRange(byteBuffer.array(), byteBuffer.position(), byteBuffer.limit()); } byte[] keyiv = new byte[48]; new BCrypt().pbkdf(passphrase, opts.readBytes(), opts.readUInt32AsInt(), keyiv); byte[] key = Arrays.copyOfRange(keyiv, 0, 32); byte[] iv = Arrays.copyOfRange(keyiv, 32, 48); cipher.init(Cipher.Mode.Decrypt, key, iv); } else { throw new IllegalStateException("No support for KDF '" + kdfName + "'."); } }
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
public void testBCryptPbkdfTestVectors() throws Exception { System.out.print("BCrypt.pbkdf w/ known vectors: "); for (BCryptPbkdfTV tv : bcrypt_pbkdf_test_vectors) { byte[] output = new byte[tv.out.length]; new BCrypt().pbkdf(tv.pass, tv.salt, tv.rounds, output); assertEquals(Arrays.toString(tv.out), Arrays.toString(output)); System.out.print("."); } System.out.println(""); } }
public void testBCryptHashTestVectors() throws Exception { System.out.print("BCrypt.hash w/ known vectors: "); for (BCryptHashTV tv : bcrypt_hash_test_vectors) { byte[] output = new byte[tv.out.length]; new BCrypt().hash(tv.pass, tv.salt, output); assertEquals(Arrays.toString(tv.out), Arrays.toString(output)); System.out.print("."); } System.out.println(""); }
private static byte[] generateKayAndIvPbkdf2(byte[] password, byte[] salt, int rounds, int keyLength, int ivLength) { byte[] keyAndIV = new byte[keyLength + ivLength]; new BCrypt().pbkdf(password, salt, rounds, keyAndIV); return keyAndIV; }
int plaintext[] = {0x155cbf8e, 0x57f57513, 0x3da787b9, 0x71679d82, 0x7cf72e93, 0x1ae25274, 0x64b54adc, 0x335cbd0b}; BCrypt bcrypt = new BCrypt(); byte[] rawBytes = bcrypt.crypt_raw(password.getBytes( StandardCharsets.UTF_8), salt,
private void initializeCipher(String kdfName, byte[] kdfOptions, Cipher cipher) throws Buffer.BufferException { if (kdfName.equals(BCRYPT)) { PlainBuffer opts = new PlainBuffer(kdfOptions); byte[] passphrase = new byte[0]; if (pwdf != null) { CharBuffer charBuffer = CharBuffer.wrap(pwdf.reqPassword(null)); ByteBuffer byteBuffer = Charset.forName("UTF-8").encode(charBuffer); passphrase = Arrays.copyOfRange(byteBuffer.array(), byteBuffer.position(), byteBuffer.limit()); } byte[] keyiv = new byte[48]; new BCrypt().pbkdf(passphrase, opts.readBytes(), opts.readUInt32AsInt(), keyiv); byte[] key = Arrays.copyOfRange(keyiv, 0, 32); byte[] iv = Arrays.copyOfRange(keyiv, 32, 48); cipher.init(Cipher.Mode.Decrypt, key, iv); } else { throw new IllegalStateException("No support for KDF '" + kdfName + "'."); } }
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
0x7cf72e93, 0x1ae25274, 0x64b54adc, 0x335cbd0b}; final byte[] password = {1, 2, 3, 4, 5, 6, 7, 8}; BCrypt bcrypt = new BCrypt();
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
B = new BCrypt(); hashed = B.crypt_raw(passwordb, saltb, rounds, (int[])bf_crypt_ciphertext.clone());
BCrypt bcrypt = new BCrypt(); byte[] rawBytes = bcrypt.crypt_raw(password.getBytes( StandardCharsets.UTF_8),