aboutsummaryrefslogtreecommitdiff
path: root/Utility/Gpg.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Utility/Gpg.hs')
-rw-r--r--Utility/Gpg.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs
index c20be754f..dae254854 100644
--- a/Utility/Gpg.hs
+++ b/Utility/Gpg.hs
@@ -22,6 +22,7 @@ import Utility.Format (decode_c)
import Control.Concurrent
import Control.Monad.IO.Class
import qualified Data.Map as M
+import Data.Char
type KeyId = String
@@ -158,9 +159,9 @@ pipeLazy (GpgCmd cmd) params feeder reader = do
- GnuPG's manpage.) -}
findPubKeys :: GpgCmd -> String -> IO KeyIds
findPubKeys cmd for
- -- "subkey!" tells gpg to force use of a specific subkey,
- -- so pass it through as-is rather than looking up the master key.
- | "!" `isSuffixOf` for = return $ KeyIds [for]
+ -- pass forced subkey through as-is rather than
+ -- looking up the master key.
+ | isForcedSubKey for = return $ KeyIds [for]
| otherwise = KeyIds . parse . lines <$> readStrict cmd params
where
params = [Param "--with-colons", Param "--list-public-keys", Param for]
@@ -168,6 +169,10 @@ findPubKeys cmd for
keyIdField ("pub":_:_:_:f:_) = Just f
keyIdField _ = Nothing
+{- "subkey!" tells gpg to force use of a specific subkey -}
+isForcedSubKey :: String -> Bool
+isForcedSubKey s = "!" `isSuffixOf` s && all isHexDigit (drop 1 s)
+
type UserId = String
{- All of the user's secret keys, with their UserIds.