diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-30 12:36:47 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-30 12:46:10 -0400 |
commit | 69a78f842a368ff143fca220584393afabd674f2 (patch) | |
tree | c46ca73345c341b5705a5c88912459abfc432292 /ExpensiveHash.hs | |
parent | 9363b4ba80de07c78805360bacf4c10b7efae13b (diff) | |
download | keysafe-69a78f842a368ff143fca220584393afabd674f2.tar.gz |
improve calcuation of expected time for the key encryption key hash
Take randomSaltBytes into account rather than hardcoding
Diffstat (limited to 'ExpensiveHash.hs')
-rw-r--r-- | ExpensiveHash.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ExpensiveHash.hs b/ExpensiveHash.hs index 4031ef3..abe89ca 100644 --- a/ExpensiveHash.hs +++ b/ExpensiveHash.hs @@ -73,10 +73,17 @@ benchmarkTunables :: Tunables -> IO () benchmarkTunables tunables = do putStrLn "/proc/cpuinfo:" putStrLn =<< readFile "/proc/cpuinfo" - putStrLn "Benchmarking 16 rounds of key generation hash..." + + -- Rather than run all 256 rounds of this hash, which would + -- probably take on the order of 1 hour, run only 16, and scale + -- the expected cost accordingly. + let normalrounds = fromIntegral $ + 256 * randomSaltBytes (keyEncryptionKeyTunable tunables) + putStrLn $ "Benchmarking 16/" ++ show normalrounds ++ " rounds of key encryption key hash..." print =<< benchmarkExpensiveHash 16 (keyEncryptionKeyHash $ keyEncryptionKeyTunable tunables) - (mapCost (`div` 16) $ randomSaltBytesBruteForceCost $ keyEncryptionKeyTunable tunables) + (mapCost (`div` (normalrounds `div` 16)) $ randomSaltBytesBruteForceCost $ keyEncryptionKeyTunable tunables) + putStrLn "Benchmarking 1 round of name generation hash..." print =<< benchmarkExpensiveHash 1 (nameGenerationHash $ nameGenerationTunable tunables) |