From d5b38fc2736ae75c872a6eb51d80cc90e97d1fc4 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 16 Jul 2019 21:14:32 -0400 Subject: KeyExact --- lib/KeyRing.hs | 2 +- lib/KeyRing/BuildKeyDB.hs | 11 ++++++++--- lib/KeyRing/Types.hs | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs index 8c92a81..4260eeb 100644 --- a/lib/KeyRing.hs +++ b/lib/KeyRing.hs @@ -673,7 +673,7 @@ isauth rt keydata = dont_have keydata && maybe False (`has_good_sig` keydata) wk workingKey grip use_db = listToMaybe $ do fp <- maybeToList grip elm <- keyData use_db - guard $ matchSpec (KeyGrip $ show fp) elm + guard $ matchSpec (KeyExact $ Just fp) elm return $ keyPacket elm mkarmor :: Access -> L.ByteString -> [Armor] diff --git a/lib/KeyRing/BuildKeyDB.hs b/lib/KeyRing/BuildKeyDB.hs index 510c820..ef4edba 100644 --- a/lib/KeyRing/BuildKeyDB.hs +++ b/lib/KeyRing/BuildKeyDB.hs @@ -416,9 +416,9 @@ parseSpec wkgrip spec = case prespec of AnyMatch -> (KeyGrip "", Nothing) EmptyMatch -> error "Bad key spec." - WorkingKeyMatch -> (KeyGrip $ show wkgrip, Nothing) - SubstringMatch (Just KeyTypeField) tag -> (KeyGrip $ show wkgrip, Just tag) - SubstringMatch Nothing str -> (KeyGrip $ show wkgrip, Just str) + WorkingKeyMatch -> (KeyExact wkgrip, Nothing) + SubstringMatch (Just KeyTypeField) tag -> (KeyExact wkgrip, Just tag) + SubstringMatch Nothing str -> (KeyExact wkgrip, Just str) SubstringMatch (Just UserIDField) ustr -> (KeyUidMatch ustr, Nothing) FingerprintMatch fp -> (KeyGrip fp, Nothing) else @@ -780,6 +780,11 @@ is40digitHex xs = ys == xs && length ys==40 ishex c = False matchSpec :: KeySpec -> KeyData -> Bool +matchSpec (KeyExact Nothing) _ = False +matchSpec (KeyExact (Just grip)) (KeyData p _ _ _) + | matchpr grip (packet p) = True + | otherwise = False + matchSpec (KeyGrip grip) (KeyData p _ _ _) | matchpr' grip (packet p) = True | otherwise = False diff --git a/lib/KeyRing/Types.hs b/lib/KeyRing/Types.hs index 1a12a61..99986e1 100644 --- a/lib/KeyRing/Types.hs +++ b/lib/KeyRing/Types.hs @@ -367,6 +367,7 @@ matchpr'' fp k | otherwise = "" data KeySpec = KeyGrip String -- fp: + | KeyExact (Maybe Fingerprint) | KeyTag Packet String -- fp:????/t: | KeyUidMatch String -- u: deriving Show -- cgit v1.2.3