Update the computation logic for kek-hash

This commit is contained in:
Vishnu Mohandas 2020-10-02 18:43:15 +05:30
parent 0daecf3924
commit 832b0c7e74
3 changed files with 7 additions and 12 deletions

View file

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:typed_data';
import 'dart:io' as io;
@ -22,7 +23,7 @@ Uint8List cryptoSecretboxOpenEasy(Map<String, dynamic> args) {
args["cipher"], args["nonce"], args["key"]);
}
String cryptoPwhashStr(Map<String, dynamic> args) {
Uint8List cryptoPwhashStr(Map<String, dynamic> args) {
return Sodium.cryptoPwhashStr(
args["input"], args["opsLimit"], args["memLimit"]);
}
@ -179,20 +180,14 @@ class CryptoUtil {
final args = Map<String, dynamic>();
args["input"] = input;
args["opsLimit"] = Sodium.cryptoPwhashOpslimitSensitive;
args["memLimit"] = Sodium.cryptoPwhashMemlimitSensitive;
try {
return await Computer().compute(cryptoPwhashStr, param: args);
} catch (e) {
Logger("CryptoUtil").warning("Forced to reduce memory limit", e);
args["memLimit"] = Sodium.cryptoPwhashMemlimitModerate;
return await Computer().compute(cryptoPwhashStr, param: args);
}
args["memLimit"] = Sodium.cryptoPwhashMemlimitModerate;
return utf8.decode(await Computer().compute(cryptoPwhashStr, param: args));
}
static Future<bool> verifyHash(Uint8List input, String hash) async {
final args = Map<String, dynamic>();
args["input"] = input;
args["hash"] = hash;
args["hash"] = utf8.encode(hash);
return await Computer().compute(cryptoPwhashStrVerify, param: args);
}
}

View file

@ -271,7 +271,7 @@ packages:
name: flutter_sodium
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.6"
version: "0.1.8"
flutter_test:
dependency: "direct dev"
description: flutter

View file

@ -60,7 +60,7 @@ dependencies:
flutter_secure_storage: ^3.3.3
uni_links: ^0.4.0
crisp: ^0.1.3
flutter_sodium: ^0.1.6
flutter_sodium: ^0.1.8
dev_dependencies:
flutter_test: