igrr / axtls-8266

axTLS port for ESP8266
Other
79 stars 33 forks source link

Added new ssl_want_read() function. #41

Closed diegopx closed 6 years ago

diegopx commented 7 years ago

A new function has been introduced to know if the receiver buffer has any information to be processed. The function delegates the check to the external environment through the new dependency ax_port_pending(). This later function should work similarly to the openssl's SSL_pending(), which returns the number of available bytes to be read from the rx stream, with the caveat that ax_port_pending() must not decrypt the data to compute the availability, i.e. the returned count may differ from openssl's implementation because of encryption padding. This simplification is important to avoid having an expensive operation just to check the state of the stream (both in time and memory).

Since ax_port_pending can't make any promises about the final count of decrypted bytes, ssl_want_read() only indicates whether there is any available information at all, which is enough for most situations.

Being able to check availability without touching the buffers makes controlling the half-duplex nature of axTLS easier.

diegopx commented 7 years ago

The failing build seems to be because the ESP8266WiFi library does not export ax_port_pending, which is logical since the pull request for that repo hasn't been accepted yet.