Skip to content

Commit 5613e66

Browse files
authored
Fix build when using latest arduino-esp32 master due to IDF update (me-no-dev#999)
* Fix build when using latest arduino-esp32 master due to IDF update espressif/arduino-esp32@a618fc1 * Fix build when using WebSockets
1 parent 2f78426 commit 5613e66

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/AsyncWebSocket.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@
2424
#include <libb64/cencode.h>
2525

2626
#ifndef ESP8266
27-
extern "C" {
28-
typedef struct {
29-
uint32_t state[5];
30-
uint32_t count[2];
31-
unsigned char buffer[64];
32-
} SHA1_CTX;
33-
34-
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
35-
void SHA1Init(SHA1_CTX* context);
36-
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
37-
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
38-
}
27+
#include "mbedtls/sha1.h"
3928
#else
4029
#include <Hash.h>
4130
#endif
@@ -1268,10 +1257,12 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket
12681257
sha1(key + WS_STR_UUID, hash);
12691258
#else
12701259
(String&)key += WS_STR_UUID;
1271-
SHA1_CTX ctx;
1272-
SHA1Init(&ctx);
1273-
SHA1Update(&ctx, (const unsigned char*)key.c_str(), key.length());
1274-
SHA1Final(hash, &ctx);
1260+
mbedtls_sha1_context ctx;
1261+
mbedtls_sha1_init(&ctx);
1262+
mbedtls_sha1_starts_ret(&ctx);
1263+
mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length());
1264+
mbedtls_sha1_finish_ret(&ctx, hash);
1265+
mbedtls_sha1_free(&ctx);
12751266
#endif
12761267
base64_encodestate _state;
12771268
base64_init_encodestate(&_state);

src/WebAuthentication.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
7171
memset(_buf, 0x00, 16);
7272
#ifdef ESP32
7373
mbedtls_md5_init(&_ctx);
74-
mbedtls_md5_starts(&_ctx);
75-
mbedtls_md5_update(&_ctx, data, len);
76-
mbedtls_md5_finish(&_ctx, _buf);
74+
mbedtls_md5_starts_ret(&_ctx);
75+
mbedtls_md5_update_ret(&_ctx, data, len);
76+
mbedtls_md5_finish_ret(&_ctx, _buf);
7777
#else
7878
MD5Init(&_ctx);
7979
MD5Update(&_ctx, data, len);

0 commit comments

Comments
 (0)