diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2018-04-14 12:22:32 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2018-04-14 12:22:32 -0700 |
commit | faed477de3454a72f1e466c67e948b7819fd96a9 (patch) | |
tree | 70b5a70d7ed78001bfcd6b513b72d91afb83a6ef /ExpensiveHash.hs | |
parent | f3c75396af2f21790a1e0232b0c42790bff82f04 (diff) | |
parent | 8adbfac38a1d6b206c6e40f70f73aaa555435b8e (diff) | |
download | keysafe-faed477de3454a72f1e466c67e948b7819fd96a9.tar.gz |
Merge tag '0.20180326'
tagging package keysafe version 0.20180326
# gpg: Signature made Mon 26 Mar 2018 05:12:25 AM MST
# gpg: using RSA key 28A500C35207EAB72F6C0F25DB12DB0FF05F8F38
# gpg: Good signature from "Joey Hess <joeyh@joeyh.name>" [full]
# Primary key fingerprint: E85A 5F63 B31D 24C1 EBF0 D81C C910 D922 2512 E3C7
# Subkey fingerprint: 28A5 00C3 5207 EAB7 2F6C 0F25 DB12 DB0F F05F 8F38
Diffstat (limited to 'ExpensiveHash.hs')
-rw-r--r-- | ExpensiveHash.hs | 7 |
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) |