on master help sign in
pwstore-fast for GHC 7.4
commit2c33fd91d4cc065face0417d7b954962b01a2b96 authorMichael Snoyman <michael@snoyman.com> dateTue 17 Sep 2013, 11:49 (13 years ago) parent9630343
1 file changed+47
patching/patches/pwstore-fast-2.4.patch+47
patching/patches/pwstore-fast-2.4.patchnew file+47
@@ -0,0 +1,47 @@
1+diff -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
18+
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)
25++
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
34++
35++#if MIN_VERSION_bytestring(0, 10, 0)
36++toStrict :: BL.ByteString -> BS.ByteString
37++toStrict = BL.toStrict
38++
39++fromStrict :: BS.ByteString -> BL.ByteString
40++fromStrict = BL.fromStrict
41++#else
42++toStrict :: BL.ByteString -> BS.ByteString
43++toStrict = BS.concat . BL.toChunks
44++
45++fromStrict :: BS.ByteString -> BL.ByteString
46++fromStrict = BL.fromChunks . return
47++#endif