aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Digest/Internal.hsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Digest/Internal.hsc')
-rw-r--r--src/Data/Digest/Internal.hsc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Data/Digest/Internal.hsc b/src/Data/Digest/Internal.hsc
index 73edbd9..a7f19d7 100644
--- a/src/Data/Digest/Internal.hsc
+++ b/src/Data/Digest/Internal.hsc
@@ -31,9 +31,6 @@ data Engine
-- | The BoringSSL @EVP_MD@ type, representing a hash algorithm.
data EvpMd
--- | A convenience alias for @Ptr EvpMd@.
-type Algo = Ptr EvpMd
-
-- | The BoringSSL @EVP_MD_CTX@ type, representing the state of a pending
-- hashing operation.
data EvpMdCtx
@@ -103,6 +100,9 @@ foreign import ccall "&btlsFinalizeEvpMdCtx"
-- Finally, we're ready to actually implement the hashing interface.
+-- | A cryptographic hash function.
+newtype Algorithm = Algorithm (Ptr EvpMd)
+
-- | The result of a hash operation.
newtype Digest =
Digest ByteString
@@ -115,9 +115,9 @@ instance Show Digest where
hexit (b `shiftR` 4 .&. 0x0f) : hexit (b .&. 0x0f) : xs
hexit = intToDigit . fromIntegral :: Word8 -> Char
--- | Hashes according to the given 'Algo'.
-hash :: Algo -> LazyByteString -> Digest
-hash md bytes =
+-- | Hashes according to the given 'Algorithm'.
+hash :: Algorithm -> LazyByteString -> Digest
+hash (Algorithm md) bytes =
unsafeLocalState $ do
ctxFP <- mallocEvpMdCtx
withForeignPtr ctxFP $ \ctx -> do