summaryrefslogtreecommitdiffhomepage
path: root/ExpensiveHash.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2018-03-26 07:39:13 -0400
committerJoey Hess <joeyh@joeyh.name>2018-03-26 08:09:41 -0400
commit8af994320d3cd343e038bd9721c5ecc80e4b9246 (patch)
treeb515bfaaefea900dbed45f48759168d2da424a31 /ExpensiveHash.hs
parent473e0484d6408e014243071fbe0698c03dd6ebe8 (diff)
downloadkeysafe-8af994320d3cd343e038bd9721c5ecc80e4b9246.tar.gz
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.
Diffstat (limited to 'ExpensiveHash.hs')
-rw-r--r--ExpensiveHash.hs7
1 files changed, 3 insertions, 4 deletions
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)