HsOpenSSL 0.10.3.1 → 0.10.3.2
raw patch · 6 files changed
+60/−51 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- HsOpenSSL.cabal +18/−8
- NEWS +7/−1
- OpenSSL.hsc +5/−3
- OpenSSL/BN.hsc +23/−38
- OpenSSL/PEM.hsc +2/−0
- OpenSSL/Session.hsc +5/−1
HsOpenSSL.cabal view
@@ -11,11 +11,13 @@ were no pure-Haskell implementations of TLS. Now there is tls package (<http://hackage.haskell.org/package/tls>), which looks pretty saner than HsOpenSSL especially for initialisation and- error handlings. So PHO (the initial author of HsOpenSSL) highly- encourages you to use and improve the tls package instead as long- as possible.+ error handlings. So PHO (the initial author of HsOpenSSL) wants to+ encourage you to use and improve the tls package instead as long+ as possible. The only problem is that the tls package has not+ received as much review as OpenSSL from cryptography specialists+ yet, thus we can't assume it's secure enough. .-Version: 0.10.3.1+Version: 0.10.3.2 License: PublicDomain License-File: COPYING Author: Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen@@ -46,6 +48,12 @@ Type: git Location: git://github.com/phonohawk/HsOpenSSL.git +Flag fast-bignum+ Description:+ Enable fast moving of bignums between OpenSSL and GMP (GHC Only).+ Default:+ True+ Library Build-Depends: base >= 4 && < 5,@@ -55,10 +63,12 @@ old-locale, time >= 1.1.1 - if impl(ghc >= 6.11)- Build-Depends: integer-gmp- else- Build-Depends: integer+ if flag(fast-bignum)+ CPP-Options: -DFAST_BIGNUM+ if impl(ghc >= 6.11)+ Build-Depends: integer-gmp+ else+ Build-Depends: integer if os(mingw32) Extra-Libraries: eay32 ssl32
NEWS view
@@ -1,9 +1,15 @@ -*- coding: utf-8 -*- +Changes from 0.10.3.1 to 0.10.3.2+---------------------------------+* Merged #15 "Fixed build with base-4.6" by Mikhail Vorozhtsov.+* Added a configuration flag 'fast-bignum', fixes #16.++ Changes from 0.10.3 to 0.10.3.1 ------------------------------- * Merged #14 "Fixed X509_STORE_CTX bindings vs OpenSSL 0.9.x" by- Mikhail Vorozhtsov+ Mikhail Vorozhtsov. Changes from 0.10.2.1 to 0.10.3
OpenSSL.hsc view
@@ -8,9 +8,11 @@ -- were no pure-Haskell implementations of TLS. Now there is tls -- package (<http://hackage.haskell.org/package/tls>), which looks -- pretty saner than HsOpenSSL especially for initialisation and error--- handlings. So PHO (the initial author of HsOpenSSL) highly--- encourages you to use and improve the tls package instead as long--- as possible.+-- handlings. So PHO (the initial author of HsOpenSSL) wants to+-- encourage you to use and improve the tls package instead as long as+-- possible. The only problem is that the tls package has not received+-- as much review as OpenSSL from cryptography specialists yet, thus+-- we can't assume it's secure enough. -- -- Features that aren't (yet) supported: --
OpenSSL/BN.hsc view
@@ -22,10 +22,8 @@ -- * Conversion from\/to Integer , peekBN-#ifdef __GLASGOW_HASKELL__ , integerToBN , bnToInteger-#endif , integerToMPI , mpiToInteger @@ -50,7 +48,7 @@ import OpenSSL.Utils import System.IO.Unsafe -#ifdef __GLASGOW_HASKELL__+#ifdef FAST_BIGNUM import Foreign.C.Types import GHC.Base # if MIN_VERSION_integer_gmp(0,2,0)@@ -92,7 +90,7 @@ wrapBN = BigNum -#ifndef __GLASGOW_HASKELL__+#ifndef FAST_BIGNUM {- slow, safe functions ----------------------------------------------------- -} @@ -105,36 +103,23 @@ foreign import ccall unsafe "HsOpenSSL_OPENSSL_free" _openssl_free :: Ptr a -> IO () --- |@'withBN' n f@ converts n to a 'BigNum' and computes @f@. Then it--- frees the 'BigNum'.-withBN :: Integer -> (BigNum -> IO a) -> IO a-withBN dec m- = withCString (show dec) $ \ strPtr ->- alloca $ \ bnPtr ->- do poke bnPtr nullPtr- _dec2bn bnPtr strPtr- >>= failIf (== 0)- bracket (peek bnPtr) _free m---- |@'peekBN' bn@ converts a 'BigNum' to an 'Prelude.Integer'.-peekBN :: BigNum -> IO Integer-peekBN bn- = do strPtr <- _bn2dec bn- when (strPtr == nullPtr) $ fail "BN_bn2dec failed"- str <- peekCString strPtr- _openssl_free strPtr-- return $ read str-+-- |Convert a BIGNUM to an 'Integer'.+bnToInteger :: BigNum -> IO Integer+bnToInteger bn+ = bracket (do strPtr <- _bn2dec (unwrapBN bn)+ when (strPtr == nullPtr) $ fail "BN_bn2dec failed"+ return strPtr)+ _openssl_free+ ((read `fmap`) . peekCString) --- | Return a new, alloced bignum-newBN :: Integer -> IO BigNum-newBN i = do+-- |Return a new, alloced BIGNUM.+integerToBN :: Integer -> IO BigNum+integerToBN i = do withCString (show i) (\str -> do alloca (\bnptr -> do poke bnptr nullPtr- _dec2bn bnptr str >>= failIf (== 0)- peek bnptr))+ _ <- _dec2bn bnptr str >>= failIf (== 0)+ wrapBN `fmap` peek bnptr)) #else @@ -240,6 +225,8 @@ (#poke BIGNUM, neg) (unwrapBN bnptr) (1 :: CInt) return bnptr +#endif+ -- TODO: we could make a function which doesn't even allocate BN data if we -- wanted to be very fast and dangerout. The BIGNUM could point right into the -- Integer's data. However, I'm not sure about the semantics of the GC; which@@ -250,6 +237,12 @@ withBN :: Integer -> (BigNum -> IO a) -> IO a withBN dec m = bracket (integerToBN dec) (_free . unwrapBN) m +foreign import ccall unsafe "BN_bn2mpi"+ _bn2mpi :: Ptr BIGNUM -> Ptr CChar -> IO CInt++foreign import ccall unsafe "BN_mpi2bn"+ _mpi2bn :: Ptr CChar -> CInt -> Ptr BIGNUM -> IO (Ptr BIGNUM)+ -- |This is an alias to 'bnToInteger'. peekBN :: BigNum -> IO Integer peekBN = bnToInteger@@ -257,14 +250,6 @@ -- |This is an alias to 'integerToBN'. newBN :: Integer -> IO BigNum newBN = integerToBN--foreign import ccall unsafe "BN_bn2mpi"- _bn2mpi :: Ptr BIGNUM -> Ptr CChar -> IO CInt--foreign import ccall unsafe "BN_mpi2bn"- _mpi2bn :: Ptr CChar -> CInt -> Ptr BIGNUM -> IO (Ptr BIGNUM)--#endif -- | Convert a BigNum to an MPI: a serialisation of large ints which has a -- 4-byte, big endian length followed by the bytes of the number in
OpenSSL/PEM.hsc view
@@ -55,7 +55,9 @@ import OpenSSL.X509 import OpenSSL.X509.Request import OpenSSL.X509.Revocation+#if !MIN_VERSION_base(4,6,0) import Prelude hiding (catch)+#endif import System.IO
OpenSSL/Session.hsc view
@@ -58,7 +58,11 @@ #include "openssl/ssl.h" -import Prelude hiding (catch, read, ioError, mapM, mapM_)+import Prelude hiding (+#if !MIN_VERSION_base(4,6,0)+ catch,+#endif+ read, ioError, mapM, mapM_) import Control.Concurrent (threadWaitWrite, threadWaitRead, runInBoundThread) import Control.Concurrent.QSem import Control.Exception