summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-04 11:44:50 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-04 11:44:50 -0400
commit00d943f2cd0b41f547c8539c0cd829da93b769ae (patch)
tree30c8c8bf792fdcf986a2627e758d6b23420351e5
parentc13b7dc9375dca7bffff9f92c900c45c3aa443e7 (diff)
add type sigs
-rw-r--r--lib/KeyRing.hs8
1 files changed, 8 insertions, 0 deletions
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
250 250
251 251
252 252
253getStr :: SingleKeySpec -> String
253getStr (FingerprintMatch x) = x 254getStr (FingerprintMatch x) = x
254getStr (SubstringMatch _ x) = x 255getStr (SubstringMatch _ x) = x
255getStr _ = "" 256getStr _ = ""
@@ -392,6 +393,7 @@ parseSpec3 maybeExpecting spec@(wordsBy '/' -> fields) =
392 SpecETooBig s --(getStr g) (Just GroupIDField) KeyTypeField 393 SpecETooBig s --(getStr g) (Just GroupIDField) KeyTypeField
393 tooBigError _ x = return x 394 tooBigError _ x = return x
394 395
396wordsBy :: Eq a => a -> [a] -> [[a]]
395wordsBy _ [] = [] 397wordsBy _ [] = []
396wordsBy c xs = let (b,a) = span (/=c) xs 398wordsBy c xs = let (b,a) = span (/=c) xs
397 in b:wordsBy c (drop 1 a) 399 in b:wordsBy c (drop 1 a)
@@ -515,6 +517,8 @@ selectAll wantPublic (spec,mtag) db = do
515 517
516 518
517 519
520writeInputFileL :: InputFileContext
521 -> InputFile -> ByteString -> IO ()
518writeInputFileL ctx (Pipe _ fd) bs = fdToHandle fd >>= (`L.hPut` bs) 522writeInputFileL ctx (Pipe _ fd) bs = fdToHandle fd >>= (`L.hPut` bs)
519writeInputFileL ctx (FileDesc fd) bs = fdToHandle fd >>= (`L.hPut` bs) 523writeInputFileL ctx (FileDesc fd) bs = fdToHandle fd >>= (`L.hPut` bs)
520writeInputFileL ctx inp bs = do 524writeInputFileL ctx inp bs = do
@@ -621,6 +625,7 @@ unconditionally action = do
621-- No instance for (ASN1Object RSA.PublicKey) 625-- No instance for (ASN1Object RSA.PublicKey)
622 626
623 627
628decodeBlob :: ParsedCert -> ByteString
624decodeBlob cert = 629decodeBlob cert =
625 if 0 /= (bs `L.index` 0) .&. 0x10 630 if 0 /= (bs `L.index` 0) .&. 0x10
626 then bs 631 then bs
@@ -842,9 +847,12 @@ subkeysForExport subspec (KeyData key _ _ subkeys) = do
842 in fmap fst v==Just True 847 in fmap fst v==Just True
843 848
844data PemType = PemPublicKey | PemPrivateKey | PemCertificate 849data PemType = PemPublicKey | PemPrivateKey | PemCertificate
850
851pemTypeString :: PemType -> String
845pemTypeString PemPublicKey = "PUBLIC KEY" 852pemTypeString PemPublicKey = "PUBLIC KEY"
846pemTypeString PemPrivateKey = "PRIVATE KEY" 853pemTypeString PemPrivateKey = "PRIVATE KEY"
847pemTypeString PemCertificate = "CERTIFICATE" 854pemTypeString PemCertificate = "CERTIFICATE"
855
848writePEM :: PemType -> String -> String 856writePEM :: PemType -> String -> String
849writePEM (pemTypeString -> typ) dta = pem 857writePEM (pemTypeString -> typ) dta = pem
850 where 858 where