Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Added -Wall to the ghc-options.
Browse files Browse the repository at this point in the history
darcs-hash:20071105062056-62b54-3f86595988e734498684b248eb1e3024d5c669b1.gz
  • Loading branch information
depressed-pho committed Nov 5, 2007
1 parent 07b3ae7 commit 0f5a6a5
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 38 deletions.
6 changes: 5 additions & 1 deletion HsOpenSSL.cabal
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion OpenSSL/ASN1.hsc
Expand Up @@ -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
6 changes: 3 additions & 3 deletions OpenSSL/BN.hsc
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions OpenSSL/Cipher.hsc
Expand Up @@ -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

Expand Down Expand Up @@ -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))
Expand All @@ -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

Expand All @@ -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 ->
Expand Down
15 changes: 8 additions & 7 deletions OpenSSL/EVP/Base64.hsc
Expand Up @@ -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
Expand All @@ -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 -------------------------------------------------------------------- -}
Expand Down
4 changes: 2 additions & 2 deletions OpenSSL/EVP/Cipher.hsc
Expand Up @@ -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
Expand All @@ -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 ------------------------------------------------------------ -}
Expand Down
11 changes: 1 addition & 10 deletions OpenSSL/EVP/Digest.hsc
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion OpenSSL/EVP/PKey.hsc
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion OpenSSL/EVP/Seal.hsc
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions OpenSSL/PEM.hsc
Expand Up @@ -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
Expand Down Expand Up @@ -92,6 +92,7 @@ foreign import ccall "wrapper"
rwflagToState :: Int -> PemPasswordRWState
rwflagToState 0 = PwRead
rwflagToState 1 = PwWrite
rwflagToState _ = undefined


callPasswordCB :: PemPasswordCallback -> PemPasswordCallback'
Expand Down
2 changes: 1 addition & 1 deletion OpenSSL/PKCS7.hsc
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions OpenSSL/Utils.hs
Expand Up @@ -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
Expand Down Expand Up @@ -79,3 +80,4 @@ fromHex = foldl step 0 where
byteHex 'D' = 13
byteHex 'E' = 14
byteHex 'F' = 15
byteHex _ = undefined
2 changes: 1 addition & 1 deletion OpenSSL/X509.hsc
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion OpenSSL/X509/Request.hsc
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion OpenSSL/X509/Revocation.hsc
Expand Up @@ -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
Expand Down

0 comments on commit 0f5a6a5

Please sign in to comment.