From 5decbad3eb779b1bbe11245cbde84701909e9c68 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Aug 2016 15:52:50 -0400 Subject: nearly able to generate shards now --- Types.hs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'Types.hs') diff --git a/Types.hs b/Types.hs index 7262f33..085f321 100644 --- a/Types.hs +++ b/Types.hs @@ -20,6 +20,11 @@ instance Bruteforceable EncryptedSecretKey UnknownPassword where -- | Objects stored on a keysafe server are (probably) a shard of an -- encrypted secret key. newtype StorableObject = StorableObject { fromStorableObject :: BL.ByteString } + deriving (Show) + +-- | An identifier for a StorableObject +newtype StorableObjectIdent = StorableObjectIdent B.ByteString + deriving (Show) -- | A password used to encrypt a key stored in keysafe. newtype Password = Password B.ByteString @@ -36,6 +41,11 @@ passwordEntropy (Password p) = Entropy $ floor $ totalEntropy p newtype Name = Name B.ByteString deriving (Show) +-- | Very naive calculation of the entropy of a name. +-- Assumes that the attacker is not targeting a particular list of names. +nameEntropy :: Name -> Entropy UnknownName +nameEntropy (Name n) = Entropy $ floor $ totalEntropy n + -- | The type of the key that is stored in keysafe. newtype KeyType = KeyType B.ByteString deriving (Show) @@ -43,16 +53,11 @@ newtype KeyType = KeyType B.ByteString gpgKey :: KeyType gpgKey = KeyType "gpg" --- | Enough information to uniquely identify a key stored in keysafe. -data KeyIdent = KeyIdent KeyType Name - deriving (Show) - -newtype ShardNum = ShardNum Int - deriving (Show) - --- | Enough information to uniquely identify an object stored on a keysafe --- server for a key. -data ObjectIdent = ObjectIdent ShardNum KeyIdent +-- | The keyid is any value that is unique to a private key, and can be +-- looked up somehow without knowing the private key. +-- +-- A gpg keyid is the obvious example. +data KeyId = KeyId KeyType B.ByteString deriving (Show) data Benchmark t = Benchmark { expectedBenchmark :: t, actualBenchmark :: t } -- cgit v1.2.3