lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] Mbedtls can't complete handshaking when the default setting


From: chen CJ
Subject: [lwip-devel] Mbedtls can't complete handshaking when the default settings of LWIP
Date: Wed, 31 Jan 2024 16:10:08 +0900

Summary: Mbedtls can't complete handshaking when the default settings of LWIP
Group: lwIP - A Lightweight TCP/IP stack
Submitter: cjchenigel
Category: None
Priority: 5 - Normal
Severity: 3 - Normal
Status: None
Privacy: Public

Fixed the handshake issue when the default settings of LWIP TCP_MSS=536 and TCP_WND=4*TCP_MSS are used.
In the function altcp_mbedtls_bio_send():
The original code 'u16_t write_len = (u16_t)LWIP_MIN(size_left, 0xFFFF);' could easily lead to an ERR_MEM error following altcp_write.
A more effective approach is to compare it with the value returned by altcp_sndbuf. This adjustment ensures that the write length exactly fits the currently available space. 
On the next round, the write_len would be 0, and the function returns the number of bytes that have been written. 
Additionally, there is a minor correction needed for the dataptr: it should be incremented by write_len for the next round.
In the function altcp_mbedtls_handle_rx_appldata: 
An attempt to complete the handshake should be made again, especially when TCP_MSS is not large, indicating that the handshake might not have been completed yet.
Fix proposed here: https://github.com/cjchenigel/lwip/compare/master...version/2.2.0

reply via email to

[Prev in Thread] Current Thread [Next in Thread]