Skip to content
Snippets Groups Projects
Commit 818787fa authored by Ryan Scott's avatar Ryan Scott
Browse files

Patch siphash-1.0.3

parent 21c0ca4a
No related branches found
No related tags found
No related merge requests found
diff --git a/Crypto/MAC/SipHash.hs b/Crypto/MAC/SipHash.hs
index ac1da7a..d86e3f5 100644
--- a/Crypto/MAC/SipHash.hs
+++ b/Crypto/MAC/SipHash.hs
@@ -27,6 +27,7 @@ import Foreign.ForeignPtr
import Foreign.Ptr
import Foreign.Storable
import System.Endian (fromLE64)
+import System.IO.Unsafe (unsafeDupablePerformIO)
-- | SigHash Key
data SipKey = SipKey {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
@@ -43,7 +44,7 @@ hash = hashWith 2 4
-- | same as 'hash', except also specifies the number of sipround iterations for compression and digest.
hashWith :: Int -> Int -> SipKey -> ByteString -> SipHash
-hashWith c d key (PS ps s fl) = inlinePerformIO $ withForeignPtr ps (\ptr -> runHash (initSip key) (ptr `plusPtr` s) fl)
+hashWith c d key (PS ps s fl) = unsafeDupablePerformIO $ withForeignPtr ps (\ptr -> runHash (initSip key) (ptr `plusPtr` s) fl)
where runHash !st !ptr l
| l > 7 = fromLE64 `fmap` peek (castPtr ptr) >>= \v -> runHash (process st v) (ptr `plusPtr` 8) (l-8)
| otherwise = do
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment