Пример #1
0
extern "C" void iocba_close(
    void* tls_channel
    )
{
    Botan::TLS::Channel* channel = (Botan::TLS::Channel*) tls_channel;
    try{
        channel->close();
    } catch (...)
    {
        printf("BotanTLS engine raised exception on close\n");
    }
}
Пример #2
0
extern "C" DLL_PUBLIC void iocba_close(
    buffers_t* buffers,
    char* out_enc_to_send,
    uint32_t *enc_to_send_length
    )
{
    // TRACE("Close called on buffer_t* %p\n", buffers);
    Botan::TLS::Channel* channel = buffers->channel;
    buffers -> enc_cursor = out_enc_to_send;
    buffers -> enc_end    = out_enc_to_send + *enc_to_send_length;
    // No waiting cleartext data in this context
    buffers -> clr_cursor = 0;
    buffers -> clr_end    = 0;
    try{
        channel->close();
    }
    catch (buffer_override_exception_t const& e)
    {
        TRACE("Buffer override at iocba_close!!\n");
        return ;
    }
    catch (Botan::TLS::TLS_Exception const& e)
    {
        if (e.type() == Botan::TLS::Alert::INAPPROPRIATE_FALLBACK)
        {
            TRACE("BotanTLS engine (close) instance likely crashed before: %s \n", e.what());
            return ;
        } else
        {
            TRACE("BotanTLS engine  (close) instance crashed (normal if ALPN didn't go well): %s \n", e.what());
            return ;
        }
    }
    catch (std::exception const& e)
    {
        // TODO: control messages
        //TRACE("BotanTLS engine crashed with generic exception: %s \n", e.what());
        return ;
    }catch (...)
    {
        TRACE("BotanTLS engine raised exception on close\n");
    }
    *enc_to_send_length = (uint32_t) (
        buffers -> enc_cursor
        - out_enc_to_send );
    buffers -> clear_cursors();
}