packages feed

threefish 0.2.5 → 0.2.6

raw patch · 3 files changed

+24/−12 lines, 3 filesdep ~arraydep ~basedep ~bytestring

Dependency ranges changed: array, base, bytestring, cereal, crypto-api, data-default, entropy, tagged

Files

Crypto/Threefish/Authenticated.hs view
@@ -22,10 +22,19 @@ prng :: IORef SkeinGen prng = unsafePerformIO $ newSkeinGen >>= newIORef +-- | Strict version of 'atomicModifyIORef'.  This forces both the value stored+-- in the 'IORef' as well as the value returned.+atomicModIORef' :: IORef a -> (a -> (a,b)) -> IO b+atomicModIORef' ref f = do+    b <- atomicModifyIORef ref+            (\x -> let (a, b) = f x+                    in (a, a `seq` b))+    b `seq` return b+ -- | Generate a 256 bit nonce using the Skein PRNG. generateNonce :: IO Nonce256 generateNonce =-    Block256 `fmap` atomicModifyIORef' prng (pflip . randomBytes 32)+    Block256 `fmap` atomicModIORef' prng (pflip . randomBytes 32)   where     pflip (a, b) = (b, a) 
Crypto/Threefish/Skein.hs view
@@ -58,7 +58,7 @@               BS.packCStringLen (castPtr ptr, outlen)           | otherwise -> do               let !chunk' =-                    BSL.toStrict chunk+                    toStrict chunk                   (!lst, !len) =                     if BSL.null rest                       then (2, fromIntegral $ BS.length chunk')@@ -67,6 +67,9 @@                 skein256_update ctx (first .|. lst) msgtype len (castPtr ptr)               go 0 rest ctx +toStrict :: BSL.ByteString -> BS.ByteString+toStrict = BS.concat . BSL.toChunks+ hash256 :: Word64 -> Key256 -> BSL.ByteString -> BS.ByteString hash256 outlen k bs =     case init256 k outlen of@@ -75,7 +78,7 @@ {-# INLINE skein256 #-} -- | Hash a message using 256 bit Skein. skein256 :: BSL.ByteString -> Block256-skein256 = Block256 . hash256 32 (Block256 "")+skein256 = Block256 . hash256 32 (Block256 BS.empty)  {-# INLINE skeinMAC256 #-} -- | Create a 256 bit Skein-MAC.
threefish.cabal view
@@ -1,5 +1,5 @@ name:                threefish-version:             0.2.5+version:             0.2.6 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@@ -37,15 +37,15 @@     MultiParamTypeClasses,     FunctionalDependencies   build-depends:-    base >=4.6 && <5,-    bytestring >=0.10,-    cereal >=0.3,-    array >=0.4,-    crypto-api >=0.12,-    tagged >=0.4,-    data-default >=0.5,+    base >=4.5 && <5,+    bytestring >=0.10.4.0,+    cereal >=0.4.0.1,+    array >=0.4.0.0,+    crypto-api >=0.12.2.2,+    tagged >=0.7,+    data-default >=0.5.3,     random,-    entropy >= 0.2.2.2+    entropy   default-language:    Haskell2010   ghc-options: -Wall -O2   include-dirs: cbits