diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-09-04 18:53:20 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-09-04 18:53:20 -0400 |
commit | 015079075e1e156d5934f4e716a51eb284289b5d (patch) | |
tree | 17dd43c33e0af2696dc1a61c2a9abe6c0667e1d4 /src/BTLS/BoringSSL/HMAC.chs | |
parent | 2e7bd84469eba730f24dd3e448cca22f5aed16f4 (diff) |
Marshal `ForeignPtr` to `Ptr` within c2hs code
Diffstat (limited to 'src/BTLS/BoringSSL/HMAC.chs')
-rw-r--r-- | src/BTLS/BoringSSL/HMAC.chs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/BTLS/BoringSSL/HMAC.chs b/src/BTLS/BoringSSL/HMAC.chs index ea9fd03..72cdd3c 100644 --- a/src/BTLS/BoringSSL/HMAC.chs +++ b/src/BTLS/BoringSSL/HMAC.chs @@ -20,7 +20,8 @@ module BTLS.BoringSSL.HMAC ) where import Data.ByteString (ByteString) -import Foreign (FinalizerPtr, ForeignPtr, Ptr, Storable(alignment, sizeOf)) +import Foreign + (FinalizerPtr, ForeignPtr, Ptr, Storable(alignment, sizeOf), withForeignPtr) import Foreign.C.Types {#import BTLS.BoringSSL.Base#} @@ -38,14 +39,22 @@ foreign import ccall "&HMAC_CTX_cleanup" hmacCtxCleanup :: FinalizerPtr HMACCtx {#fun HMAC_Init_ex as hmacInitEx - {`Ptr HMACCtx', unsafeUseAsCBuffer* `ByteString'&, `Ptr EVPMD', `Ptr Engine'} + { withForeignPtr* `ForeignPtr HMACCtx' + , unsafeUseAsCBuffer* `ByteString'& + , `Ptr EVPMD' + , `Ptr Engine' } -> `Int'#} {#fun HMAC_Update as hmacUpdate - {`Ptr HMACCtx', unsafeUseAsCBuffer* `ByteString'&} -> `()' alwaysSucceeds*-#} + { withForeignPtr* `ForeignPtr HMACCtx' + , unsafeUseAsCBuffer* `ByteString'& } + -> `()' alwaysSucceeds*-#} {#fun HMAC_Final as hmacFinal - {`Ptr HMACCtx', id `Ptr CUChar', id `Ptr CUInt'} -> `()' requireSuccess*-#} + { withForeignPtr* `ForeignPtr HMACCtx' + , id `Ptr CUChar' + , id `Ptr CUInt' } + -> `()' requireSuccess*-#} instance Storable HMACCtx where sizeOf _ = {#sizeof HMAC_CTX#} |