afis 0.1.1 → 0.1.2
raw patch · 3 files changed
+15/−11 lines, 3 filesdep +crypto-randomdep −crypto-random-apidep ~cryptohash
Dependencies added: crypto-random
Dependencies removed: crypto-random-api
Dependency ranges changed: cryptohash
Files
- Crypto/Data/AFIS.hs +3/−3
- afis.cabal +5/−4
- tests/Tests.hs +7/−4
Crypto/Data/AFIS.hs view
@@ -79,7 +79,7 @@ xorMem blockPtr lastBlock blockSize diffuse hashF lastBlock blockSize fillRandomBlock g blockPtr = do- let (rand, g') = genRandomBytes blockSize g+ let (rand, g') = cprgGenerate blockSize g withBytePtr rand $ \randPtr -> B.memcpy blockPtr randPtr blockSize return g' @@ -132,10 +132,10 @@ return () | otherwise = return () - digestSize = B.length $ digestToByteString $ hashF B.empty+ digestSize = byteableLength $ hashF B.empty byteStringOfPtr :: Ptr Word8 -> Int -> IO ByteString byteStringOfPtr ptr sz = newForeignPtr_ ptr >>= \fptr -> return $ B.fromForeignPtr fptr 0 sz hashBlock n src =- digestToByteString $ hashF $ runPacking (B.length src+4) (putWord32BE (fromIntegral n) >> putBytes src)+ toBytes $ hashF $ runPacking (B.length src+4) (putWord32BE (fromIntegral n) >> putBytes src)
afis.cabal view
@@ -1,5 +1,5 @@ Name: afis-Version: 0.1.1+Version: 0.1.2 Synopsis: Anti-forensic Information Splitter Description: Anti-forensic Information Splitter as defined for LUKS License: BSD3@@ -17,8 +17,8 @@ Library Build-Depends: base >= 3 && < 5 , bytestring- , cryptohash- , crypto-random-api+ , cryptohash >= 0.9.1+ , crypto-random , packer , byteable Exposed-modules: Crypto.Data.AFIS@@ -35,9 +35,10 @@ , test-framework-quickcheck2 , test-framework-hunit , afis- , crypto-random-api+ , crypto-random , cryptohash , bytestring+ , byteable ghc-options: -Wall -fno-warn-orphans -fno-warn-missing-signatures source-repository head
tests/Tests.hs view
@@ -14,8 +14,9 @@ import qualified Crypto.Data.AFIS as AFIS import Crypto.Hash-import Crypto.Random.API+import Crypto.Random import qualified Data.ByteString as B+import Data.Byteable mergeVec = [ (3@@ -42,11 +43,13 @@ data FakeRNG = FakeRNG Int B.ByteString instance CPRG FakeRNG where- cprgNeedReseed _ = NeverReseed- cprgSupplyEntropy b2 (FakeRNG o b) = FakeRNG o (B.append b b2)- cprgGenBytes n (FakeRNG o b)+ cprgCreate pool = FakeRNG 0 (toBytes $ grabEntropy 1024 pool)+ cprgSetReseedThreshold _ g = g+ cprgGenerate n (FakeRNG o b) | n > B.length b - o = (B.take n $ B.drop o (B.concat $ replicate 10 b), FakeRNG 0 b) | otherwise = (B.take n $ B.drop o b, FakeRNG (o+n) b)+ cprgGenerateWithEntropy = cprgGenerate+ cprgFork g = (g,g) instance Arbitrary AFISParams where arbitrary = AFISParams <$> arbitraryBS <*> choose (2,2) <*> elements [hash :: HashFunctionBS SHA1] <*> arbitraryRandom