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

Commit

Permalink
Added COPYING / Supplessed unneeded imports
Browse files Browse the repository at this point in the history
darcs-hash:20070717082814-62b54-bc40000b230281780fad78f5ae8fc0a1e5dc6242.gz
  • Loading branch information
depressed-pho committed Jul 17, 2007
1 parent d145e51 commit 0e4cdc6
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 43 deletions.
29 changes: 29 additions & 0 deletions COPYING
@@ -0,0 +1,29 @@
<!-- -*- xml -*-
HsOpenSSL はパブリックドメインに在ります。
HsOpenSSL is in the public domain.
See http://creativecommons.org/licenses/publicdomain/
-->

<rdf:RDF xmlns="http://web.resource.org/cc/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<Work rdf:about="http://ccm.sherry.jp/HsOpenSSL/">
<dc:title>HsOpenSSL</dc:title>
<dc:rights>
<Agent>
<dc:title>phonohawk</dc:title>
</Agent>
</dc:rights>
<license rdf:resource="http://web.resource.org/cc/PublicDomain" />
</Work>

<License rdf:about="http://web.resource.org/cc/PublicDomain">
<permits rdf:resource="http://web.resource.org/cc/Reproduction" />
<permits rdf:resource="http://web.resource.org/cc/Distribution" />
<permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
</License>

</rdf:RDF>
12 changes: 7 additions & 5 deletions HsOpenSSL.cabal
Expand Up @@ -7,10 +7,11 @@ Description:
messages.
Version: 0.1
License: PublicDomain
Author: PHO <phonohawk AT ps DOT sakura DOT ne DOT jp>
Maintainer: PHO <phonohawk AT ps DOT sakura DOT ne DOT jp>
License-File: COPYING
Author: PHO <phonohawk at ps dot sakura dot ne dot jp>
Maintainer: PHO <phonohawk at ps dot sakura dot ne dot jp>
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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
examples/PKCS7.hs
13 changes: 6 additions & 7 deletions OpenSSL/BIO.hsc
Expand Up @@ -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
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 --------------------------------------------------------------------- -}

Expand Down
29 changes: 14 additions & 15 deletions OpenSSL/EVP/Base64.hsc
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions OpenSSL/EVP/Cipher.hsc
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/EVP/Open.hsc
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/EVP/PKey.hsc
Expand Up @@ -25,7 +25,6 @@ module OpenSSL.EVP.PKey
where

import Foreign
import Foreign.C
import OpenSSL.EVP.Digest
import OpenSSL.RSA
import OpenSSL.Utils
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/EVP/Seal.hsc
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/EVP/Verify.hsc
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions OpenSSL/PKCS7.hsc
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/RSA.hsc
Expand Up @@ -30,7 +30,6 @@ module OpenSSL.RSA

import Control.Monad
import Foreign
import Foreign.C
import OpenSSL.BN
import OpenSSL.Utils

Expand Down
3 changes: 1 addition & 2 deletions OpenSSL/Stack.hsc
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion OpenSSL/Utils.hs
Expand Up @@ -12,7 +12,6 @@ module OpenSSL.Utils
where

import Foreign
import Foreign.C
import GHC.Base
import OpenSSL.ERR

Expand Down
1 change: 0 additions & 1 deletion OpenSSL/X509/Store.hsc
Expand Up @@ -17,7 +17,6 @@ module OpenSSL.X509.Store
where

import Foreign
import Foreign.C
import OpenSSL.X509
import OpenSSL.X509.Revocation
import OpenSSL.Utils
Expand Down

0 comments on commit 0e4cdc6

Please sign in to comment.