From 96eb1c302d693026c6c8076c373638b711e24c6c Mon Sep 17 00:00:00 2001 From: pho Date: Sun, 17 Feb 2008 12:45:39 +0900 Subject: [PATCH] Use HsOpenSSL instead of Crypto darcs-hash:20080217034539-62b54-80e49d861b72fd519389d6fd328dc0cc3c802c92.gz --- ImplantFile.hs | 17 +++++++++-------- Lucu.cabal | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ImplantFile.hs b/ImplantFile.hs index 8ba976d..2fbab00 100644 --- a/ImplantFile.hs +++ b/ImplantFile.hs @@ -5,17 +5,17 @@ import Data.Bits import qualified Data.ByteString.Lazy as Lazy (ByteString) import qualified Data.ByteString.Lazy as L hiding (ByteString) import Data.Char -import Data.Digest.SHA2 import Data.Int import Data.Maybe import Data.Time import Data.Time.Clock.POSIX -import Data.Word import Language.Haskell.Pretty import Language.Haskell.Syntax import Network.HTTP.Lucu.MIMEType import Network.HTTP.Lucu.MIMEType.DefaultExtensionMap import Network.HTTP.Lucu.MIMEType.Guess +import OpenSSL +import OpenSSL.EVP.Digest import System.Console.GetOpt import System.Environment import System.Exit @@ -75,7 +75,8 @@ printUsage = do putStrLn "" main :: IO () -main = do (opts, sources, errors) <- return . getOpt Permute options =<< getArgs +main = withOpenSSL $ + do (opts, sources, errors) <- return . getOpt Permute options =<< getArgs when (not $ null errors) $ do mapM_ putStr errors @@ -409,16 +410,16 @@ getETag opts input _ -> False) opts in case eTagOpts of - [] -> return mkETagFromInput + [] -> getDigestByName "SHA1" >>= return . mkETagFromInput . fromJust (OptETag str):[] -> return str _ -> error "too many --etag options." where - mkETagFromInput :: String - mkETagFromInput = "SHA-1:" ++ (toHex $ toOctets $ sha256 $ L.unpack input) + mkETagFromInput :: Digest -> String + mkETagFromInput sha1 = "SHA-1:" ++ (toHex $ digestLBS sha1 input) - toHex :: [Word8] -> String + toHex :: [Char] -> String toHex [] = "" - toHex (x:xs) = hexByte (fromIntegral x) ++ toHex xs + toHex (x:xs) = hexByte (fromEnum x) ++ toHex xs hexByte :: Int -> String hexByte n diff --git a/Lucu.cabal b/Lucu.cabal index 0e30777..2c56c91 100644 --- a/Lucu.cabal +++ b/Lucu.cabal @@ -13,7 +13,7 @@ License: PublicDomain Author: PHO Maintainer: PHO Stability: experimental -Homepage: http://ccm.sherry.jp/Lucu/ +Homepage: http://cielonegro.org/Lucu Category: Network Tested-With: GHC == 6.8.1 Cabal-Version: >= 1.2 @@ -30,7 +30,7 @@ Flag build-lucu-implant-file Library Build-Depends: - Crypto, base, bytestring, containers, dataenc, directory, + HsOpenSSL, base, bytestring, containers, dataenc, directory, haskell-src, hxt, mtl, network, stm, time, unix, zlib Exposed-Modules: Network.HTTP.Lucu -- 2.40.0