Questions on internal-buffers being used

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions on internal-buffers being used

Ajay Garg
Hi All.


a)
In the call,
                      int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);

are internal-buffers malloc'ed for each of "bio1" and "bio2"?
If yes, is there a way to pass buffers from the application-layer?
I ask this, because not all systems possess dynamic-memory allocation (or at least "malloc" is not available on all systems).

b)
Irrespective of the values of "writebuf1" and "writebuf2" in a), I see that everything works perfect.
So, there's got to be some internal-buffer that manages the complete ssl-packet, most probably instantiated via the call

BIO* BIO_new(BIO_f_ssl());

Here too, is it possible to pass the buffer from application-layer (because of same reasons as above)?


Will be grateful for pointers.

Thanks and Regards,
Ajay

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Questions on internal-buffers being used

Benjamin Kaduk
On 10/11/2016 02:06 PM, Ajay Garg wrote:
Hi All.


a)
In the call,
                      int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);

are internal-buffers malloc'ed for each of "bio1" and "bio2"?
If yes, is there a way to pass buffers from the application-layer?
I ask this, because not all systems possess dynamic-memory allocation (or at least "malloc" is not available on all systems).

b)
Irrespective of the values of "writebuf1" and "writebuf2" in a), I see that everything works perfect.
So, there's got to be some internal-buffer that manages the complete ssl-packet, most probably instantiated via the call

                      BIO* BIO_new(BIO_f_ssl());

Here too, is it possible to pass the buffer from application-layer (because of same reasons as above)?


You should be able to produce the desired effect with BIO_new_mem_buf() (twice) and attaching the resulting BIOs to each other with BIO_make_bio_pair().

-Ben

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Questions on internal-buffers being used

Ajay Garg
Thanks Ben for the reply.

I tried the following, and the code hits the block as commented ::


###########################################################################
static char inter_bio_buf[1000];
static char network_bio_buf[1000];

{
        BIO *inter_bio_buf_bio = NULL, *network_bio_buf_bio = NULL;

        inter_bio_buf_bio = BIO_new_mem_buf(inter_bio_buf, sizeof(inter_bio_buf));
        if(inter_bio_buf_bio == NULL)
        {
            /* Control does not reach here. */
        }

        network_bio_buf_bio = BIO_new_mem_buf(network_bio_buf, sizeof(network_bio_buf));
        if(network_bio_buf_bio == NULL)
        {
            /* Control does not reach here. */
        }

        if(!BIO_make_bio_pair(inter_bio_buf_bio, network_bio_buf_bio))
        {
            /* CONTROL REACHES HERE. */
        }
}
############################################################################

What am I doing wrong?

On Wed, Oct 12, 2016 at 12:59 AM, Benjamin Kaduk <[hidden email]> wrote:
On 10/11/2016 02:06 PM, Ajay Garg wrote:
Hi All.


a)
In the call,
                      int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);

are internal-buffers malloc'ed for each of "bio1" and "bio2"?
If yes, is there a way to pass buffers from the application-layer?
I ask this, because not all systems possess dynamic-memory allocation (or at least "malloc" is not available on all systems).

b)
Irrespective of the values of "writebuf1" and "writebuf2" in a), I see that everything works perfect.
So, there's got to be some internal-buffer that manages the complete ssl-packet, most probably instantiated via the call

                      BIO* BIO_new(BIO_f_ssl());

Here too, is it possible to pass the buffer from application-layer (because of same reasons as above)?


You should be able to produce the desired effect with BIO_new_mem_buf() (twice) and attaching the resulting BIOs to each other with BIO_make_bio_pair().

-Ben

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users




--
Regards,
Ajay

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Questions on internal-buffers being used

Benjamin Kaduk
Showing the contents of the error queue would help, but it seems most likely that what is going on is that I overlooked the fact that BIO_new_mem_buf() makes a read-only BIO.  I'm not sure offhand that there's a way to get a writeable BIO using application-supplied buffers; maybe someone else on the list knows.

-Ben

On 10/13/2016 05:04 AM, Ajay Garg wrote:
Thanks Ben for the reply.

I tried the following, and the code hits the block as commented ::


###########################################################################
static char inter_bio_buf[1000];
static char network_bio_buf[1000];

{
        BIO *inter_bio_buf_bio = NULL, *network_bio_buf_bio = NULL;

        inter_bio_buf_bio = BIO_new_mem_buf(inter_bio_buf, sizeof(inter_bio_buf));
        if(inter_bio_buf_bio == NULL)
        {
            /* Control does not reach here. */
        }

        network_bio_buf_bio = BIO_new_mem_buf(network_bio_buf, sizeof(network_bio_buf));
        if(network_bio_buf_bio == NULL)
        {
            /* Control does not reach here. */
        }

        if(!BIO_make_bio_pair(inter_bio_buf_bio, network_bio_buf_bio))
        {
            /* CONTROL REACHES HERE. */
        }
}
############################################################################

What am I doing wrong?

On Wed, Oct 12, 2016 at 12:59 AM, Benjamin Kaduk <[hidden email]> wrote:
On 10/11/2016 02:06 PM, Ajay Garg wrote:
Hi All.


a)
In the call,
                      int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2);

are internal-buffers malloc'ed for each of "bio1" and "bio2"?
If yes, is there a way to pass buffers from the application-layer?
I ask this, because not all systems possess dynamic-memory allocation (or at least "malloc" is not available on all systems).

b)
Irrespective of the values of "writebuf1" and "writebuf2" in a), I see that everything works perfect.
So, there's got to be some internal-buffer that manages the complete ssl-packet, most probably instantiated via the call

                      BIO* BIO_new(BIO_f_ssl());

Here too, is it possible to pass the buffer from application-layer (because of same reasons as above)?


You should be able to produce the desired effect with BIO_new_mem_buf() (twice) and attaching the resulting BIOs to each other with BIO_make_bio_pair().

-Ben

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users




--
Regards,
Ajay




--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users