public boolean isValid(PasswordHashData passwordHash, String password) {
byte[] salt = passwordHash.getSalt().toByteArray();
int rounds = passwordHash.getRounds();
int keySize = DEFAULT_KEYSIZE;
PBEKey key = doPbkdf2(rounds, salt, password, keySize);
byte[] encoded = key.getEncoded();
byte[] stored = passwordHash.getData().toByteArray();
return org.keyczar.util.Util.safeArrayEquals(encoded, stored);
}