From 1b40d64a20e45f8ac49f669039e9a257c1f07023 Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Wed, 30 Sep 2020 23:59:58 +0530 Subject: [PATCH] Move hash verification to a separate isolate --- lib/utils/crypto_util.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/utils/crypto_util.dart b/lib/utils/crypto_util.dart index 56df94b98..fff7296ad 100644 --- a/lib/utils/crypto_util.dart +++ b/lib/utils/crypto_util.dart @@ -27,6 +27,10 @@ String cryptoPwhashStr(Map args) { args["input"], args["opsLimit"], args["memLimit"]); } +bool cryptoPwhashStrVerify(Map args) { + return Sodium.cryptoPwhashStrVerify(args["hash"], args["input"]) == 0; +} + ChaChaAttributes chachaEncrypt(Map args) { final encryptionStartTime = DateTime.now().millisecondsSinceEpoch; final logger = Logger("ChaChaEncrypt"); @@ -189,7 +193,10 @@ class CryptoUtil { } } - static bool verifyHash(Uint8List passphrase, String hash) { - return Sodium.cryptoPwhashStrVerify(hash, passphrase) == 0; + static Future verifyHash(Uint8List input, String hash) async { + final args = Map(); + args["input"] = input; + args["hash"] = hash; + return await Computer().compute(cryptoPwhashStrVerify, param: args); } }