summaryrefslogtreecommitdiff
path: root/lib/KeyDB.hs
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-07-14 00:10:42 -0400
committerAndrew Cady <d@jerkface.net>2019-07-14 00:13:12 -0400
commitd1dce393d77121509c7ac6d729a09f9f94bc7ab7 (patch)
tree237b077c353cf5671f7821e12c59f3c11f64e585 /lib/KeyDB.hs
parent3f29bdc88a068ec3eab91a8bac12757e3a106ceb (diff)
newtype UidString
Diffstat (limited to 'lib/KeyDB.hs')
-rw-r--r--lib/KeyDB.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/KeyDB.hs b/lib/KeyDB.hs
index 1f0849c..1aef747 100644
--- a/lib/KeyDB.hs
+++ b/lib/KeyDB.hs
@@ -21,6 +21,7 @@ module KeyDB
21 , sortByHint 21 , sortByHint
22 , flattenKeys 22 , flattenKeys
23 , flattenFiltered 23 , flattenFiltered
24 , UidString(..)
24 ) where 25 ) where
25 26
26import Control.Monad 27import Control.Monad
@@ -38,12 +39,14 @@ type SigAndTrust = ( MappedPacket
38 , TrustMap ) -- trust packets 39 , TrustMap ) -- trust packets
39data SubKey = SubKey MappedPacket [SigAndTrust] deriving Show 40data SubKey = SubKey MappedPacket [SigAndTrust] deriving Show
40 41
42data UidString = UidString { unUidString :: String } deriving (Show, Eq, Ord)
43
41-- | This is a GPG Identity which includes a master key and all its UIDs and 44-- | This is a GPG Identity which includes a master key and all its UIDs and
42-- subkeys and associated signatures. 45-- subkeys and associated signatures.
43data KeyData = KeyData 46data KeyData = KeyData
44 { keyMappedPacket :: MappedPacket -- main key 47 { keyMappedPacket :: MappedPacket -- main key
45 , keySigAndTrusts :: [SigAndTrust] -- sigs on main key 48 , keySigAndTrusts :: [SigAndTrust] -- sigs on main key
46 , keyUids :: (Map.Map String ([SigAndTrust],OriginMap)) -- uids 49 , keyUids :: (Map.Map UidString ([SigAndTrust],OriginMap)) -- uids
47 , keySubKeys :: (Map.Map KeyKey SubKey) -- subkeys 50 , keySubKeys :: (Map.Map KeyKey SubKey) -- subkeys
48 } deriving Show 51 } deriving Show
49 52
@@ -118,14 +121,14 @@ flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPubl
118 _)) = True 121 _)) = True
119 isSecret _ = False 122 isSecret _ = False
120 123
121flattenUid :: FilePath -> Bool -> (String,([SigAndTrust],OriginMap)) -> [MappedPacket] 124flattenUid :: FilePath -> Bool -> (UidString,([SigAndTrust],OriginMap)) -> [MappedPacket]
122flattenUid fname ispub (str,(sigs,om)) = 125flattenUid fname ispub (UidString str,(sigs,om)) =
123 (mappedPacket "" $ UserIDPacket str) {locations=om} : concatSort fname head (unsig fname ispub) sigs 126 (mappedPacket "" $ UserIDPacket str) {locations=om} : concatSort fname head (unsig fname ispub) sigs
124 127
125flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket] 128flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket]
126flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatSort fname head (unsig fname ispub) sigs 129flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatSort fname head (unsig fname ispub) sigs
127 130
128flattenAllUids :: FilePath -> Bool -> Map.Map String ([SigAndTrust],OriginMap) -> [MappedPacket] 131flattenAllUids :: FilePath -> Bool -> Map.Map UidString ([SigAndTrust],OriginMap) -> [MappedPacket]
129flattenAllUids fname ispub uids = 132flattenAllUids fname ispub uids =
130 concatSort fname head (flattenUid fname ispub) (Map.assocs uids) 133 concatSort fname head (flattenUid fname ispub) (Map.assocs uids)
131 134