diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-07 00:29:18 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-07 00:29:18 -0400 |
commit | 7890e78cc6e98fed07bc2ad471b527a2f1b1494f (patch) | |
tree | 7f61f981730f550475aa4235d04aac822077a6bc /Cost.hs | |
parent | a1de1fb890773d5909e9214496890d4dd0972820 (diff) | |
download | keysafe-7890e78cc6e98fed07bc2ad471b527a2f1b1494f.tar.gz |
improve types
Diffstat (limited to 'Cost.hs')
-rw-r--r-- | Cost.hs | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,4 +1,4 @@ -{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses #-} module Cost where @@ -74,3 +74,10 @@ data UnknownPassword bruteForceLinearSearch :: Cost step -> CostCalc BruteForceOp t bruteForceLinearSearch stepcost e = castCost stepcost `raiseCostPower` reduceEntropy e 1 + +-- | Things that can be brute-forced expose a CostCalc. +class Bruteforceable t a where + getBruteCostCalc :: t -> CostCalc BruteForceOp a + +estimateBruteforceOf :: Bruteforceable t a => t -> Entropy a -> Cost BruteForceOp +estimateBruteforceOf t e = getBruteCostCalc t e |