diff options
author | joe <joe@jerkface.net> | 2014-07-31 22:04:42 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-07-31 22:04:42 -0400 |
commit | b08068c787f8f69271cd7d9f7480e88a988acbff (patch) | |
tree | 988fb8473d2195b1868dc738801fde6444a99c24 /KeyRing.hs | |
parent | 1e92b09448a61b715b8a7394ede0062d5a2efb45 (diff) |
init-key command
Diffstat (limited to 'KeyRing.hs')
-rw-r--r-- | KeyRing.hs | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 | ||
91 | import System.Environment | 99 | import 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 | ||
1428 | unconditionally :: IO (KikiCondition a) -> IO a | ||
1429 | unconditionally action = do | ||
1430 | r <- action | ||
1431 | case r of | ||
1432 | KikiSuccess x -> return x | ||
1433 | e -> error $ errorString e | ||
1434 | |||
1420 | try :: Monad m => KikiCondition a -> (a -> m (KikiCondition b)) -> m (KikiCondition b) | 1435 | try :: Monad m => KikiCondition a -> (a -> m (KikiCondition b)) -> m (KikiCondition b) |
1421 | try x body = | 1436 | try 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) | |||
3155 | foreign import ccall unsafe "futimens" | 3170 | foreign 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 | |||
3174 | onionNameForContact :: KeyKey -> KeyDB -> Maybe String | ||
3175 | onionNameForContact kk db = do | ||
3176 | contact <- Map.lookup kk db | ||
3177 | let (_,(name:_,_)) = getHostnames contact | ||
3178 | return $ Char8.unpack name | ||