summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonEkblad <>2013-10-01 18:47:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2013-10-01 18:47:00 (GMT)
commitc2280e9ee25c44c2ac1ddac162b0243874bd18b0 (patch)
treeb89d27c7260e43dfd70d4c27bcb1509e089f1473
parentce5fad77a4dd0a6ec73ea566274347003d0c8bf9 (diff)
version 0.2.20.2.2
-rw-r--r--Crypto/Threefish/Skein/Internal.hs30
-rw-r--r--threefish.cabal3
2 files changed, 32 insertions, 1 deletions
diff --git a/Crypto/Threefish/Skein/Internal.hs b/Crypto/Threefish/Skein/Internal.hs
new file mode 100644
index 0000000..07d767c
--- /dev/null
+++ b/Crypto/Threefish/Skein/Internal.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+-- | Skein FFI internals.
+module Crypto.Threefish.Skein.Internal where
+import Foreign.ForeignPtr
+import Foreign.Ptr
+import Data.Word
+
+newtype Skein256Ctx = Skein256Ctx (ForeignPtr Word64)
+
+foreign import ccall unsafe skein256_init
+ :: Ptr Word64 -- ^ Skein 256 context to initialize.
+ -> Ptr Word64 -- ^ Desired key or nullPtr.
+ -> Word64 -- ^ Output size in bits.
+ -> IO ()
+
+foreign import ccall unsafe skein256_update
+ :: Ptr Word64 -- ^ Skein 256 context.
+ -> Int -- ^ First/last update? First starts a new tweak.
+ -- (First bit indicates first, second bit indicates last.)
+ -> Int -- ^ Type of block, as given by type2int.
+ -> Word64 -- ^ Length of block. Must be multiple of 32 except for last.
+ -> Ptr Word64 -- ^ Pointer to update data.
+ -> IO ()
+
+foreign import ccall unsafe skein256_output
+ :: Ptr Word64 -- ^ Skein 256 context.
+ -> Int -- ^ First output block to get.
+ -> Int -- ^ Last output block to get.
+ -> Ptr Word64 -- ^ Pointer to store output data in.
+ -> IO ()
diff --git a/threefish.cabal b/threefish.cabal
index 5919e49..098720b 100644
--- a/threefish.cabal
+++ b/threefish.cabal
@@ -1,5 +1,5 @@
name: threefish
-version: 0.2.1
+version: 0.2.2
synopsis: The Threefish block cipher and the Skein hash function for Haskell.
description: Implements 256 and 512 bit variants of Threefish and Skein. Skein is usable as a "normal" hash function as well as in Skein-MAC, as a cryptographically secure PRNG, as a stream cipher and as a key derivation function, all implemented according to the specifications of the Skein 1.3 paper.
homepage: http://github.com/valderman/threefish
@@ -23,6 +23,7 @@ library
Crypto.Threefish.Authenticated,
Crypto.Threefish.Random,
Crypto.Threefish.Skein,
+ Crypto.Threefish.Skein.Internal,
Crypto.Threefish.Skein.KDF,
Crypto.Threefish.Skein.StreamCipher
other-modules: