byte[] pwHash = hashPassword(_info, password);
byte[] iv = generateIv(algorithm, verifier.getSalt(), null);
SecretKey skey;
skey = new SecretKeySpec(generateKey(pwHash, kVerifierInputBlock), "AES");
Cipher cipher = getCipher(algorithm, mode, skey, iv);
byte[] verifierHashInput = cipher.doFinal(verifier.getVerifier());
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
byte[] trimmed = new byte[verifier.getSalt().length];
System.arraycopy(verifierHashInput, 0, trimmed, 0, trimmed.length);
byte[] hashedVerifier = sha1.digest(trimmed);
skey = new SecretKeySpec(generateKey(pwHash, kHashedVerifierBlock), "AES");
iv = generateIv(algorithm, verifier.getSalt(), null);
cipher = getCipher(algorithm, mode, skey, iv);
byte[] verifierHash = cipher.doFinal(verifier.getVerifierHash());
trimmed = new byte[hashedVerifier.length];
System.arraycopy(verifierHash, 0, trimmed, 0, trimmed.length);
if (Arrays.equals(trimmed, hashedVerifier)) {
skey = new SecretKeySpec(generateKey(pwHash, kCryptoKeyBlock), "AES");
iv = generateIv(algorithm, verifier.getSalt(), null);
cipher = getCipher(algorithm, mode, skey, iv);
byte[] inter = cipher.doFinal(verifier.getEncryptedKey());
byte[] keyspec = new byte[_info.getHeader().getKeySize() / 8];
System.arraycopy(inter, 0, keyspec, 0, keyspec.length);
_secretKey = new SecretKeySpec(keyspec, "AES");
return true;
} else {
return false;
}
}