Maybe my original question is to broad. I guess I will
just describe a path that i headed down and hopefully
get some input as to if it is the best way to go. Any
input would be greatly appreciated.

The problem is that I need to create a typical I/O
callback for OpenSSL. During the handshake I have a
pointer to a read and write function, and during
normal data transfer, I have a pointer to a buffer and
len that i can read from and write from. So, in trying
to solve this problem, here is what i have come up
with.
First, i created my own sink objects (for brevity, i
have listed only one, but in reality, i will have a
foo object for the handshake and a bar object for
encrypted data transfers - see code below).

#define BIO_TYPE_FOO  (46|0x0400|0x0100)

BIO_METHOD * BIO_s_foo(void) {
        return (&methods_foo);
}

BIO_METHOD methods_foo ={ 
        BIO_TYPE_FOO, "foo",
        foo_write, foo_read, NULL, NULL,
        foo_ctrl, foo_new, foo_free, NULL };

int foo_read(...) { reading by using the funkyCtx set
in ctrl() }
int foo_write(...) { same as write }
int foo_ctrl(...) { setting my funkyCtx with
BIO_C_SET_FD )
int foo_new(...) { allocating space for my funkyCtx }
int foo_free(...)

The interesting function is the ctrl function that I
enable the passing
of my special context when i create the method (much
like you pass a socket
into a BIO_s_socket() method).

So, then, I can make the following calls:

FOO_CTX *funkyFooCtx = (pointer to all of my needed
i/o info);
FOO_CTX *funkyBarCtx = (pointer to all of my needed
i/o info);

BIO * fooBio = BIO_new(BIO_s_foo());
BIO * barBio = BIO_new(BIO_s_bar());

BIO_set_fd(fooBio, funkyFooCtx, close_flag);
BIO_set_fd(barBio, funkyBarCtx, close_flag);

SSL_set_bio(conn, fooBio, fooBio);

SSL_accept(conn);

SSL_set_bio(conn, barBio, barBio);
SSL_read(conn, ..., ...);
SSL_write(conn, ..., ...);

Does this make sense, or is there some easier way to
do this that i am just not seeing?

Thank you for any help,
-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