diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..3604612
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,29 @@
+
+
+
+
+ HsOpenSSL
+
+
+ phonohawk
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HsOpenSSL.cabal b/HsOpenSSL.cabal
index e33aaaf..1408561 100644
--- a/HsOpenSSL.cabal
+++ b/HsOpenSSL.cabal
@@ -7,10 +7,11 @@ Description:
messages.
Version: 0.1
License: PublicDomain
-Author: PHO
-Maintainer: PHO
+License-File: COPYING
+Author: PHO
+Maintainer: PHO
Stability: experimental
-Homepage: http://ccm.sherry.jp/hs-openssl/
+Homepage: http://ccm.sherry.jp/HsOpenSSL/
Category: Cryptography
Tested-With: GHC == 6.6.1
Build-Depends:
@@ -44,7 +45,7 @@ Exposed-Modules:
Extensions:
ForeignFunctionInterface
ghc-options:
- -fglasgow-exts -O2
+ -fglasgow-exts -O2 -fwarn-unused-imports
C-Sources:
cbits/HsOpenSSL.c
Include-Dirs:
@@ -53,9 +54,10 @@ Install-Includes:
HsOpenSSL.h
Extra-Source-Files:
HsOpenSSL.buildinfo.in
+ cbits/HsOpenSSL.h
configure
configure.ac
examples/Makefile
examples/GenRSAKey.hs
examples/HelloWorld.hs
- examples/PKCS7.hs
\ No newline at end of file
+ examples/PKCS7.hs
diff --git a/OpenSSL/BIO.hsc b/OpenSSL/BIO.hsc
index 3cba02e..d06954c 100644
--- a/OpenSSL/BIO.hsc
+++ b/OpenSSL/BIO.hsc
@@ -76,7 +76,6 @@ module OpenSSL.BIO
where
import Control.Monad
-import qualified Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
@@ -261,7 +260,7 @@ bioReadLBS bio = lazyRead >>= return . LPS
lazyRead = unsafeInterleaveIO loop
loop = do bs <- bioReadBS bio chunkSize
- if B.null bs then
+ if B8.null bs then
do isEOF <- bioEOF bio
if isEOF then
return []
@@ -318,10 +317,10 @@ bioWriteBS bio bs
where
interpret :: Int -> IO ()
interpret n
- | n == B.length bs = return ()
- | n == -1 = bioWriteBS bio bs -- full retry
- | n < -1 = raiseOpenSSLError
- | otherwise = bioWriteBS bio (B.drop n bs) -- partial retry
+ | n == B8.length bs = return ()
+ | n == -1 = bioWriteBS bio bs -- full retry
+ | n < -1 = raiseOpenSSLError
+ | otherwise = bioWriteBS bio (B8.drop n bs) -- partial retry
-- |@'bioWriteLBS' bio lbs@ lazily writes entire @lbs@ to @bio@. The
-- string doesn't necessarily have to be finite.
@@ -459,7 +458,7 @@ newConstMemBS bs
-- LazyByteString.
newConstMemLBS :: LazyByteString -> IO BIO
newConstMemLBS (LPS bss)
- = (return . B.concat) bss >>= newConstMemBS
+ = (return . B8.concat) bss >>= newConstMemBS
{- null --------------------------------------------------------------------- -}
diff --git a/OpenSSL/EVP/Base64.hsc b/OpenSSL/EVP/Base64.hsc
index 4b4b808..6c09ae6 100644
--- a/OpenSSL/EVP/Base64.hsc
+++ b/OpenSSL/EVP/Base64.hsc
@@ -16,7 +16,6 @@ module OpenSSL.EVP.Base64
where
import Control.Exception
-import qualified Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
@@ -27,13 +26,13 @@ import OpenSSL.Utils
-- エンコード時: 最低 3 バイト以上になるまで次のブロックを取り出し續け
--- る。返された[ByteString] は B.concat してから、その文字列長より小さ
+-- る。返された[ByteString] は B8.concat してから、その文字列長より小さ
-- な最大の 3 の倍數の位置で分割し、殘りは次のブロックの一部と見做す。
--
-- デコード時: 分割のアルゴリズムは同じだが最低バイト数が 4。
nextBlock :: Int -> ([ByteString], LazyByteString) -> ([ByteString], LazyByteString)
nextBlock _ (xs, LPS [] ) = (xs, LPS [])
-nextBlock minLen (xs, LPS src) = if foldl' (+) 0 (map B.length xs) >= minLen then
+nextBlock minLen (xs, LPS src) = if foldl' (+) 0 (map B8.length xs) >= minLen then
(xs, LPS src)
else
case src of
@@ -54,7 +53,7 @@ encodeBlock inBS
_EncodeBlock (unsafeCoercePtr outBuf) inBuf inLen
where
maxOutLen = (inputLen `div` 3 + 1) * 4 + 1 -- +1: '\0'
- inputLen = B.length inBS
+ inputLen = B8.length inBS
-- |@'encodeBase64' str@ lazilly encodes a stream of data to
@@ -75,14 +74,14 @@ encodeBase64LBS inLBS
| L8.null inLBS = L8.empty
| otherwise
= let (blockParts', remain' ) = nextBlock 3 ([], inLBS)
- block' = B.concat blockParts'
- blockLen' = B.length block'
+ block' = B8.concat blockParts'
+ blockLen' = B8.length block'
(block , leftover) = if blockLen' < 3 then
-- 最後の半端
- (block', B.empty)
+ (block', B8.empty)
else
- B.splitAt (blockLen' - blockLen' `mod` 3) block'
- remain = if B.null leftover then
+ B8.splitAt (blockLen' - blockLen' `mod` 3) block'
+ remain = if B8.null leftover then
remain'
else
case remain' of
@@ -101,10 +100,10 @@ foreign import ccall unsafe "EVP_DecodeBlock"
decodeBlock :: ByteString -> ByteString
decodeBlock inBS
- = assert (B.length inBS `mod` 4 == 0) $
+ = assert (B8.length inBS `mod` 4 == 0) $
unsafePerformIO $
unsafeUseAsCStringLen inBS $ \ (inBuf, inLen) ->
- createAndTrim (B.length inBS) $ \ outBuf ->
+ createAndTrim (B8.length inBS) $ \ outBuf ->
_DecodeBlock (unsafeCoercePtr outBuf) inBuf inLen
-- |@'decodeBase64' str@ lazilly decodes a stream of data from
@@ -124,11 +123,11 @@ decodeBase64LBS inLBS
| L8.null inLBS = L8.empty
| otherwise
= let (blockParts', remain' ) = nextBlock 4 ([], inLBS)
- block' = B.concat blockParts'
- blockLen' = B.length block'
+ block' = B8.concat blockParts'
+ blockLen' = B8.length block'
(block , leftover) = assert (blockLen' >= 4) $
- B.splitAt (blockLen' - blockLen' `mod` 4) block'
- remain = if B.null leftover then
+ B8.splitAt (blockLen' - blockLen' `mod` 4) block'
+ remain = if B8.null leftover then
remain'
else
case remain' of
diff --git a/OpenSSL/EVP/Cipher.hsc b/OpenSSL/EVP/Cipher.hsc
index a7e2b78..06f502c 100644
--- a/OpenSSL/EVP/Cipher.hsc
+++ b/OpenSSL/EVP/Cipher.hsc
@@ -33,7 +33,6 @@ module OpenSSL.EVP.Cipher
where
import Control.Monad
-import qualified Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
@@ -207,7 +206,7 @@ cipherStrictly :: CipherCtx -> ByteString -> IO ByteString
cipherStrictly ctx input
= do output' <- cipherUpdateBS ctx input
output'' <- cipherFinalBS ctx
- return $ B.append output' output''
+ return $ B8.append output' output''
cipherLazily :: CipherCtx -> LazyByteString -> IO LazyByteString
diff --git a/OpenSSL/EVP/Open.hsc b/OpenSSL/EVP/Open.hsc
index ccb3991..e131462 100644
--- a/OpenSSL/EVP/Open.hsc
+++ b/OpenSSL/EVP/Open.hsc
@@ -11,7 +11,6 @@ module OpenSSL.EVP.Open
where
import Control.Monad
-import qualified Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
diff --git a/OpenSSL/EVP/PKey.hsc b/OpenSSL/EVP/PKey.hsc
index 380f036..c01f1a4 100644
--- a/OpenSSL/EVP/PKey.hsc
+++ b/OpenSSL/EVP/PKey.hsc
@@ -25,7 +25,6 @@ module OpenSSL.EVP.PKey
where
import Foreign
-import Foreign.C
import OpenSSL.EVP.Digest
import OpenSSL.RSA
import OpenSSL.Utils
diff --git a/OpenSSL/EVP/Seal.hsc b/OpenSSL/EVP/Seal.hsc
index 4ac40ea..5b3a1ac 100644
--- a/OpenSSL/EVP/Seal.hsc
+++ b/OpenSSL/EVP/Seal.hsc
@@ -11,7 +11,6 @@ module OpenSSL.EVP.Seal
where
import Control.Monad
-import qualified Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
diff --git a/OpenSSL/EVP/Verify.hsc b/OpenSSL/EVP/Verify.hsc
index ec64314..6e467fd 100644
--- a/OpenSSL/EVP/Verify.hsc
+++ b/OpenSSL/EVP/Verify.hsc
@@ -12,7 +12,6 @@ module OpenSSL.EVP.Verify
where
import Control.Monad
-import Data.ByteString as B
import Data.ByteString.Base
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy.Char8 as L8
diff --git a/OpenSSL/PKCS7.hsc b/OpenSSL/PKCS7.hsc
index f8e8145..1da05ce 100644
--- a/OpenSSL/PKCS7.hsc
+++ b/OpenSSL/PKCS7.hsc
@@ -27,11 +27,6 @@ module OpenSSL.PKCS7
)
where
-import Data.Bits
-import qualified Data.ByteString as B
-import Data.ByteString.Base
-import qualified Data.ByteString.Char8 as B8
-import qualified Data.ByteString.Lazy.Char8 as L8
import Data.List
import Data.Traversable
import Data.Typeable
diff --git a/OpenSSL/RSA.hsc b/OpenSSL/RSA.hsc
index e916c85..155ddaf 100644
--- a/OpenSSL/RSA.hsc
+++ b/OpenSSL/RSA.hsc
@@ -30,7 +30,6 @@ module OpenSSL.RSA
import Control.Monad
import Foreign
-import Foreign.C
import OpenSSL.BN
import OpenSSL.Utils
diff --git a/OpenSSL/Stack.hsc b/OpenSSL/Stack.hsc
index c956a85..2d10de4 100644
--- a/OpenSSL/Stack.hsc
+++ b/OpenSSL/Stack.hsc
@@ -12,11 +12,10 @@ module OpenSSL.Stack
import Control.Exception
import Foreign
-import Foreign.C
import OpenSSL.Utils
-data STACK = STACK
+data STACK
foreign import ccall unsafe "sk_new_null"
diff --git a/OpenSSL/Utils.hs b/OpenSSL/Utils.hs
index db29909..cdeab82 100644
--- a/OpenSSL/Utils.hs
+++ b/OpenSSL/Utils.hs
@@ -12,7 +12,6 @@ module OpenSSL.Utils
where
import Foreign
-import Foreign.C
import GHC.Base
import OpenSSL.ERR
diff --git a/OpenSSL/X509/Store.hsc b/OpenSSL/X509/Store.hsc
index 49d0ba0..34199c0 100644
--- a/OpenSSL/X509/Store.hsc
+++ b/OpenSSL/X509/Store.hsc
@@ -17,7 +17,6 @@ module OpenSSL.X509.Store
where
import Foreign
-import Foreign.C
import OpenSSL.X509
import OpenSSL.X509.Revocation
import OpenSSL.Utils