diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-07 10:18:31 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-07 10:21:02 -0400 |
commit | 3e432c60d2c6b3fecd920e8053ba4e9a75965dbd (patch) | |
tree | 4d6d8bda9efe4fae54e5509703b30aa2097239f9 /Storage.hs | |
parent | 8069f11684819fb229cfe9e40c680732776c7c9c (diff) | |
download | keysafe-3e432c60d2c6b3fecd920e8053ba4e9a75965dbd.tar.gz |
Removed dependency on crypto-random.
Use raaz for random bytestring generation exclusively. It was already used
in all important places, but chaffing was using crypto-random.
Note that System.Random is used for delays during chaffing and
by random-shuffle.
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. |