Porting mbedTLS basic questions

06 Apr 2019

Hi, guys, I am porting the mbedTLS library to a 32-bit MCU platform. My particular project involves a cellular socket modem and I am not sure exactly how to write the bio callbacks. The TCP/IP stack is inside the cellular module. All I have to do is send TCP payload to an IP address with a port number. On the receiving side, I get source IP, source port and TCP payload.

Here are my questions:

1. What is the difference between callback type mbedtls_ssl_recv_t and mbedtls_ssl_recv_timeout_t? Do I need both? If the library can perform timeout, how do I provide "tick" callback to the library?

2. My TCP data is sent/received via a 115200-bps serial channel. What do I need to do in the send callback function when the serial transmit is not ready, e.g., still busy sending the previous frame? Can I keep returning MBEDTLS_ERR_SSL_WANT_WRITE until the buffer is free?

Thanks!

22 Sep 2019

Hi Alan,

1. the difference between mbedtls_ssl_recv_t and mbedtls_ssl_recv_timeout_t is, as named, the latter has a timeout. You don't need both, and the f_recv callback will be called only if f_recv_timeout is NULL. However, note that you might get into a blocking state, if you don't use a timeout, and in DTLS this would be problematic.

2. What you are describing here is basically non blocking IO. In the case where the send callback is busy, is with wait and block, or, preferebly, return MBEDTLS_ERR_SSL_WANT_WRITE in which the application should try and send the same data again, as you can see in the networking example.

Regards,

Mbed TLS Support

Ron