signGPG :: MonadIO m =>
           BS.ByteString
        -> BS.ByteString
        -> m BS.ByteString
signGPG kid bs = liftIO $ do
    ctx <- Gpg.ctxNew Nothing
    keys <- Gpg.getKeys ctx True
    matches <- filterM (liftM (== Just kid) . Gpg.keyFingerprint) keys
    case matches of
        [] -> error "key does not exist" -- return Nothing
        (p:_) -> do
            sig <- Gpg.sign ctx bs p Gpg.SigModeDetach
            logDebug $ "Signing " ++ show bs ++ " yielded " ++ show sig
            return sig
signGPG :: MonadIO m =>
           BS.ByteString
        -> BS.ByteString
        -> m BS.ByteString
signGPG kid bs = liftIO $ do
    ctx <- Gpg.ctxNew Nothing
    keys <- Gpg.getKeys ctx True
    matches <- filterM (liftM (== Just kid) . Gpg.keyFingerprint) keys
    case matches of
        [] -> error "key does not exist" -- return Nothing
        (p:_) -> do
            sig <- Gpg.sign ctx bs p Gpg.SigModeDetach
            logDebug $ "Signing " ++ show bs ++ " yielded " ++ show sig
            return sig
signGPG kid bs = liftIO $ do
    ctx <- Gpg.ctxNew Nothing
    keys <- Gpg.getKeys ctx True
    matches <- filterM (liftM (== Just kid) . Gpg.keyFingerprint) keys
    case matches of
        [] -> error "key does not exist" -- return Nothing
        (p:_) -> do
            sig <- Gpg.sign ctx bs p Gpg.SigModeDetach
            logDebug $ "Signing " ++ show bs ++ " yielded " ++ show sig
            return sig