add internalUpdateUnsafe to process data more efficiently at the expense of threads.
internalUpdateUnsafe, just like internalUpdate update the context, but does it using the unsafe key word for the ffi binding
This commit is contained in:
parent
90d02607ba
commit
b5dbc9caae
@ -17,6 +17,7 @@ module Crypto.Hash.Internal.Kekkak
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -83,6 +84,9 @@ foreign import ccall unsafe "cryptonite_kekkak.h cryptonite_kekkak_init"
|
||||
foreign import ccall "cryptonite_kekkak.h cryptonite_kekkak_update"
|
||||
c_kekkak_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_kekkak.h cryptonite_kekkak_update"
|
||||
c_kekkak_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_kekkak.h cryptonite_kekkak_finalize"
|
||||
c_kekkak_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -98,6 +102,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_kekkak_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_kekkak_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr =
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.MD2
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_md2.h cryptonite_md2_init"
|
||||
foreign import ccall "cryptonite_md2.h cryptonite_md2_update"
|
||||
c_md2_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md2.h cryptonite_md2_update"
|
||||
c_md2_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md2.h cryptonite_md2_finalize"
|
||||
c_md2_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md2_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md2_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_md2_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.MD4
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_md4.h cryptonite_md4_init"
|
||||
foreign import ccall "cryptonite_md4.h cryptonite_md4_update"
|
||||
c_md4_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md4.h cryptonite_md4_update"
|
||||
c_md4_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md4.h cryptonite_md4_finalize"
|
||||
c_md4_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md4_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md4_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_md4_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.MD5
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_md5.h cryptonite_md5_init"
|
||||
foreign import ccall "cryptonite_md5.h cryptonite_md5_update"
|
||||
c_md5_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md5.h cryptonite_md5_update"
|
||||
c_md5_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_md5.h cryptonite_md5_finalize"
|
||||
c_md5_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md5_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_md5_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_md5_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.RIPEMD160
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_ripemd.h cryptonite_ripemd160_init"
|
||||
foreign import ccall "cryptonite_ripemd.h cryptonite_ripemd160_update"
|
||||
c_ripemd160_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_ripemd.h cryptonite_ripemd160_update"
|
||||
c_ripemd160_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_ripemd.h cryptonite_ripemd160_finalize"
|
||||
c_ripemd160_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_ripemd160_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_ripemd160_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_ripemd160_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.SHA1
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_sha1.h cryptonite_sha1_init"
|
||||
foreign import ccall "cryptonite_sha1.h cryptonite_sha1_update"
|
||||
c_sha1_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha1.h cryptonite_sha1_update"
|
||||
c_sha1_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha1.h cryptonite_sha1_finalize"
|
||||
c_sha1_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha1_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha1_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_sha1_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.SHA224
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha224_init"
|
||||
foreign import ccall "cryptonite_sha256.h cryptonite_sha224_update"
|
||||
c_sha224_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha224_update"
|
||||
c_sha224_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha224_finalize"
|
||||
c_sha224_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha224_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha224_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_sha224_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.SHA256
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha256_init"
|
||||
foreign import ccall "cryptonite_sha256.h cryptonite_sha256_update"
|
||||
c_sha256_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha256_update"
|
||||
c_sha256_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha256.h cryptonite_sha256_finalize"
|
||||
c_sha256_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha256_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha256_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_sha256_finalize ptr)
|
||||
|
||||
@ -17,6 +17,7 @@ module Crypto.Hash.Internal.SHA3
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -83,6 +84,9 @@ foreign import ccall unsafe "cryptonite_sha3.h cryptonite_sha3_init"
|
||||
foreign import ccall "cryptonite_sha3.h cryptonite_sha3_update"
|
||||
c_sha3_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha3.h cryptonite_sha3_update"
|
||||
c_sha3_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha3.h cryptonite_sha3_finalize"
|
||||
c_sha3_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -98,6 +102,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha3_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha3_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr =
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.SHA384
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha384_init"
|
||||
foreign import ccall "cryptonite_sha512.h cryptonite_sha384_update"
|
||||
c_sha384_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha384_update"
|
||||
c_sha384_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha384_finalize"
|
||||
c_sha384_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha384_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha384_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_sha384_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.SHA512
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxNew
|
||||
@ -82,6 +83,9 @@ foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha512_init"
|
||||
foreign import ccall "cryptonite_sha512.h cryptonite_sha512_update"
|
||||
c_sha512_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha512_update"
|
||||
c_sha512_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha512.h cryptonite_sha512_finalize"
|
||||
c_sha512_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -97,6 +101,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha512_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_sha512_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_sha512_finalize ptr)
|
||||
|
||||
@ -17,6 +17,7 @@ module Crypto.Hash.Internal.Skein256
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -83,6 +84,9 @@ foreign import ccall unsafe "cryptonite_skein256.h cryptonite_skein256_init"
|
||||
foreign import ccall "cryptonite_skein256.h cryptonite_skein256_update"
|
||||
c_skein256_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein256.h cryptonite_skein256_update"
|
||||
c_skein256_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein256.h cryptonite_skein256_finalize"
|
||||
c_skein256_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -98,6 +102,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_skein256_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_skein256_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr =
|
||||
|
||||
@ -17,6 +17,7 @@ module Crypto.Hash.Internal.Skein512
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -83,6 +84,9 @@ foreign import ccall unsafe "cryptonite_skein512.h cryptonite_skein512_init"
|
||||
foreign import ccall "cryptonite_skein512.h cryptonite_skein512_update"
|
||||
c_skein512_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein512.h cryptonite_skein512_update"
|
||||
c_skein512_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_skein512.h cryptonite_skein512_finalize"
|
||||
c_skein512_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -98,6 +102,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_skein512_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_skein512_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr =
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.Tiger
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_tiger.h cryptonite_tiger_init"
|
||||
foreign import ccall "cryptonite_tiger.h cryptonite_tiger_update"
|
||||
c_tiger_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_tiger.h cryptonite_tiger_update"
|
||||
c_tiger_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_tiger.h cryptonite_tiger_finalize"
|
||||
c_tiger_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_tiger_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_tiger_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_tiger_finalize ptr)
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.Whirlpool
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_whirlpool.h cryptonite_whirlpool_init"
|
||||
foreign import ccall "cryptonite_whirlpool.h cryptonite_whirlpool_update"
|
||||
c_whirlpool_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_whirlpool.h cryptonite_whirlpool_update"
|
||||
c_whirlpool_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_whirlpool.h cryptonite_whirlpool_finalize"
|
||||
c_whirlpool_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_whirlpool_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_whirlpool_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_whirlpool_finalize ptr)
|
||||
|
||||
@ -17,6 +17,7 @@ module Crypto.Hash.Internal.%%MODULENAME%%
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -83,6 +84,9 @@ foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_
|
||||
foreign import ccall "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_update"
|
||||
c_%%HASHNAME%%_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_update"
|
||||
c_%%HASHNAME%%_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_finalize"
|
||||
c_%%HASHNAME%%_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -98,6 +102,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_%%HASHNAME%%_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_%%HASHNAME%%_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr =
|
||||
|
||||
@ -18,6 +18,7 @@ module Crypto.Hash.Internal.%%MODULENAME%%
|
||||
, internalInit
|
||||
, internalInitAt
|
||||
, internalUpdate
|
||||
, internalUpdateUnsafe
|
||||
, internalFinalize
|
||||
-- * Context copy and creation
|
||||
, withCtxCopy
|
||||
@ -81,6 +82,9 @@ foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_
|
||||
foreign import ccall "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_update"
|
||||
c_%%HASHNAME%%_update :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_update"
|
||||
c_%%HASHNAME%%_update_unsafe :: Ptr Ctx -> Ptr Word8 -> Word32 -> IO ()
|
||||
|
||||
foreign import ccall unsafe "cryptonite_%%HEADER_FILE%% cryptonite_%%HASHNAME%%_finalize"
|
||||
c_%%HASHNAME%%_finalize :: Ptr Ctx -> Ptr Word8 -> IO ()
|
||||
|
||||
@ -96,6 +100,14 @@ internalUpdate :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdate ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_%%HASHNAME%%_update ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Update a context in place using an unsafe foreign function call.
|
||||
--
|
||||
-- It is faster than `internalUpdate`, but will block the haskell runtime.
|
||||
-- This shouldn't be used if the input data is large.
|
||||
internalUpdateUnsafe :: Ptr Ctx -> ByteString -> IO ()
|
||||
internalUpdateUnsafe ptr d =
|
||||
unsafeUseAsCStringLen d (\(cs, len) -> c_%%HASHNAME%%_update_unsafe ptr (castPtr cs) (fromIntegral len))
|
||||
|
||||
-- | Finalize a context in place
|
||||
internalFinalize :: Ptr Ctx -> IO ByteString
|
||||
internalFinalize ptr = create digestSize (c_%%HASHNAME%%_finalize ptr)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user