packages feed

crypto-numbers 0.1.3 → 0.2.0

raw patch · 2 files changed

+21/−8 lines, 2 filesdep +byteabledep +crypto-randomdep ~crypto-random-apidep ~vectorPVP ok

version bump matches the API change (PVP)

Dependencies added: byteable, crypto-random

Dependency ranges changed: crypto-random-api, vector

API changes (from Hackage documentation)

Files

Tests/RNG.hs view
@@ -2,8 +2,9 @@  import Data.Word import Data.List (foldl')+import Data.Byteable import qualified Data.ByteString as B-import Crypto.Random.API+import Crypto.Random import Control.Arrow (first)  {- this is a just test rng. this is absolutely not a serious RNG. DO NOT use elsewhere -}@@ -24,10 +25,21 @@      in (b:l, g'')  instance CPRG Rng where-    cprgGenBytes len g    = first B.pack $ getBytes len g-    cprgSupplyEntropy e g = reseed e g-    cprgNeedReseed _      = NeverReseed+    cprgCreate pool = let ent = grabEntropy 4 pool in generate (B.unpack $ toBytes ent)+    cprgSetReseedThreshold _ g = g+    cprgGenerate len g = first B.pack $ getBytes len g+    cprgGenerateWithEntropy = cprgGenerate+    cprgFork g = let (bs, g') = getBytes 4 g+                    in case bs of+                        [a,b,c,d] -> let g2 = Rng (fromIntegral a * 256 + fromIntegral b, fromIntegral c * 256 + fromIntegral d)+                                      in (g2, g')+                        _         -> error "getBytes assertion" ++generate :: [Word8] -> Rng+generate [a,b,c,d] = Rng (fromIntegral a * 256 + fromIntegral b, fromIntegral c * 256 + fromIntegral d)+generate _ = error "generate assertion: need 4 bytes"+ reseed :: B.ByteString -> Rng -> Rng reseed bs (Rng (a,b)) = Rng (fromIntegral a', b')         where a' = foldl' (\v i -> ((fromIntegral v) + (fromIntegral i) * 36969) `mod` 65536) a l@@ -35,4 +47,4 @@               l  = B.unpack bs  rng :: Rng-rng = Rng (1,2) +rng = Rng (2,2)
crypto-numbers.cabal view
@@ -1,5 +1,5 @@ Name:                crypto-numbers-Version:             0.1.3+Version:             0.2.0 Description:         Cryptographic numbers: functions and algorithms License:             BSD3 License-file:        LICENSE@@ -17,7 +17,7 @@   Build-Depends:     base >= 4 && < 5                    , bytestring                    , vector-                   , crypto-random-api >= 0.2 && < 0.3+                   , crypto-random >= 0.0 && < 0.1   Exposed-modules:   Crypto.Number.ModArithmetic                      Crypto.Number.Serialize                      Crypto.Number.Generate@@ -31,9 +31,10 @@   hs-source-dirs:    Tests   Main-Is:           Tests.hs   Build-depends:     base >= 4 && < 5-                   , crypto-random-api+                   , crypto-random                    , crypto-numbers                    , bytestring+                   , byteable                    , vector                    , QuickCheck >= 2                    , HUnit