aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Digest/Sha1.hs
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-01-27 17:05:58 -0500
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-01-27 17:05:58 -0500
commit45a29b37173ab724d8b90af7e0b1a9fda3acbeb2 (patch)
tree40090e0bee29510d19d3473075e6c1cd4f1d02fa /src/Data/Digest/Sha1.hs
parent22b58e03dbf030d7fa0c34f5677bda341405fe07 (diff)
Data.Digest: Switch back to EVP
Use the finalizer techniques demonstrated in 4e56c79b907da4a4654e5278bdcf94b08480a426 to safely allocate `EVP_MD_CTX` on the Haskell heap. This allows us to return to the high-level EVP API, eliminating much boilerplate code.
Diffstat (limited to 'src/Data/Digest/Sha1.hs')
-rw-r--r--src/Data/Digest/Sha1.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Data/Digest/Sha1.hs b/src/Data/Digest/Sha1.hs
new file mode 100644
index 0000000..16101b0
--- /dev/null
+++ b/src/Data/Digest/Sha1.hs
@@ -0,0 +1,12 @@
+module Data.Digest.Sha1
+ ( sha1
+ ) where
+
+import Data.ByteString.Lazy (ByteString)
+
+import Data.Digest.Internal
+
+foreign import ccall "openssl/digest.h EVP_sha1" evpSha1 :: Algo
+
+sha1 :: ByteString -> Digest
+sha1 = hash evpSha1