Update WebSockets.cpp

added esp32 hwcrypto for sha1
This commit is contained in:
Silver Kuusik
2017-07-30 00:21:13 +02:00
committed by GitHub
parent 4fc80871a6
commit 8c19d7ba48

View File

@ -38,6 +38,8 @@ extern "C" {
#ifdef ESP8266 #ifdef ESP8266
#include <Hash.h> #include <Hash.h>
#elif defined(ESP32)
#include <hwcrypto/sha.h>
#else #else
extern "C" { extern "C" {
@ -483,6 +485,9 @@ String WebSockets::acceptKey(String & clientKey) {
uint8_t sha1HashBin[20] = { 0 }; uint8_t sha1HashBin[20] = { 0 };
#ifdef ESP8266 #ifdef ESP8266
sha1(clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", &sha1HashBin[0]); sha1(clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", &sha1HashBin[0]);
#elif defined(ESP32)
String data = clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
esp_sha(SHA1, (unsigned char*)data.c_str(), data.length(), &sha1HashBin[0]);
#else #else
clientKey += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; clientKey += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
SHA1_CTX ctx; SHA1_CTX ctx;