Reduce the memlimit for pwhash

This commit is contained in:
Vishnu Mohandas 2020-09-29 00:34:22 +05:30
parent bb85b8f774
commit a4323ad280
2 changed files with 4 additions and 3 deletions

View file

@ -55,7 +55,7 @@ class Configuration {
final encryptedKeyData = await CryptoUtil.encrypt(key, key: kek);
// Hash the passphrase so that its correctness can be compared later
final passphraseHash = await CryptoUtil.hash(utf8.encode(passphrase));
final passphraseHash = CryptoUtil.hash(utf8.encode(passphrase));
final attributes = KeyAttributes(
passphraseHash: passphraseHash,
kekSalt: Sodium.bin2base64(kekSalt),

View file

@ -169,11 +169,12 @@ class CryptoUtil {
Sodium.cryptoPwhashAlgDefault);
}
static Future<String> hash(Uint8List passphrase) async {
static String hash(Uint8List passphrase) {
Sodium.init();
return Sodium.cryptoPwhashStr(
passphrase,
Sodium.cryptoPwhashOpslimitSensitive,
Sodium.cryptoPwhashMemlimitSensitive);
Sodium.cryptoPwhashMemlimitModerate);
}
static bool verifyHash(Uint8List passphrase, String hash) {