summaryrefslogtreecommitdiff
path: root/KeyRing.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-07-31 22:04:42 -0400
committerjoe <joe@jerkface.net>2014-07-31 22:04:42 -0400
commitb08068c787f8f69271cd7d9f7480e88a988acbff (patch)
tree988fb8473d2195b1868dc738801fde6444a99c24 /KeyRing.hs
parent1e92b09448a61b715b8a7394ede0062d5a2efb45 (diff)
init-key command
Diffstat (limited to 'KeyRing.hs')
-rw-r--r--KeyRing.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index e0994cf..ab7450b 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -86,6 +86,14 @@ module KeyRing
86 , decodeBlob 86 , decodeBlob
87 , selectPublicKeyAndSigs 87 , selectPublicKeyAndSigs
88 , x509cert 88 , x509cert
89 , getHomeDir
90 , unconditionally
91 , SecretPEMData(..)
92 , readSecretPEMFile
93 , writeInputFileL
94 , InputFileContext(..)
95 , onionNameForContact
96 , keykey
89 ) where 97 ) where
90 98
91import System.Environment 99import System.Environment
@@ -1417,6 +1425,13 @@ derRSA rsa = do
1417 k <- rsaKeyFromPacket rsa 1425 k <- rsaKeyFromPacket rsa
1418 return $ encodeASN1 DER (toASN1 k []) 1426 return $ encodeASN1 DER (toASN1 k [])
1419 1427
1428unconditionally :: IO (KikiCondition a) -> IO a
1429unconditionally action = do
1430 r <- action
1431 case r of
1432 KikiSuccess x -> return x
1433 e -> error $ errorString e
1434
1420try :: Monad m => KikiCondition a -> (a -> m (KikiCondition b)) -> m (KikiCondition b) 1435try :: Monad m => KikiCondition a -> (a -> m (KikiCondition b)) -> m (KikiCondition b)
1421try x body = 1436try x body =
1422 case functorToEither x of 1437 case functorToEither x of
@@ -3155,3 +3170,9 @@ toCTimeSpec t = CTimeSpec (CTime sec) (truncate $ 10^(9::Int) * frac)
3155foreign import ccall unsafe "futimens" 3170foreign import ccall unsafe "futimens"
3156 c_futimens :: CInt -> Ptr CTimeSpec -> IO CInt 3171 c_futimens :: CInt -> Ptr CTimeSpec -> IO CInt
3157#endif 3172#endif
3173
3174onionNameForContact :: KeyKey -> KeyDB -> Maybe String
3175onionNameForContact kk db = do
3176 contact <- Map.lookup kk db
3177 let (_,(name:_,_)) = getHostnames contact
3178 return $ Char8.unpack name