Remove single line hash function
This commit is contained in:
parent
d9a583a46c
commit
5fffea1824
2 changed files with 4 additions and 8 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue