summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-07 17:24:56 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-07 17:24:56 -0400
commit6f2d6120533070ce48bbc1e12465d1f7d603aec8 (patch)
tree29ce41b0999dc9dca388de3304e801d66b547daf /Types.hs
parentd2a6fc83a8657329fc2d3d97308801dcc1c9aa48 (diff)
downloadkeysafe-6f2d6120533070ce48bbc1e12465d1f7d603aec8.tar.gz
sharding
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs24
1 files changed, 23 insertions, 1 deletions
diff --git a/Types.hs b/Types.hs
index 8787273..b4d68f4 100644
--- a/Types.hs
+++ b/Types.hs
@@ -1,9 +1,12 @@
-{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances #-}
module Types where
+import Cost
+import Entropy
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8
+import qualified Data.ByteString.Lazy as BL
import Raaz.Core.Encode
import Data.Monoid
import Data.Word
@@ -11,10 +14,29 @@ import Data.Time.Clock
import Data.String
import Text.Read
+-- | keysafe stores secret keys.
+newtype SecretKey = SecretKey B.ByteString
+
+-- | The secret key, encrypted with a password.
+data EncryptedSecretKey = EncryptedSecretKey B.ByteString (CostCalc BruteForceOp UnknownPassword)
+
+instance Bruteforceable EncryptedSecretKey UnknownPassword where
+ getBruteCostCalc (EncryptedSecretKey _ cc) = cc
+
+-- | An object that can be stored on a keysafe server.
+data StorableObject = StorableObject BL.ByteString
+
-- | A password used to encrypt a key stored in keysafe.
newtype Password = Password B.ByteString
deriving (IsString)
+-- | Naive calculation of the entropy of a password.
+-- Does not take common passwords and password generation patterns into
+-- account, so this is an overestimation of how hard a password
+-- is to crack.
+passwordEntropy :: Password -> Entropy UnknownPassword
+passwordEntropy (Password p) = Entropy $ floor $ totalEntropy p
+
-- | A name associated with a key stored in keysafe.
newtype Name = Name B.ByteString
deriving (Show)