aboutsummaryrefslogtreecommitdiff
path: root/src/Codec/Crypto/HKDF.hs
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-08-02 17:19:33 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-08-02 17:19:33 -0400
commit44a6b5738f73b5281c3630c507aeece75e6ee952 (patch)
treec55ae9fe7260b7f16244b5dd220bc7f806a9fc79 /src/Codec/Crypto/HKDF.hs
parent2152e7728db7e0cf86ea23d29a05294af24b6898 (diff)
Factor out common char* ↔ unsigned char* cast
Diffstat (limited to 'src/Codec/Crypto/HKDF.hs')
-rw-r--r--src/Codec/Crypto/HKDF.hs8
1 files changed, 2 insertions, 6 deletions
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