8000 Fix build when using WebSockets · Compy/ESPAsyncWebServer@8a43124 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a43124

Browse files
committed
Fix build when using WebSockets
1 parent c7b7faf commit 8a43124

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
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);

0 commit comments

Comments
 (0)
0