Fix build when using latest arduino-esp32 master due to IDF update (#999)

* Fix build when using latest arduino-esp32 master due to IDF update
a618fc1361

* Fix build when using WebSockets
This commit is contained in:
JDavid 2021-07-26 12:40:52 -05:00 committed by GitHub
parent 2f784268f0
commit 5613e66f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 19 deletions

View File

@ -24,18 +24,7 @@
#include <libb64/cencode.h>
#ifndef ESP8266
extern "C" {
typedef struct {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
}
#include "mbedtls/sha1.h"
#else
#include <Hash.h>
#endif
@ -1268,10 +1257,12 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket
sha1(key + WS_STR_UUID, hash);
#else
(String&)key += WS_STR_UUID;
SHA1_CTX ctx;
SHA1Init(&ctx);
SHA1Update(&ctx, (const unsigned char*)key.c_str(), key.length());
SHA1Final(hash, &ctx);
mbedtls_sha1_context ctx;
mbedtls_sha1_init(&ctx);
mbedtls_sha1_starts_ret(&ctx);
mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length());
mbedtls_sha1_finish_ret(&ctx, hash);
mbedtls_sha1_free(&ctx);
#endif
base64_encodestate _state;
base64_init_encodestate(&_state);

View File

@ -71,9 +71,9 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
memset(_buf, 0x00, 16);
#ifdef ESP32
mbedtls_md5_init(&_ctx);
mbedtls_md5_starts(&_ctx);
mbedtls_md5_update(&_ctx, data, len);
mbedtls_md5_finish(&_ctx, _buf);
mbedtls_md5_starts_ret(&_ctx);
mbedtls_md5_update_ret(&_ctx, data, len);
mbedtls_md5_finish_ret(&_ctx, _buf);
#else
MD5Init(&_ctx);
MD5Update(&_ctx, data, len);