diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-01-27 17:05:58 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-01-27 17:05:58 -0500 |
commit | 45a29b37173ab724d8b90af7e0b1a9fda3acbeb2 (patch) | |
tree | 40090e0bee29510d19d3473075e6c1cd4f1d02fa /src/Data/Digest/Md5.hsc | |
parent | 22b58e03dbf030d7fa0c34f5677bda341405fe07 (diff) |
Data.Digest: Switch back to EVP
Use the finalizer techniques demonstrated in
4e56c79b907da4a4654e5278bdcf94b08480a426 to safely allocate `EVP_MD_CTX`
on the Haskell heap. This allows us to return to the high-level EVP API,
eliminating much boilerplate code.
Diffstat (limited to 'src/Data/Digest/Md5.hsc')
-rw-r--r-- | src/Data/Digest/Md5.hsc | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/Data/Digest/Md5.hsc b/src/Data/Digest/Md5.hsc deleted file mode 100644 index 2a1303d..0000000 --- a/src/Data/Digest/Md5.hsc +++ /dev/null @@ -1,38 +0,0 @@ -{-# LANGUAGE CApiFFI #-} -{-# OPTIONS_GHC -Wno-missing-methods #-} - -module Data.Digest.Md5 - ( md5 - ) where - -import Data.ByteString.Lazy (ByteString) -import Foreign (Ptr, Storable(alignment, sizeOf)) -import Foreign.C.Types - -import Data.Digest.Internal - -#include <openssl/md5.h> - -data Md5Ctx - -instance Storable Md5Ctx where - sizeOf _ = #size MD5_CTX - alignment _ = #alignment MD5_CTX - -foreign import capi "openssl/md5.h value MD5_DIGEST_LENGTH" - md5DigestLength :: CSize - -foreign import ccall "openssl/md5.h MD5_Init" - md5Init :: Ptr Md5Ctx -> IO CInt - -foreign import ccall "openssl/md5.h MD5_Update" - md5Update :: Ptr Md5Ctx -> Ptr a -> CSize -> IO CInt - -foreign import ccall "openssl/md5.h MD5_Final" - md5Final :: Ptr CUChar -> Ptr Md5Ctx -> IO CInt - -md5Algo :: Algo -md5Algo = Algo md5DigestLength md5Init md5Update md5Final - -md5 :: ByteString -> Digest -md5 = hash md5Algo |