diff options
author | Andrew Cady <d@jerkface.net> | 2019-07-14 00:10:42 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-07-14 00:13:12 -0400 |
commit | d1dce393d77121509c7ac6d729a09f9f94bc7ab7 (patch) | |
tree | 237b077c353cf5671f7821e12c59f3c11f64e585 /lib/KeyDB.hs | |
parent | 3f29bdc88a068ec3eab91a8bac12757e3a106ceb (diff) |
newtype UidString
Diffstat (limited to 'lib/KeyDB.hs')
-rw-r--r-- | lib/KeyDB.hs | 11 |
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 | ||
26 | import Control.Monad | 27 | import Control.Monad |
@@ -38,12 +39,14 @@ type SigAndTrust = ( MappedPacket | |||
38 | , TrustMap ) -- trust packets | 39 | , TrustMap ) -- trust packets |
39 | data SubKey = SubKey MappedPacket [SigAndTrust] deriving Show | 40 | data SubKey = SubKey MappedPacket [SigAndTrust] deriving Show |
40 | 41 | ||
42 | data 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. |
43 | data KeyData = KeyData | 46 | data 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 | ||
121 | flattenUid :: FilePath -> Bool -> (String,([SigAndTrust],OriginMap)) -> [MappedPacket] | 124 | flattenUid :: FilePath -> Bool -> (UidString,([SigAndTrust],OriginMap)) -> [MappedPacket] |
122 | flattenUid fname ispub (str,(sigs,om)) = | 125 | flattenUid 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 | ||
125 | flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket] | 128 | flattenSub :: FilePath -> Bool -> SubKey -> [MappedPacket] |
126 | flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatSort fname head (unsig fname ispub) sigs | 129 | flattenSub fname ispub (SubKey key sigs) = unk ispub key: concatSort fname head (unsig fname ispub) sigs |
127 | 130 | ||
128 | flattenAllUids :: FilePath -> Bool -> Map.Map String ([SigAndTrust],OriginMap) -> [MappedPacket] | 131 | flattenAllUids :: FilePath -> Bool -> Map.Map UidString ([SigAndTrust],OriginMap) -> [MappedPacket] |
129 | flattenAllUids fname ispub uids = | 132 | flattenAllUids 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 | ||