From 00d943f2cd0b41f547c8539c0cd829da93b769ae Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Thu, 4 Jul 2019 11:44:50 -0400 Subject: add type sigs --- lib/KeyRing.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs index 0637044..c41439a 100644 --- a/lib/KeyRing.hs +++ b/lib/KeyRing.hs @@ -250,6 +250,7 @@ x509cert _ = Nothing +getStr :: SingleKeySpec -> String getStr (FingerprintMatch x) = x getStr (SubstringMatch _ x) = x getStr _ = "" @@ -392,6 +393,7 @@ parseSpec3 maybeExpecting spec@(wordsBy '/' -> fields) = SpecETooBig s --(getStr g) (Just GroupIDField) KeyTypeField tooBigError _ x = return x +wordsBy :: Eq a => a -> [a] -> [[a]] wordsBy _ [] = [] wordsBy c xs = let (b,a) = span (/=c) xs in b:wordsBy c (drop 1 a) @@ -515,6 +517,8 @@ selectAll wantPublic (spec,mtag) db = do +writeInputFileL :: InputFileContext + -> InputFile -> ByteString -> IO () writeInputFileL ctx (Pipe _ fd) bs = fdToHandle fd >>= (`L.hPut` bs) writeInputFileL ctx (FileDesc fd) bs = fdToHandle fd >>= (`L.hPut` bs) writeInputFileL ctx inp bs = do @@ -621,6 +625,7 @@ unconditionally action = do -- No instance for (ASN1Object RSA.PublicKey) +decodeBlob :: ParsedCert -> ByteString decodeBlob cert = if 0 /= (bs `L.index` 0) .&. 0x10 then bs @@ -842,9 +847,12 @@ subkeysForExport subspec (KeyData key _ _ subkeys) = do in fmap fst v==Just True data PemType = PemPublicKey | PemPrivateKey | PemCertificate + +pemTypeString :: PemType -> String pemTypeString PemPublicKey = "PUBLIC KEY" pemTypeString PemPrivateKey = "PRIVATE KEY" pemTypeString PemCertificate = "CERTIFICATE" + writePEM :: PemType -> String -> String writePEM (pemTypeString -> typ) dta = pem where -- cgit v1.2.3