From 46f0b4f51ffa6982e66bdbf3a29426fb15c999d2 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 28 Apr 2018 14:28:03 -0700 Subject: Begin refactoring low-level foreign imports into their own hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s clear at this point that this system is going to get large enough that a two-layer implementation is warranted. `Internal` will contain low-level bindings to BoringSSL; other modules will export an idiomatic interface on top of them. --- src/Data/Digest/Internal.chs | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'src/Data/Digest/Internal.chs') diff --git a/src/Data/Digest/Internal.chs b/src/Data/Digest/Internal.chs index 86cea65..6478810 100644 --- a/src/Data/Digest/Internal.chs +++ b/src/Data/Digest/Internal.chs @@ -12,8 +12,6 @@ -- License for the specific language governing permissions and limitations under -- the License. -{-# OPTIONS_GHC -Wno-missing-methods #-} - module Data.Digest.Internal where import Data.Bits (Bits((.&.)), shiftR) @@ -24,13 +22,14 @@ import qualified Data.ByteString.Unsafe as ByteString import Data.Char (intToDigit) import Data.Word (Word8) import Foreign - (FinalizerPtr, ForeignPtr, Ptr, Storable(alignment, peek, sizeOf), - addForeignPtrFinalizer, alloca, allocaArray, mallocForeignPtr, - nullPtr, withForeignPtr) + (FinalizerPtr, ForeignPtr, Ptr, Storable(peek), addForeignPtrFinalizer, + alloca, allocaArray, mallocForeignPtr, withForeignPtr) import Foreign.C.Types import Foreign.Marshal.Unsafe (unsafeLocalState) import Unsafe.Coerce (unsafeCoerce) +{#import Internal.Base#} +{#import Internal.Digest#} () import Foreign.Ptr.Cast (asVoidPtr) import Result @@ -40,26 +39,6 @@ type LazyByteString = ByteString.Lazy.ByteString -- First, we build basic bindings to the BoringSSL EVP interface. --- | The BoringSSL @ENGINE@ type. -data Engine -{#pointer *ENGINE as 'Ptr Engine' -> Engine nocode#} - -noEngine :: Ptr Engine -noEngine = nullPtr - --- | The BoringSSL @EVP_MD@ type, representing a hash algorithm. -data EvpMd -{#pointer *EVP_MD as 'Ptr EvpMd' -> EvpMd nocode#} - --- | The BoringSSL @EVP_MD_CTX@ type, representing the state of a pending --- hashing operation. -data EvpMdCtx -{#pointer *EVP_MD_CTX as 'Ptr EvpMdCtx' -> EvpMdCtx nocode#} - -instance Storable EvpMdCtx where - sizeOf _ = {#sizeof EVP_MD_CTX#} - alignment _ = {#alignof EVP_MD_CTX#} - -- Imported functions from BoringSSL. See -- https://commondatastorage.googleapis.com/chromium-boringssl-docs/digest.h.html -- for documentation. -- cgit v1.2.3