From 80f2fb2e3be2c4074fbfb0adbc47746d2d88813b Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Fri, 31 Aug 2018 16:50:41 -0400 Subject: Begin switching to `fun` in c2hs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace most invocations of `call` with `fun`. There’s a lot of explicit `id`-marshalling going on; future commits will remove it. --- src/BTLS/BoringSSL/HMAC.chs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/BTLS/BoringSSL/HMAC.chs') diff --git a/src/BTLS/BoringSSL/HMAC.chs b/src/BTLS/BoringSSL/HMAC.chs index 5c53122..1e5e82c 100644 --- a/src/BTLS/BoringSSL/HMAC.chs +++ b/src/BTLS/BoringSSL/HMAC.chs @@ -36,18 +36,15 @@ mallocHMACCtx = createWithFinalizer {#call HMAC_CTX_init as ^#} hmacCtxCleanup foreign import ccall "&HMAC_CTX_cleanup" hmacCtxCleanup :: FinalizerPtr HMACCtx -hmacInitEx :: Ptr HMACCtx -> Ptr a -> CULong -> Ptr EVPMD -> Ptr Engine -> IO () -hmacInitEx ctx bytes size md engine = - requireSuccess $ - {#call HMAC_Init_ex as ^#} ctx (asVoidPtr bytes) size md engine - -hmacUpdate :: Ptr HMACCtx -> Ptr CUChar -> CULong -> IO () -hmacUpdate ctx bytes size = - alwaysSucceeds $ {#call HMAC_Update as ^#} ctx bytes size - -hmacFinal :: Ptr HMACCtx -> Ptr CUChar -> Ptr CUInt -> IO () -hmacFinal ctx out outSize = - requireSuccess $ {#call HMAC_Final as ^#} ctx out outSize +{#fun HMAC_Init_ex as hmacInitEx + {`Ptr HMACCtx', asVoidPtr `Ptr a', id `CULong', `Ptr EVPMD', `Ptr Engine'} + -> `()' requireSuccess*-#} + +{#fun HMAC_Update as hmacUpdate + {`Ptr HMACCtx', id `Ptr CUChar', id `CULong'} -> `()' alwaysSucceeds*-#} + +{#fun HMAC_Final as hmacFinal + {`Ptr HMACCtx', id `Ptr CUChar', id `Ptr CUInt'} -> `()' requireSuccess*-#} instance Storable HMACCtx where sizeOf _ = {#sizeof HMAC_CTX#} -- cgit v1.2.3