Abort andOTP import early if number of iterations is suspicious

This commit is contained in:
Alexander Bakker 2022-12-04 20:34:48 +01:00
parent ee6a020f4d
commit 0112431269

View File

@ -123,6 +123,12 @@ public class AndOtpImporter extends DatabaseImporter {
if (iterations < 1) {
throw new DatabaseImporterException(String.format("Invalid number of iterations for PBKDF: %d", iterations));
}
// If number of iterations is this high, it's probably not an andOTP file, so
// abort early in order to prevent having to wait for an extremely long key derivation
// process, only to find out that the user picked the wrong file
if (iterations > 10_000_000L) {
throw new DatabaseImporterException(String.format("Unexpectedly high number of iterations: %d", iterations));
}
byte[] salt = Arrays.copyOfRange(_data, INT_SIZE, INT_SIZE + SALT_SIZE);
return new KeyDerivationParams(password, salt, iterations);