From 44a6b5738f73b5281c3630c507aeece75e6ee952 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Thu, 2 Aug 2018 17:19:33 -0400 Subject: Factor out common char* ↔ unsigned char* cast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Codec/Crypto/HKDF.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/Codec/Crypto/HKDF.hs') diff --git a/src/Codec/Crypto/HKDF.hs b/src/Codec/Crypto/HKDF.hs index 8c1db0a..4547a52 100644 --- a/src/Codec/Crypto/HKDF.hs +++ b/src/Codec/Crypto/HKDF.hs @@ -19,13 +19,12 @@ module Codec.Crypto.HKDF import qualified Data.ByteString as ByteString import qualified Data.ByteString.Unsafe as ByteString -import Foreign (Ptr, Storable(peek), alloca, allocaArray) -import Foreign.C.Types +import Foreign (Storable(peek), alloca, allocaArray) import Foreign.Marshal.Unsafe (unsafeLocalState) -import Unsafe.Coerce (unsafeCoerce) import BTLS.BoringSSL.Digest (evpMaxMDSize) import BTLS.BoringSSL.HKDF +import BTLS.Cast (asCUCharBuf) import BTLS.Types (AssociatedData(AssociatedData), Salt(Salt), SecretKey(SecretKey), noSalt) import Data.Digest.Internal (Algorithm(Algorithm)) @@ -63,6 +62,3 @@ expand (Algorithm md) (AssociatedData info) outLen (SecretKey secret) = (asCUCharBuf pSecret) (fromIntegral secretLen) (asCUCharBuf pInfo) (fromIntegral infoLen) SecretKey <$> ByteString.packCStringLen (pOutKey, outLen) - -asCUCharBuf :: Ptr CChar -> Ptr CUChar -asCUCharBuf = unsafeCoerce -- cgit v1.2.3