summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-21 16:37:14 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-21 16:37:14 -0400
commit892593c5efacbc084d19af4b5d7164ededaea7ff (patch)
tree20c1763ad5ca69b89c4a8977d6a45c98dc64b217
parent66d951c3fd1a2aa19543d4148be8de734f54fd5c (diff)
Use haskell Crypto library instead of haskell SHA library.a
Since hS3 needs Crypto anyway, this actually reduces dependencies.
-rw-r--r--Crypto.hs24
-rw-r--r--debian/changelog6
-rw-r--r--debian/control2
-rw-r--r--doc/install.mdwn2
4 files changed, 24 insertions, 10 deletions
diff --git a/Crypto.hs b/Crypto.hs
index 478d83761..ef7b49d8f 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -27,20 +27,21 @@ module Crypto (
import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Map as M
import qualified Codec.Binary.Base64 as B64
-import Data.ByteString.Lazy.UTF8 (fromString)
-import Data.Digest.Pure.SHA
-import System.Cmd.Utils
import Data.String.Utils
import Data.List
import Data.Bits.Utils
+import Data.HMAC
+import Data.Array
+import Codec.Utils
+import System.Cmd.Utils
import System.IO
import System.Posix.IO
import System.Posix.Types
import System.Posix.Process
-import Control.Concurrent
-import Control.Exception (finally)
import System.Exit
import System.Environment
+import Control.Concurrent
+import Control.Exception (finally)
import Types
import Key
@@ -143,9 +144,9 @@ decryptCipher _ (EncryptedCipher encipher _) =
encryptKey :: Cipher -> Key -> IO Key
encryptKey c k =
return Key {
- keyName = showDigest $ hmacSha1
- (fromString $ cipherHmac c)
- (fromString $ show k),
+ keyName = showOctets $ hmac_sha1
+ (s2w8 $ cipherHmac c)
+ (s2w8 $ show k),
keyBackendName = "GPGHMACSHA1",
keySize = Nothing, -- size and mtime omitted
keyMtime = Nothing -- to avoid leaking data
@@ -252,3 +253,10 @@ fromB64 s =
case B64.decode s of
Nothing -> error "bad base64 encoded data"
Just ws -> w82s ws
+
+showOctets :: [Octet] -> String
+showOctets = concat . map hexChars
+ where
+ hexChars c = [arr ! (c `div` 16), arr ! (c `mod` 16)]
+ arr = listArray (0, 15) "0123456789abcdef"
+
diff --git a/debian/changelog b/debian/changelog
index 26e9e8172..5955f2958 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (0.20110421) UNRELEASED; urgency=low
+
+ * Use haskell Crypto library instead of haskell SHA library.
+
+ -- Joey Hess <joeyh@debian.org> Thu, 21 Apr 2011 16:35:27 -0400
+
git-annex (0.20110420) unstable; urgency=low
* Update Debian build dependencies for ghc 7.
diff --git a/debian/control b/debian/control
index 768638997..97b04ea5b 100644
--- a/debian/control
+++ b/debian/control
@@ -7,8 +7,8 @@ Build-Depends:
libghc-missingh-dev,
libghc-pcre-light-dev,
libghc-testpack-dev,
- libghc-sha-dev,
libghc-dataenc-dev,
+ libghc-crypto-dev,
libghc-utf8-string-dev,
libghc-hs3-dev (>= 0.5.6),
ikiwiki,
diff --git a/doc/install.mdwn b/doc/install.mdwn
index 3d15eac60..a6b86891d 100644
--- a/doc/install.mdwn
+++ b/doc/install.mdwn
@@ -13,7 +13,7 @@ To build and use git-annex, you will need:
* MissingH: <http://github.com/jgoerzen/missingh/wiki>
* pcre-light: <http://hackage.haskell.org/package/pcre-light>
* utf8-string: <http://hackage.haskell.org/package/utf8-string>
-* SHA: <http://hackage.haskell.org/package/SHA>
+* crypto: <http://hackage.haskell.org/package/Crypto>
* dataenc: <http://hackage.haskell.org/package/dataenc>
* TestPack <http://hackage.haskell.org/cgi-bin/hackage-scripts/package/testpack>
* QuickCheck 2 <http://hackage.haskell.org/package/QuickCheck>