diff options
Diffstat (limited to 'Storage.hs')
-rw-r--r-- | Storage.hs | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -16,16 +16,17 @@ import Share import Storage.Network import Servers import Tunables +import ByteStrings import Data.Maybe import Data.List import Data.Monoid import Control.Monad -import Crypto.Random -import System.Random import Control.Concurrent.Thread.Delay import Control.Concurrent.Async import qualified Data.Set as S +import System.Random import System.Random.Shuffle +import qualified Raaz networkStorageLocations :: Maybe LocalStorageDirectory -> StorageLocations networkStorageLocations = StorageLocations . serverList @@ -170,25 +171,25 @@ storeChaff :: HostName -> Port -> Maybe Seconds -> IO () storeChaff hn port delayseconds = forever $ do say $ "Sending chaff to " ++ hn ++ " (press ctrl-c to stop)" say "Legend: + = successful upload, ! = upload failure" - rng <- (cprgCreate <$> createEntropyPool) :: IO SystemRNG - let (randomname, rng') = cprgGenerate 128 rng + prg <- Raaz.newPRG () :: IO Raaz.SystemPRG + randomname <- randomByteStringOfLength 128 prg -- It's ok the use the testModeTunables here because -- the randomname is not something that can be feasibly guessed. -- Prefix "random chaff" to the name to avoid ever using a name -- that a real user might want to use. let sis = shareIdents testModeTunables (Name $ "random chaff:" <> randomname) AnyGpgKey - mapConcurrently (go sis rng') + mapConcurrently (go sis prg) [1..totalObjects (shareParams testModeTunables)] where server = networkStorage Untrusted Nothing $ Server (ServerName hn) [ServerAddress hn port] "chaff server" objsize = objectSize defaultTunables * shareOverhead defaultTunables maxmsdelay = ceiling $ 1000000 * fromMaybe 0 delayseconds - go sis rng n = do + go sis prg n = do msdelay <- getStdRandom (randomR (0, maxmsdelay)) delay msdelay - let (b, rng') = cprgGenerate objsize rng + b <- randomByteStringOfLength objsize prg let share = Share 0 (StorableObject b) let (is, sis') = nextShareIdents sis let i = S.toList is !! (n - 1) @@ -196,7 +197,7 @@ storeChaff hn port delayseconds = forever $ do case r of StoreSuccess -> progress "+" _ -> progress "!" - go sis' rng' n + go sis' prg n -- | Shuffles the list, keeping Recommended first, then -- Alternate, and finally Untrusted. |