diff options
Diffstat (limited to 'lib/Transforms.hs')
-rw-r--r-- | lib/Transforms.hs | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/lib/Transforms.hs b/lib/Transforms.hs index adb7830..8eaa482 100644 --- a/lib/Transforms.hs +++ b/lib/Transforms.hs | |||
@@ -56,37 +56,34 @@ data SubKey = SubKey MappedPacket [SigAndTrust] deriving Show | |||
56 | 56 | ||
57 | -- | This is a GPG Identity which includes a master key and all its UIDs and | 57 | -- | This is a GPG Identity which includes a master key and all its UIDs and |
58 | -- subkeys and associated signatures. | 58 | -- subkeys and associated signatures. |
59 | data KeyData = KeyData { keyMappedPacket :: MappedPacket -- main key | 59 | data KeyData = KeyData |
60 | , keySigAndTrusts :: [SigAndTrust] -- sigs on main key | 60 | { keyMappedPacket :: MappedPacket -- main key |
61 | , keyUids :: (Map.Map String ([SigAndTrust],OriginMap)) -- uids | 61 | , keySigAndTrusts :: [SigAndTrust] -- sigs on main key |
62 | , keySubKeys :: (Map.Map KeyKey SubKey) -- subkeys | 62 | , keyUids :: (Map.Map String ([SigAndTrust],OriginMap)) -- uids |
63 | } deriving Show | 63 | , keySubKeys :: (Map.Map KeyKey SubKey) -- subkeys |
64 | } deriving Show | ||
64 | type KeyDB = Map.Map KeyKey KeyData | 65 | type KeyDB = Map.Map KeyKey KeyData |
65 | 66 | ||
66 | 67 | ||
67 | 68 | ||
68 | data KeyRingRuntime = KeyRingRuntime | 69 | data KeyRingRuntime = KeyRingRuntime |
69 | { rtPubring :: FilePath | 70 | { rtPubring :: FilePath -- ^ Path to the file represented by 'HomePub' |
70 | -- ^ Path to the file represented by 'HomePub' | 71 | , rtSecring :: FilePath -- ^ Path to the file represented by 'HomeSec' |
71 | , rtSecring :: FilePath | 72 | , rtGrip :: Maybe String |
72 | -- ^ Path to the file represented by 'HomeSec' | 73 | -- ^ Fingerprint or portion of a fingerprint used |
73 | , rtGrip :: Maybe String | 74 | -- to identify the working GnuPG identity used to |
74 | -- ^ Fingerprint or portion of a fingerprint used | 75 | -- make signatures. |
75 | -- to identify the working GnuPG identity used to | 76 | , rtWorkingKey :: Maybe Packet -- ^ The master key of the working GnuPG identity. |
76 | -- make signatures. | 77 | , rtKeyDB :: KeyDB -- ^ The common information pool where files spilled |
77 | , rtWorkingKey :: Maybe Packet | 78 | -- their content and from which they received new |
78 | -- ^ The master key of the working GnuPG identity. | 79 | -- content. |
79 | , rtKeyDB :: KeyDB | 80 | , rtRingAccess :: Map.Map InputFile Access |
80 | -- ^ The common information pool where files spilled | 81 | -- ^ The 'Access' values used for files of type |
81 | -- their content and from which they received new | 82 | -- 'KeyRingFile'. If 'AutoAccess' was specified |
82 | -- content. | 83 | -- for a file, this 'Map.Map' will indicate the |
83 | , rtRingAccess :: Map.Map InputFile Access | 84 | -- detected value that was used by the algorithm. |
84 | -- ^ The 'Access' values used for files of type | 85 | , rtPassphrases :: PacketTranscoder |
85 | -- 'KeyRingFile'. If 'AutoAccess' was specified | 86 | } |
86 | -- for a file, this 'Map.Map' will indicate the | ||
87 | -- detected value that was used by the algorithm. | ||
88 | , rtPassphrases :: PacketTranscoder | ||
89 | } | ||
90 | 87 | ||
91 | 88 | ||
92 | -- | Roster-entry level actions | 89 | -- | Roster-entry level actions |
@@ -140,9 +137,9 @@ data KikiReportAction = | |||
140 | type KikiReport = [ (FilePath, KikiReportAction) ] | 137 | type KikiReport = [ (FilePath, KikiReportAction) ] |
141 | 138 | ||
142 | data UserIDRecord = UserIDRecord { | 139 | data UserIDRecord = UserIDRecord { |
143 | uid_full :: String, | 140 | uid_full :: String, |
144 | uid_realname :: T.Text, | 141 | uid_realname :: T.Text, |
145 | uid_user :: T.Text, | 142 | uid_user :: T.Text, |
146 | uid_subdomain :: T.Text, | 143 | uid_subdomain :: T.Text, |
147 | uid_topdomain :: T.Text | 144 | uid_topdomain :: T.Text |
148 | } | 145 | } |
@@ -780,6 +777,9 @@ makeSig doDecrypt top fname subkey_p tags mbsig = do | |||
780 | 777 | ||
781 | 778 | ||
782 | 779 | ||
780 | -- TODO: Use fingerprint to narrow candidates. | ||
781 | candidateSignerKeys :: KeyDB -> Packet -> [Packet] | ||
782 | candidateSignerKeys db sig = map keyPacket $ Map.elems db | ||
783 | 783 | ||
784 | performManipulations :: | 784 | performManipulations :: |
785 | (PacketDecrypter) | 785 | (PacketDecrypter) |
@@ -812,8 +812,8 @@ performManipulations doDecrypt rt wk manip = do | |||
812 | selfsigs = filter (\(sig,v,whosign) -> isJust (v >> Just wkun >>= guard | 812 | selfsigs = filter (\(sig,v,whosign) -> isJust (v >> Just wkun >>= guard |
813 | . (== keykey whosign) | 813 | . (== keykey whosign) |
814 | . keykey)) vs | 814 | . keykey)) vs |
815 | keys = map keyPacket $ Map.elems (rtKeyDB rt) | 815 | keys = map keyPacket $ Map.elems (rtKeyDB rt) -- TODO candidateSignerKeys (rtKeyDB rt) sig |
816 | overs sig = signatures $ Message (keys++[keyPacket kd,UserIDPacket uid,sig]) | 816 | overs sig = signatures $ Message (keys ++ [keyPacket kd,UserIDPacket uid,sig]) |
817 | vs :: [ ( Packet -- signature | 817 | vs :: [ ( Packet -- signature |
818 | , Maybe SignatureOver -- Nothing means non-verified | 818 | , Maybe SignatureOver -- Nothing means non-verified |
819 | , Packet ) -- key who signed | 819 | , Packet ) -- key who signed |
@@ -822,10 +822,11 @@ performManipulations doDecrypt rt wk manip = do | |||
822 | x <- maybeToList $ Map.lookup uid (keyUids kd) | 822 | x <- maybeToList $ Map.lookup uid (keyUids kd) |
823 | sig <- map (packet . fst) (fst x) | 823 | sig <- map (packet . fst) (fst x) |
824 | o <- overs sig | 824 | o <- overs sig |
825 | k <- keys | 825 | take 1 $ do -- Stop attempting to verify after the first success. |
826 | let ov = verify (Message [k]) $ o | 826 | k <- keys |
827 | signatures_over ov | 827 | let ov = verify (Message [k]) $ o |
828 | return (sig,Just ov,k) | 828 | signatures_over ov |
829 | return (sig,Just ov,k) | ||
829 | additional new_sig = do | 830 | additional new_sig = do |
830 | new_sig <- maybeToList new_sig | 831 | new_sig <- maybeToList new_sig |
831 | guard (null $ selfsigs) | 832 | guard (null $ selfsigs) |