Permalink
Browse files

Added -Wall to the ghc-options.

darcs-hash:20071105062056-62b54-3f86595988e734498684b248eb1e3024d5c669b1.gz
  • Loading branch information...
1 parent 07b3ae7 commit 0f5a6a57ad3818def0aeceeb0273ae0da2cb76f7 @depressed-pho committed Nov 5, 2007
View
@@ -37,6 +37,10 @@ Library
else
build-depends: base < 3, time >= 1.1.1
+ --PkgConfig-Depends: openssl >= 0.9.7l
+ -- We really should use this instead of the configure script but
+ -- Cabal 1.2.2.0 can't handle the weird version scheme of OpenSSL.
+
Exposed-Modules:
OpenSSL
OpenSSL.BN
@@ -70,7 +74,7 @@ Library
Extensions:
ForeignFunctionInterface, EmptyDataDecls, MagicHash
ghc-options:
- -O2 -fwarn-unused-imports -fglasgow-exts
+ -Wall -fglasgow-exts
C-Sources:
cbits/HsOpenSSL.c
Include-Dirs:
View
@@ -1,15 +1,15 @@
CABAL_FILE = HsOpenSSL.cabal
GHC = ghc
-build: .setup-config Setup
+build: dist/setup-config Setup
./Setup build
run: build
@echo ".:.:. Let's go .:.:."
$(MAKE) -C examples run
-.setup-config: $(CABAL_FILE) configure Setup
- ./Setup configure -p
+dist/setup-config: $(CABAL_FILE) configure Setup
+ ./Setup configure -p -O --enable-split-objs
configure: aclocal.m4 configure.ac
autoconf
@@ -26,7 +26,7 @@ clean:
$(MAKE) -C examples clean
doc: .setup-config Setup
- ./Setup haddock
+ ./Setup haddock --hyperlink-source --hscolour-css=../hscolour/hscolour.css
install: build
sudo ./Setup install
View
@@ -157,6 +157,6 @@ allocaASN1Time m
withASN1Time :: UTCTime -> (Ptr ASN1_TIME -> IO a) -> IO a
withASN1Time utc m
= allocaASN1Time $ \ time ->
- do _ASN1_TIME_set time (fromIntegral $ round $ utcTimeToPOSIXSeconds utc)
+ do _ASN1_TIME_set time (fromIntegral $ (round $ utcTimeToPOSIXSeconds utc :: Integer))
>>= failIfNull
m time
View
@@ -41,7 +41,7 @@ module OpenSSL.BN
)
where
-import Control.Exception
+import Control.Exception hiding (try)
import Foreign
import qualified Data.ByteString as BS
import OpenSSL.Utils
@@ -172,7 +172,7 @@ bnToInteger bn = do
if negative == 0
then return $ S## i
else return $ 0 - (S## i)
- otherwise -> do
+ _ -> do
let (I## nlimbsi) = fromIntegral nlimbs
(I## limbsize) = (#size unsigned long)
(MBA arr) <- newByteArray (nlimbsi *## limbsize)
@@ -290,7 +290,7 @@ foreign import ccall unsafe "BN_mod_exp"
_mod_exp :: Ptr BIGNUM -> Ptr BIGNUM -> Ptr BIGNUM -> Ptr BIGNUM -> BNCtx -> IO (Ptr BIGNUM)
type BNCtx = Ptr BNCTX
-data BNCTX = BNCTX
+data BNCTX
foreign import ccall unsafe "BN_CTX_new"
_BN_ctx_new :: IO BNCtx
View
@@ -29,6 +29,7 @@ import OpenSSL.Utils
data Mode = Encrypt | Decrypt deriving (Eq, Show)
+modeToInt :: Num a => Mode -> a
modeToInt Encrypt = 1
modeToInt Decrypt = 0
@@ -71,7 +72,7 @@ newAESCtx mode key iv = do
when (BS.length iv /= 16) $ fail "Bad AES128 iv length"
ctx <- mallocForeignPtrBytes (#size AES_KEY)
withForeignPtr ctx $ \ctxPtr ->
- BS.useAsCStringLen key (\(ptr, len) ->
+ BS.useAsCStringLen key (\(ptr, _) ->
case mode of
Encrypt -> _AES_set_encrypt_key ptr (fromIntegral keyLen) ctxPtr >>= failIf (/= 0)
Decrypt -> _AES_set_decrypt_key ptr (fromIntegral keyLen) ctxPtr >>= failIf (/= 0))
@@ -80,7 +81,7 @@ newAESCtx mode key iv = do
nref <- newIORef 0
withForeignPtr ecounter (\ecptr -> _memset ecptr 0 16)
withForeignPtr ivbytes $ \ivPtr ->
- BS.useAsCStringLen iv $ \(ptr, len) ->
+ BS.useAsCStringLen iv $ \(ptr, _) ->
do _memcpy ivPtr ptr 16
return $ AESCtx ctx ivbytes ecounter nref mode
@@ -102,6 +103,7 @@ aesCBC (AESCtx ctx iv _ _ mode) input = do
aesCTR :: AESCtx -- ^ context
-> BS.ByteString -- ^ input, any number of bytes
-> IO BS.ByteString
+aesCTR (AESCtx _ _ _ _ Decrypt) _ = fail "the context mode must be Encrypt"
aesCTR (AESCtx ctx iv ecounter nref Encrypt) input = do
withForeignPtr ctx $ \ctxPtr ->
withForeignPtr iv $ \ivPtr ->
View
@@ -15,7 +15,7 @@ module OpenSSL.EVP.Base64
)
where
-import Control.Exception
+import Control.Exception hiding (block)
import Data.ByteString.Internal (createAndTrim)
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import qualified Data.ByteString.Lazy.Internal as L8Internal
@@ -32,12 +32,13 @@ import Foreign.C
--
-- デコード時: 分割のアルゴリズムは同じだが最低バイト数が 4。
nextBlock :: Int -> ([B8.ByteString], L8.ByteString) -> ([B8.ByteString], L8.ByteString)
-nextBlock _ (xs, L8Internal.Empty ) = (xs, L8Internal.Empty)
-nextBlock minLen (xs, src) = if foldl' (+) 0 (map B8.length xs) >= minLen then
- (xs, src)
- else
- case src of
- L8Internal.Chunk y ys -> nextBlock minLen (xs ++ [y], ys)
+nextBlock minLen (xs, src)
+ = if foldl' (+) 0 (map B8.length xs) >= minLen then
+ (xs, src)
+ else
+ case src of
+ L8Internal.Empty -> (xs, src)
+ L8Internal.Chunk y ys -> nextBlock minLen (xs ++ [y], ys)
{- encode -------------------------------------------------------------------- -}
View
@@ -62,7 +62,7 @@ foreign import ccall unsafe "HsOpenSSL_EVP_CIPHER_iv_length"
withCipherPtr :: Cipher -> (Ptr EVP_CIPHER -> IO a) -> IO a
-withCipherPtr (Cipher cipher) f = f cipher
+withCipherPtr (Cipher cipherPtr) f = f cipherPtr
-- |@'getCipherByName' name@ returns a symmetric cipher algorithm
-- whose name is @name@. If no algorithms are found, the result is
@@ -83,7 +83,7 @@ getCipherNames = getObjNames CipherMethodType True
cipherIvLength :: Cipher -> Int
-cipherIvLength (Cipher cipher) = _iv_length cipher
+cipherIvLength (Cipher cipherPtr) = _iv_length cipherPtr
{- EVP_CIPHER_CTX ------------------------------------------------------------ -}
View
@@ -30,7 +30,6 @@ module OpenSSL.EVP.Digest
where
import Control.Monad
-import Data.ByteString (packCStringLen)
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
@@ -51,9 +50,6 @@ data EVP_MD
foreign import ccall unsafe "EVP_get_digestbyname"
_get_digestbyname :: CString -> IO (Ptr EVP_MD)
-foreign import ccall unsafe "HsOpenSSL_EVP_MD_size"
- mdSize :: Ptr EVP_MD -> Int
-
withMDPtr :: Digest -> (Ptr EVP_MD -> IO a) -> IO a
withMDPtr (Digest mdPtr) f = f mdPtr
@@ -128,11 +124,6 @@ digestUpdateBS ctx bs
_DigestUpdate ctxPtr buf (fromIntegral len) >>= failIf (/= 1) >> return ()
-digestUpdateLBS :: DigestCtx -> L8.ByteString -> IO ()
-digestUpdateLBS ctx lbs
- = mapM_ (digestUpdateBS ctx) $ L8.toChunks lbs
-
-
digestFinal :: DigestCtx -> IO String
digestFinal ctx
= withDigestCtxPtr ctx $ \ ctxPtr ->
@@ -196,4 +187,4 @@ hmacBS (Digest md) key input =
unsafeUseAsCStringLen input $ \(inputdata, inputlen) ->
do _HMAC md keydata (fromIntegral keylen) inputdata (fromIntegral inputlen) bufPtr bufLenPtr
bufLen <- liftM fromIntegral $ peek bufLenPtr
- packCStringLen (bufPtr, bufLen)
+ B8.packCStringLen (bufPtr, bufLen)
View
@@ -29,7 +29,7 @@ module OpenSSL.EVP.PKey
import Foreign
import OpenSSL.DSA
-import OpenSSL.EVP.Digest
+import OpenSSL.EVP.Digest hiding (digest)
import OpenSSL.RSA
import OpenSSL.Utils
View
@@ -15,7 +15,7 @@ import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
import Foreign
import Foreign.C
-import OpenSSL.EVP.Cipher
+import OpenSSL.EVP.Cipher hiding (cipher)
import OpenSSL.EVP.PKey
import OpenSSL.Utils
View
@@ -35,12 +35,12 @@ module OpenSSL.PEM
)
where
-import Control.Exception
+import Control.Exception hiding (try)
import Control.Monad
import Foreign
import Foreign.C
import OpenSSL.BIO
-import OpenSSL.EVP.Cipher
+import OpenSSL.EVP.Cipher hiding (cipher)
import OpenSSL.EVP.PKey
import OpenSSL.PKCS7
import OpenSSL.Utils
@@ -92,6 +92,7 @@ foreign import ccall "wrapper"
rwflagToState :: Int -> PemPasswordRWState
rwflagToState 0 = PwRead
rwflagToState 1 = PwWrite
+rwflagToState _ = undefined
callPasswordCB :: PemPasswordCallback -> PemPasswordCallback'
View
@@ -33,7 +33,7 @@ import Data.Typeable
import Foreign
import Foreign.C
import OpenSSL.BIO
-import OpenSSL.EVP.Cipher
+import OpenSSL.EVP.Cipher hiding (cipher)
import OpenSSL.EVP.PKey
import OpenSSL.Stack
import OpenSSL.Utils
View
@@ -51,6 +51,7 @@ toHex = reverse . map hexByte . unfoldr step where
hexByte 13 = 'd'
hexByte 14 = 'e'
hexByte 15 = 'f'
+ hexByte _ = undefined
-- | Convert a hex string to an integer
fromHex :: (Bits i) => String -> i
@@ -79,3 +80,4 @@ fromHex = foldl step 0 where
byteHex 'D' = 13
byteHex 'E' = 14
byteHex 'F' = 15
+ byteHex _ = undefined
View
@@ -56,7 +56,7 @@ import Foreign
import Foreign.C
import OpenSSL.ASN1
import OpenSSL.BIO
-import OpenSSL.EVP.Digest
+import OpenSSL.EVP.Digest hiding (digest)
import OpenSSL.EVP.PKey
import OpenSSL.EVP.Verify
import OpenSSL.Utils
View
@@ -37,7 +37,7 @@ import Control.Monad
import Foreign
import Foreign.C
import OpenSSL.BIO
-import OpenSSL.EVP.Digest
+import OpenSSL.EVP.Digest hiding (digest)
import OpenSSL.EVP.PKey
import OpenSSL.EVP.Verify
import OpenSSL.Utils
@@ -49,7 +49,7 @@ import Foreign
import Foreign.C
import OpenSSL.ASN1
import OpenSSL.BIO
-import OpenSSL.EVP.Digest
+import OpenSSL.EVP.Digest hiding (digest)
import OpenSSL.EVP.PKey
import OpenSSL.EVP.Verify
import OpenSSL.Stack

0 comments on commit 0f5a6a5

Please sign in to comment.