From a3dae3710e1d7578301b0abbb1a0fd9db4476f7e Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 21 Apr 2014 22:02:12 -0400 Subject: more type sigs in KeyRing.hs (I reached the end of the file now) --- KeyRing.hs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'KeyRing.hs') diff --git a/KeyRing.hs b/KeyRing.hs index 3897ef5..10baa98 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -893,7 +893,7 @@ buildKeyDB :: (MappedPacket -> IO (KikiCondition Packet)) ([Hosts.Hosts], [Hosts.Hosts], Hosts.Hosts, - [(SockAddr, ([ByteString], [ByteString]))], + [(SockAddr, (KeyKey, KeyKey))], [SockAddr]) ) ,[(FilePath,KikiReportAction)])) buildKeyDB doDecrypt secring pubring grip0 keyring = do @@ -1735,6 +1735,7 @@ sigpackets typ hashed unhashed = return $ 0 -- Word16 -- Left 16 bits of the signed hash value [] -- [MPI] +secretToPublic :: Packet -> Packet secretToPublic pkt@(SecretKeyPacket {}) = PublicKeyPacket { version = version pkt , timestamp = timestamp pkt @@ -1763,6 +1764,8 @@ slurpWIPKeys stamp cs = in maybe (ks,b58:js) (\(net,Message [k])->((net,k):ks,js)) mb +decode_btc_key :: + Enum timestamp => timestamp -> String -> Maybe (Word8, Message) decode_btc_key timestamp str = do (network_id,us) <- base58_decode str return . (network_id,) $ Message $ do @@ -1853,8 +1856,10 @@ readPacketsFromFile fname = do return $ decode input #endif +now :: IO Integer now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime +signature_time :: SignatureOver -> Word32 signature_time ov = case if null cs then ds else cs of [] -> minBound xs -> last (sort xs) @@ -1866,6 +1871,7 @@ signature_time ov = case if null cs then ds else cs of creationTime (SignatureCreationTimePacket t) = [t] creationTime _ = [] +splitAtMinBy :: (t -> t -> Ordering) -> [t] -> ([t], [t]) splitAtMinBy comp xs = minimumBy comp' xxs where xxs = zip (inits xs) (tails xs) @@ -1876,6 +1882,14 @@ splitAtMinBy comp xs = minimumBy comp' xxs +findTag :: + String + -> Packet + -> Packet + -> [(MappedPacket, b)] + -> ([(MappedPacket, b)], + Maybe (Bool, (MappedPacket, b)), + [(MappedPacket, b)]) findTag tag wk subkey subsigs = (xs',minsig,ys') where vs = map (\sig -> @@ -1905,6 +1919,14 @@ findTag tag wk subkey subsigs = (xs',minsig,ys') return (tag `elem` ks, sig) +makeSig :: + (MappedPacket -> IO (KikiCondition Packet)) + -> MappedPacket + -> [Char] + -> MappedPacket + -> [Char] + -> Maybe (MappedPacket, Map.Map k a) + -> IO (KikiCondition ((MappedPacket, Map.Map k a), [KikiReportAction])) makeSig doDecrypt top fname subkey_p tag mbsig = do let wk = packet top wkun <- doDecrypt top @@ -2036,18 +2058,21 @@ origin p n = OriginFlags ispub n SecretKeyPacket {} -> False _ -> True +mappedPacket :: FilePath -> Packet -> MappedPacket mappedPacket filename p = MappedPacket { packet = p , usage_tag = Nothing , locations = Map.singleton filename (origin p (-1)) } +keykey :: Packet -> KeyKey keykey key = -- Note: The key's timestamp is included in it's fingerprint. -- Therefore, the same key with a different timestamp is -- considered distinct using this keykey implementation. fingerprint_material (key {timestamp=0}) -- TODO: smaller key? +uidkey :: Packet -> String uidkey (UserIDPacket str) = str merge :: KeyDB -> FilePath -> Message -> KeyDB @@ -2207,8 +2232,11 @@ unsig fname isPublic (sig,trustmap) = asMapped n p = let m = mappedPacket fname p in m { locations = fmap (\x->x {originalNum=n}) (locations m) } +concatSort :: + FilePath -> ([a] -> MappedPacket) -> (b -> [a]) -> [b] -> [a] concatSort fname getp f = concat . sortByHint fname getp . map f +sortByHint :: FilePath -> (a -> MappedPacket) -> [a] -> [a] sortByHint fname f = sortBy (comparing gethint) where gethint = maybe defnum originalNum . Map.lookup fname . locations . f @@ -2369,9 +2397,11 @@ fingerdress topk = maybe zero id $ Hosts.inet_pton addr_str colons (a:b:c:d:xs@(_:_)) = [a,b,c,d,':'] ++ colons xs colons xs = xs +backsig :: SignatureSubpacket -> Maybe Packet backsig (EmbeddedSignaturePacket s) = Just s backsig _ = Nothing +socketFamily :: SockAddr -> Family socketFamily (SockAddrInet _ _) = AF_INET socketFamily (SockAddrInet6 _ _ _ _) = AF_INET6 socketFamily (SockAddrUnix _) = AF_UNIX -- cgit v1.2.3