Limit record size in OpenSSL

2.3k Views Asked by At

I need to implement TLS on an embedded device with an OpenSSL client running on a normal computer. The data transfers are limited to less than 1 kB at a time. I have been looking at mbedtls and it is possible to limit the record buffer to 2 kB to save memory, however the standard TLS record can be up to 16 kB. Is it possible to limit the record size in TLS or at the very least require each SSL_write command to create its own record? Otherwise OpenSSL may concatenate the data and create a record that is too long to be received. I have complete control over both ends of the connection so there shouldn't be any issues with compatibility.

1

There are 1 best solutions below

6
Davislor On

Try BIO_set_write_buffer_size(), but you should just be able to control how much you read or send at a time, and flush the BIO after each write.

Another strategy might be to create a memory BIO, and transmit the bytes of output it produces. You can’t control the maximum size of its buffer, but you should be able to control the chunk size manually that way.