Hi,

I apologize in advance if I am being brain-dead here.
I am trying to figure out how to enable a read and
write callback for SSL_accept/SSL_read/SSL_write. This
seems like it should be a fairly straight forward
procedure. That said, I have gone through the BIO
code, as well as the SSL write code, poured through
the lists, etc... I just simply can't see it.

So, what I am trying to do is wrap the SSL Record
layer with header info. When the SSL lib calls a bio
read (in SSL_accept, or SSL_read), I want to intercept
it, strip off the wrapper, and pass it on. And when
the SSL lib writes (in SSL_accept or SSL_write) I want
to intercept the call, wrap it, and send it on its
way. Arguably a quintessential use of a callback,
right? (or maybe of a filter). 

Well, just to add one more layer of complexity, I MUST
make callbacks myself to send and receive I/O. I don't
have a descriptor to work with, or a buffer of memory.
I just have a context and callbacks to get data from
the server. In fact, if the data is sent or received
during the handshake, I have a callback to get data
off the wire directly. However, after the handshake, I
must use a buffered system.

The callbacks are straight forward enough (see below),
but I just cannot see the how the interaction with BIO
works. For instance, should this be a filter? And if
it is a filter, how would the sink change look like
from the handshake to application data. Because I am
not working with sockets here, I don't think the
filter will work. I think I need a sink. Does that
make sense? But if I need to make a sink, what types
do I use?

Here are the basic callbacks.

my_read_one(MySpecialCtx ctx, Buf * buf, int len, ...)
{
        get the data from my special ctx pointers (via
socket)
        parse out the wrapper,
        copy the data into the buf and len
)
my_read_two(MySpecialCtx ctx, Buf * buf, int len, ...)
{
        get the data from my special ctx pointers (via
memcpy)
        parse out the wrapper,
        copy the data into the buf and len
)

Some thoughts on code to create a sink are:

create my own bio methods one for the memcpy and one
for the callback?
/* callback method */
static BIO_METHOD methods_myCbMethod={
        BIO_TYPE_SOCKET,        "my socket",
        my_cb_sock_write,
        my_cb_sock_read,
        NULL,   NULL, /* sock_gets, */  NULL,
        sock_new, /* do i need these? */ sock_free,
        NULL,   };
static BIO_METHOD methods_myMemMethod ={
        ... my_mem_sock_* }

Is it OK do define only read and write? What about
name and type? and then create the functions,
following the crypto\bio\bss_*.c files? Is this the
correct path to go down? Or is there some simpler way
to just register a callback to get data?

If it is the correct path, can I steal a bio type of
BIO_TYPE_SOCKET, or do I have to create my own? 

Any help will be greatly appreciated. 

Sincerely,
-z

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to