Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request civetweb#1072 from guitargeek/openssl_deprecation_1
Browse files Browse the repository at this point in the history
Using higher-level wrapper of OpenSSL SHA1 hash function
  • Loading branch information
bel2125 authored Apr 13, 2022
2 parents 6dc8388 + 6bf1a49 commit f0ab2c5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/civetweb.c
Original file line number Diff line number Diff line change
Expand Up @@ -12991,7 +12991,6 @@ send_websocket_handshake(struct mg_connection *conn, const char *websock_key)
static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
char buf[100], sha[20], b64_sha[sizeof(sha) * 2];
size_t dst_len = sizeof(b64_sha);
SHA_CTX sha_ctx;
int truncated;

/* Calculate Sec-WebSocket-Accept reply from Sec-WebSocket-Key. */
Expand All @@ -13003,9 +13002,8 @@ send_websocket_handshake(struct mg_connection *conn, const char *websock_key)

DEBUG_TRACE("%s", "Send websocket handshake");

SHA1_Init(&sha_ctx);
SHA1_Update(&sha_ctx, (unsigned char *)buf, (uint32_t)strlen(buf));
SHA1_Final((unsigned char *)sha, &sha_ctx);
EVP_Digest((unsigned char *)buf, (uint32_t)strlen(buf), (unsigned char *)sha,
NULL, EVP_get_digestbyname("sha1"), NULL);
mg_base64_encode((unsigned char *)sha, sizeof(sha), b64_sha, &dst_len);
mg_printf(conn,
"HTTP/1.1 101 Switching Protocols\r\n"
Expand Down

0 comments on commit f0ab2c5

Please sign in to comment.