From a1d5de397cd1b12080e4652965591827e6d50c86 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 26 Sep 2016 14:11:32 -0400 Subject: Randomize the server list. May help avoid some correlations. Once there are many servers, will spread the load out amoung them. This commit was sponsored by Ethan Aubin. --- keysafe.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'keysafe.hs') diff --git a/keysafe.hs b/keysafe.hs index f4ee878..ed7b3c4 100644 --- a/keysafe.hs +++ b/keysafe.hs @@ -114,7 +114,8 @@ backup cmdline ui tunables secretkeysource secretkey = do _ <- esk `deepseq` addpercent 25 _ <- sis `seq` addpercent 25 let step = 50 `div` sum (map S.size shares) - storeShares (cmdLineStorageLocations cmdline) sis shares (addpercent step) + locs <- cmdLineStorageLocations cmdline + storeShares locs sis shares (addpercent step) backuplog <- mkBackupLog $ backupMade (mapMaybe getServer locs) secretkeysource passwordentropy case r of StoreSuccess -> do @@ -224,7 +225,8 @@ restore cmdline ui possibletunables secretkeydest = do <$> promptPassword ui True "Enter password" passworddesc let mksis tunables = shareIdents tunables name secretkeydest - r <- downloadInitialShares storagelocations ui mksis possibletunables + locs <- cmdLineStorageLocations cmdline + r <- downloadInitialShares locs ui mksis possibletunables case r of Nothing -> showError ui "No shares could be downloaded. Perhaps you entered the wrong name?" Just (tunables, shares, sis, usedservers) -> do @@ -236,12 +238,11 @@ restore cmdline ui possibletunables secretkeydest = do Right esk -> do final <- withProgress ui "Decrypting" (decryptdesc cost cores) $ \setpercent -> - go tunables [shares] usedservers sis setpercent $ + go locs tunables [shares] usedservers sis setpercent $ tryDecrypt candidatekeys esk final =<< getPasswordEntropy password name where - storagelocations = cmdLineStorageLocations cmdline - go tunables firstshares firstusedservers sis setpercent r = case r of + go locs tunables firstshares firstusedservers sis setpercent r = case r of DecryptFailed -> return $ \_ -> showError ui "Decryption failed! Probably you entered the wrong password." DecryptSuccess secretkey -> do @@ -257,13 +258,13 @@ restore cmdline ui possibletunables secretkeydest = do DecryptIncomplete kek -> do -- Download shares for another chunk. (nextshares, sis', nextusedservers) - <- retrieveShares storagelocations sis (return ()) + <- retrieveShares locs sis (return ()) let shares = firstshares ++ [nextshares] let usedservers = nub (firstusedservers ++ nextusedservers) case combineShares tunables shares of Left e -> return $ \_ -> showError ui e Right esk -> - go tunables shares usedservers sis' setpercent $ + go locs tunables shares usedservers sis' setpercent $ decrypt kek esk namedesc = unlines [ "When you backed up your secret key, you entered some information." @@ -337,9 +338,9 @@ userName = do u <- getUserEntryForID =<< getEffectiveUserID return $ Name $ BU8.fromString $ takeWhile (/= ',') (userGecos u) -cmdLineStorageLocations :: CmdLine.CmdLine -> StorageLocations +cmdLineStorageLocations :: CmdLine.CmdLine -> IO StorageLocations cmdLineStorageLocations cmdline - | CmdLine.localstorage cmdline = localStorageLocations lsd + | CmdLine.localstorage cmdline = return (localStorageLocations lsd) | otherwise = networkStorageLocations lsd where lsd = CmdLine.localstoragedirectory cmdline -- cgit v1.2.3