From 8af994320d3cd343e038bd9721c5ecc80e4b9246 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 26 Mar 2018 07:39:13 -0400 Subject: Updated to argon2-1.3. New parameters are set to the old values and test suite passes so this looks good. This commit was sponsored by Nick Daly on Patreon. --- ExpensiveHash.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ExpensiveHash.hs') diff --git a/ExpensiveHash.hs b/ExpensiveHash.hs index 6fab15c..4a01194 100644 --- a/ExpensiveHash.hs +++ b/ExpensiveHash.hs @@ -11,6 +11,7 @@ import Tunables import Cost import Serialization () import qualified Data.Text as T +import Data.Text.Short (toText) import qualified Data.ByteString as B import qualified Crypto.Argon2 as Argon2 import Raaz.Core.Encode @@ -31,12 +32,10 @@ data Salt t = Salt t expensiveHash :: Encodable t => ExpensiveHashTunable -> Salt t -> B.ByteString -> ExpensiveHash expensiveHash (UseArgon2 cost opts) (Salt s) b = ExpensiveHash cost $ - -- Using hashEncoded here and not hash, - -- because of this bug: - -- https://github.com/ocharles/argon2/issues/3 - Argon2.hashEncoded opts b argonsalt + either hashfailed toText $ Argon2.hashEncoded opts b argonsalt where -- argon salt cannot be shorter than 8 bytes, so pad with spaces. argonsalt = let sb = toByteString s in sb <> B.replicate (8 - B.length sb ) 32 + hashfailed e = error ("hash generation failed: " ++ show e) -- cgit v1.2.3