diff options
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 67 |
1 files changed, 0 insertions, 67 deletions
@@ -650,19 +650,6 @@ getPassphrase cmd = | |||
650 | 650 | ||
651 | #define HOMEOPTION (def &= explicit &= name "homedir" &= typDir ) | 651 | #define HOMEOPTION (def &= explicit &= name "homedir" &= typDir ) |
652 | 652 | ||
653 | flattenKeys :: Bool -> KeyDB -> Message | ||
654 | flattenKeys isPublic db = Message $ concatMap (map packet . flattenTop "" isPublic . snd) (prefilter . Map.assocs $ db) | ||
655 | where | ||
656 | prefilter = if isPublic then id else filter isSecret | ||
657 | where | ||
658 | isSecret (_,(KeyData | ||
659 | (MappedPacket { packet=(SecretKeyPacket {})}) | ||
660 | _ | ||
661 | _ | ||
662 | _)) = True | ||
663 | isSecret _ = False | ||
664 | |||
665 | |||
666 | writeOutKeyrings :: Map.Map FilePath t -> KeyDB -> IO () | 653 | writeOutKeyrings :: Map.Map FilePath t -> KeyDB -> IO () |
667 | writeOutKeyrings lkmap db = do | 654 | writeOutKeyrings lkmap db = do |
668 | let ks = Map.elems db | 655 | let ks = Map.elems db |
@@ -1704,60 +1691,6 @@ isTopKey p@(SecretKeyPacket {}) | not (is_subkey p) = True | |||
1704 | isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True | 1691 | isTopKey p@(PublicKeyPacket {}) | not (is_subkey p) = True |
1705 | isTopKey _ = False | 1692 | isTopKey _ = False |
1706 | 1693 | ||
1707 | selectSecretKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet | ||
1708 | selectSecretKey (spec,mtag) db = selectKey0 False (spec,mtag) db | ||
1709 | |||
1710 | selectPublicKey :: (KeySpec,Maybe String) -> KeyDB -> Maybe Packet | ||
1711 | selectPublicKey (spec,mtag) db = selectKey0 True (spec,mtag) db | ||
1712 | |||
1713 | selectKey0 :: Bool -> (KeySpec,Maybe String) -> KeyDB -> Maybe Packet | ||
1714 | selectKey0 wantPublic (spec,mtag) db = do | ||
1715 | let Message ps = flattenKeys wantPublic db | ||
1716 | ys = snd $ seek_key spec ps | ||
1717 | flip (maybe (listToMaybe ys)) mtag $ \tag -> do | ||
1718 | let (subspec,ys1) = (KeyTag y tag,ys1) where y:ys1 = ys | ||
1719 | zs = snd $ seek_key subspec ys1 | ||
1720 | listToMaybe zs | ||
1721 | |||
1722 | seek_key :: KeySpec -> [Packet] -> ([Packet],[Packet]) | ||
1723 | seek_key (KeyGrip grip) sec = (pre, subs) | ||
1724 | where | ||
1725 | (pre,subs) = break pred sec | ||
1726 | pred p@(SecretKeyPacket {}) = matchpr grip p == grip | ||
1727 | pred p@(PublicKeyPacket {}) = matchpr grip p == grip | ||
1728 | pred _ = False | ||
1729 | |||
1730 | seek_key (KeyTag key tag) ps = if null bs | ||
1731 | then (ps,[]) | ||
1732 | else if null qs | ||
1733 | then let (as',bs') = seek_key (KeyTag key tag) (tail bs) | ||
1734 | in (as ++ (head bs:as'), bs') | ||
1735 | else (reverse (tail qs), head qs : reverse rs ++ bs) | ||
1736 | where | ||
1737 | (as,bs) = break (\p -> isSignaturePacket p | ||
1738 | && has_tag tag p | ||
1739 | && isJust (signature_issuer p) | ||
1740 | && matchpr (fromJust $ signature_issuer p) key == fromJust (signature_issuer p) ) | ||
1741 | ps | ||
1742 | (rs,qs) = break isKey (reverse as) | ||
1743 | |||
1744 | has_tag tag p = tag `elem` mapMaybe usage (hashed_subpackets p) | ||
1745 | || tag `elem` map usageString (mapMaybe keyflags (hashed_subpackets p)) | ||
1746 | |||
1747 | seek_key (KeyUidMatch pat) ps = if null bs | ||
1748 | then (ps,[]) | ||
1749 | else if null qs | ||
1750 | then let (as',bs') = seek_key (KeyUidMatch pat) (tail bs) | ||
1751 | in (as ++ (head bs:as'), bs') | ||
1752 | else (reverse (tail qs), head qs : reverse rs ++ bs) | ||
1753 | where | ||
1754 | (as,bs) = break (isInfixOf pat . uidStr) | ||
1755 | ps | ||
1756 | (rs,qs) = break isKey (reverse as) | ||
1757 | |||
1758 | uidStr (UserIDPacket s) = s | ||
1759 | uidStr _ = "" | ||
1760 | |||
1761 | groupTops ps = groupBy (\_ b -> not (isTopKey b)) ps | 1694 | groupTops ps = groupBy (\_ b -> not (isTopKey b)) ps |
1762 | 1695 | ||
1763 | 1696 | ||