Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This program is free software: you can redistribute it and/or modify
#include "lwip/tcp.h" // for the netconn structure
#include "esp_system.h" // for esp_random
#include "mbedtls/base64.h"
#include "mbedtls/sha1.h"
#include "mbedtls/md.h"
#include <string.h>

ws_client_t ws_connect_client(struct netconn* conn,
Expand Down Expand Up @@ -310,7 +310,8 @@ char* ws_hash_handshake(char* handshake,uint8_t len) {

memcpy(key,handshake,len);
strlcpy(&key[len],hash,sizeof(key));
mbedtls_sha1((unsigned char*)key,len+hash_len-1,sha1sum);
const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA1);
mbedtls_md(md_info, (unsigned char*)key, len+hash_len-1, sha1sum);
mbedtls_base64_encode(NULL, 0, &ret_len, sha1sum, 20);
if(!mbedtls_base64_encode((unsigned char*)ret,32,&ret_len,sha1sum,20)) {
ret[ret_len] = '\0';
Expand Down