Remove single line hash function

This commit is contained in:
Vishnu Mohandas 2020-09-10 02:22:18 +05:30
parent d9a583a46c
commit 5fffea1824
2 changed files with 4 additions and 8 deletions

View file

@ -66,10 +66,10 @@ class Configuration {
String passphrase, KeyAttributes attributes) async {
final kek = CryptoUtil.scrypt(
utf8.encode(passphrase), base64.decode(attributes.kekSalt));
bool correctPassphrase = CryptoUtil.compareHash(
kek,
base64.decode(attributes.kekHash),
base64.decode(attributes.kekHashSalt));
final calculatedKekHash =
CryptoUtil.scrypt(kek, base64.decode(attributes.kekHashSalt));
bool correctPassphrase =
base64.encode(calculatedKekHash) == attributes.kekHash;
if (!correctPassphrase) {
throw Exception("Incorrect passphrase");
}

View file

@ -20,10 +20,6 @@ class CryptoUtil {
.hashBytes(salt: salt, input: plainText, len: 32);
}
static bool compareHash(Uint8List plainText, Uint8List hash, Uint8List salt) {
return base64.encode(scrypt(plainText, salt)) == base64.encode(hash);
}
static Uint8List aesEncrypt(
Uint8List plainText, Uint8List key, Uint8List iv) {
final encrypter = AES(Key(key), mode: AESMode.cbc);