on e46572e help sign in
stackage/patching/patches/pwstore-fast-2.4.patch
47 lines 1.6 kB history raw
1diff -ru orig/Crypto/PasswordStore.hs new/Crypto/PasswordStore.hs
2--- orig/Crypto/PasswordStore.hs 2013-09-17 11:48:49.178111970 +0300
3+++ new/Crypto/PasswordStore.hs 2013-09-17 11:48:49.000000000 +0300
4@@ -1,4 +1,5 @@
5 {-# LANGUAGE OverloadedStrings, BangPatterns #-}
6+{-# LANGUAGE CPP #-}
7 -- |
8 -- Module : Crypto.PasswordStore
9 -- Copyright : (c) Peter Scott, 2011
10@@ -149,8 +150,8 @@
11 -> ByteString
12 -- ^ The encoded message
13 hmacSHA256 secret msg =
14- let digest = SHA.hmacSha256 (BL.fromStrict secret) (BL.fromStrict msg)
15- in BL.toStrict . SHA.bytestringDigest $ digest
16+ let digest = SHA.hmacSha256 (fromStrict secret) (fromStrict msg)
17+ in toStrict . SHA.bytestringDigest $ digest
19 -- | PBKDF2 key-derivation function.
20 -- For details see @http://tools.ietf.org/html/rfc2898@.
21@@ -403,3 +404,26 @@
22 where (a, g') = randomR ('\NUL', '\255') g
23 salt = makeSalt $ B.pack $ map fst (rands gen 16)
24 newgen = snd $ last (rands gen 16)
26+#if !MIN_VERSION_base(4, 6, 0)
27+-- | Strict version of 'modifySTRef'
28+modifySTRef' :: STRef s a -> (a -> a) -> ST s ()
29+modifySTRef' ref f = do
30+ x <- readSTRef ref
31+ let x' = f x
32+ x' `seq` writeSTRef ref x'
33+#endif
35+#if MIN_VERSION_bytestring(0, 10, 0)
36+toStrict :: BL.ByteString -> BS.ByteString
37+toStrict = BL.toStrict
39+fromStrict :: BS.ByteString -> BL.ByteString
40+fromStrict = BL.fromStrict
41+#else
42+toStrict :: BL.ByteString -> BS.ByteString
43+toStrict = BS.concat . BL.toChunks
45+fromStrict :: BS.ByteString -> BL.ByteString
46+fromStrict = BL.fromChunks . return
47+#endif