Hi everybody, im doing password based file encryption in Java. Im using AES as the underlying encryption algorithm and PBKDF2WithHmacSHA1 to derive a key from a salt and password combination using the following code(which i got from another generous poster on this site).
SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec ks = new PBEKeySpec(password,salt,1024,128);
SecretKey s = f.generateSecret(ks);
Key k = new SecretKeySpec(s.getEncoded(),"AES");
I share the salt, the user enters their password at each end and encrytion and decryption work fine :-) My problem is that i would like to be able to verify that the password the user enters is correct before embarking on the (potentialy long) decrytpion process. I know the PBKD spec includes an optional 2 byte verification value but im not sure how to generate this value using the above approach. Does java provide support for this or if not what would be a secure alternative?
Thanks for your time.