Closed hn closed 11 months ago
Well, I think I found the issue. The PolarSSL MD5 context in LT is defined as follows:
typedef struct {
unsigned long total[2]; /*!< number of bytes processed */
unsigned long state[4]; /*!< intermediate digest state */
unsigned char buffer[64]; /*!< data block being processed */
} md5_context;
whereas the context in PolarSSL library is this:
typedef struct
{
uint32_t total[2]; /*!< number of bytes processed */
uint32_t state[4]; /*!< intermediate digest state */
unsigned char buffer[64]; /*!< data block being processed */
unsigned char ipad[64]; /*!< HMAC: inner padding */
unsigned char opad[64]; /*!< HMAC: outer padding */
}
md5_context;
Notice the missing ipad
and opad
fields, which make the structure smaller (thus, esphome allocates less memory for the context, and we have a memory corruption).
Set Mbed-TLS as default for MD5 hashing, remove Polar SSL. The latter has given wrong results on at least one MCU and is generally deprecated.
Closes issue #142.