Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit edabf22

Browse files
authored
Fix compile error
Fix deprecated functions superseded from mbed TLS v2.7.0 - mbedtls_md5_starts() - mbedtls_md5_update() - mbedtls_md5_finish() leading to following compiling error ``` /home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o:(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts' /home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o: in function `getMD5(unsigned char*, unsigned short, char*)': /home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/WebAuthentication.cpp:73: undefined reference to `mbedtls_md5_starts' collect2: error: ld returned 1 exit status exit status 1 Error compiling for board ESP32S2 Dev Module. ```
1 parent fbf2e1a commit edabf22

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/WebAuthentication.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <libb64/cencode.h>
2323
#ifdef ESP32
2424
#include "mbedtls/md5.h"
25+
#include "mbedtls/version.h"
2526
#else
2627
#include "md5.h"
2728
#endif
@@ -71,9 +72,16 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
7172
memset(_buf, 0x00, 16);
7273
#ifdef ESP32
7374
mbedtls_md5_init(&_ctx);
74-
mbedtls_md5_starts(&_ctx);
75-
mbedtls_md5_update(&_ctx, data, len);
76-
mbedtls_md5_finish(&_ctx, _buf);
75+
#if (MBEDTLS_VERSION_NUMBER < 0x02070000)
76+
// Superseded from v2.7.0
77+
mbedtls_md5_starts(&_ctx);
78+
mbedtls_md5_update(&_ctx, data, len);
79+
mbedtls_md5_finish(&_ctx, _buf);
80+
#else
81+
mbedtls_md5_starts_ret(&_ctx);
82+
mbedtls_md5_update_ret(&_ctx, data, len);
83+
mbedtls_md5_finish_ret(&_ctx, _buf);
84+
#endif
7785
#else
7886
MD5Init(&_ctx);
7987
MD5Update(&_ctx, data, len);

0 commit comments

Comments
 (0)