diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-04-28 14:28:03 -0700 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-04-28 14:28:03 -0700 |
commit | 46f0b4f51ffa6982e66bdbf3a29426fb15c999d2 (patch) | |
tree | 87914726af8bcb38a0071b3216459514b8e2fc17 /src/Data/Digest/Internal.chs | |
parent | 5418461764453d2a6fa0e66b56123ef541631689 (diff) |
Begin refactoring low-level foreign imports into their own hierarchy
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.
Diffstat (limited to 'src/Data/Digest/Internal.chs')
-rw-r--r-- | src/Data/Digest/Internal.chs | 29 |
1 files changed, 4 insertions, 25 deletions
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. |