diff options
-rw-r--r-- | src/plugins/relay/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/relay/Makefile.am | 4 | ||||
-rw-r--r-- | src/plugins/relay/relay-websocket.c | 22 |
3 files changed, 13 insertions, 14 deletions
diff --git a/src/plugins/relay/CMakeLists.txt b/src/plugins/relay/CMakeLists.txt index e83fba09a..b8e613b1b 100644 --- a/src/plugins/relay/CMakeLists.txt +++ b/src/plugins/relay/CMakeLists.txt @@ -41,7 +41,6 @@ set_target_properties(relay PROPERTIES PREFIX "") set(LINK_LIBS) list(APPEND LINK_LIBS ${ZLIB_LIBRARY}) -list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS}) if(GNUTLS_FOUND) include_directories(${GNUTLS_INCLUDE_PATH}) diff --git a/src/plugins/relay/Makefile.am b/src/plugins/relay/Makefile.am index b7078856a..e2be35fd1 100644 --- a/src/plugins/relay/Makefile.am +++ b/src/plugins/relay/Makefile.am @@ -17,7 +17,7 @@ # along with WeeChat. If not, see <https://www.gnu.org/licenses/>. # -AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(ZLIB_CFLAGS) $(GCRYPT_CFLAGS) $(GNUTLS_CFLAGS) +AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(ZLIB_CFLAGS) $(GNUTLS_CFLAGS) libdir = ${weechat_libdir}/plugins @@ -59,6 +59,6 @@ relay_la_SOURCES = relay.c \ relay-websocket.h relay_la_LDFLAGS = -module -no-undefined -relay_la_LIBADD = $(RELAY_LFLAGS) $(ZLIB_LFLAGS) $(GCRYPT_LFLAGS) $(GNUTLS_LFLAGS) +relay_la_LIBADD = $(RELAY_LFLAGS) $(ZLIB_LFLAGS) $(GNUTLS_LFLAGS) EXTRA_DIST = CMakeLists.txt diff --git a/src/plugins/relay/relay-websocket.c b/src/plugins/relay/relay-websocket.c index f3d5bbf0b..dfcbc011b 100644 --- a/src/plugins/relay/relay-websocket.c +++ b/src/plugins/relay/relay-websocket.c @@ -23,7 +23,6 @@ #include <unistd.h> #include <stdio.h> #include <string.h> -#include <gcrypt.h> #include "../weechat-plugin.h" #include "relay.h" @@ -188,10 +187,8 @@ char * relay_websocket_build_handshake (struct t_relay_client *client) { const char *sec_websocket_key; - char *key, sec_websocket_accept[128], handshake[1024]; - unsigned char *result; - gcry_md_hd_t hd; - int length; + char *key, sec_websocket_accept[128], handshake[1024], *hash; + int length, length_hash; sec_websocket_key = weechat_hashtable_get (client->http_headers, "sec-websocket-key"); @@ -210,17 +207,20 @@ relay_websocket_build_handshake (struct t_relay_client *client) snprintf (key, length, "%s%s", sec_websocket_key, WEBSOCKET_GUID); /* compute 160-bit SHA1 on the key and encode it with base64 */ - gcry_md_open (&hd, GCRY_MD_SHA1, 0); - length = gcry_md_get_algo_dlen (GCRY_MD_SHA1); - gcry_md_write (hd, key, strlen (key)); - result = gcry_md_read (hd, GCRY_MD_SHA1); - if (weechat_string_base_encode (64, (char *)result, length, + weechat_string_hash_binary (key, strlen (key), "sha1", + &hash, &length_hash); + if (!hash) + { + free (key); + return NULL; + } + if (weechat_string_base_encode (64, hash, length_hash, sec_websocket_accept) < 0) { sec_websocket_accept[0] = '\0'; } - gcry_md_close (hd); + free (hash); free (key); /* build the handshake (it will be sent as-is to client) */ |