tlse icon indicating copy to clipboard operation
tlse copied to clipboard

Examples: tlshelloworld.c, tls_read or recv?

Open Velho opened this issue 2 years ago • 1 comments

Greetings!

I was going through the examples and I noticed that the tlshelloworld.c does not make use of the tls_read nor tls_write, should these be used to populate the application buffer or is the tls consume stream enough?

Thanks!

Velho avatar Jul 24 '23 19:07 Velho

Hello!

tls_read and tls_write work on the TLS buffer itself. tls_consume_stream writes the protocol bytes to the internal TLS buffer (after deciphering, validating and authorizing). So, we should have: recv => tls_consume_stream and then tls_read. Same way we use tls_write to write actual payload data. Then use tls_get_write_buffer to get the actual TLS bytes to write on the socket (or any other medium).

It should be also safe to use tls_write while calling tls_consume_stream (reading).

SSL_read and SSL_write are performing both socket I/O and TLS protocol I/O using recv, tls_read, send and tls_write.

Thank you!

eduardsui avatar Jul 25 '23 16:07 eduardsui