mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-22 19:45:54 -04:00
Use libgcrypt instead of libgnutls for SHA1 hashing
This commit is contained in:
parent
1f88ca5032
commit
3c5a73d29e
@ -122,8 +122,7 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
|
|||||||
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
|
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
|
||||||
PKG_CHECK_MODULES([curl], [libcurl], [],
|
PKG_CHECK_MODULES([curl], [libcurl], [],
|
||||||
[AC_MSG_ERROR([libcurl is required for profanity])])
|
[AC_MSG_ERROR([libcurl is required for profanity])])
|
||||||
PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.8.0], [],
|
AX_LIB_GCRYPT([yes])
|
||||||
[AC_MSG_ERROR([gnutls is required for profanity])])
|
|
||||||
|
|
||||||
AS_IF([test "x$PLATFORM" = xosx], [LIBS="$LIBS -lcurl"])
|
AS_IF([test "x$PLATFORM" = xosx], [LIBS="$LIBS -lcurl"])
|
||||||
|
|
||||||
@ -219,9 +218,9 @@ AC_CHECK_HEADERS([ncurses.h], [], [])
|
|||||||
AM_CFLAGS="-Wall -Wno-deprecated-declarations"
|
AM_CFLAGS="-Wall -Wno-deprecated-declarations"
|
||||||
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
|
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
|
||||||
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
|
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $LIBGNUTLS_CFLAGS"
|
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $GCRYPT_CFLAGS"
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
|
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
|
||||||
LIBS="$LIBS $glib_LIBS $curl_LIBS $libnotify_LIBS $LIBGNUTLS_LIBS"
|
LIBS="$LIBS $glib_LIBS $curl_LIBS $libnotify_LIBS $GCRYPT_LIBS"
|
||||||
|
|
||||||
AC_SUBST(AM_CFLAGS)
|
AC_SUBST(AM_CFLAGS)
|
||||||
AC_SUBST(AM_CPPFLAGS)
|
AC_SUBST(AM_CPPFLAGS)
|
||||||
|
17
src/common.c
17
src/common.c
@ -31,8 +31,7 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/easy.h>
|
#include <curl/easy.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gnutls/gnutls.h>
|
#include <gcrypt.h>
|
||||||
#include <gnutls/crypto.h>
|
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -393,16 +392,12 @@ generate_unique_id(char *prefix)
|
|||||||
char *
|
char *
|
||||||
sha1_hash(char *str)
|
sha1_hash(char *str)
|
||||||
{
|
{
|
||||||
gnutls_hash_hd_t dig;
|
int msg_length = strlen(str);
|
||||||
gnutls_digest_algorithm_t algorithm = GNUTLS_DIG_SHA1;
|
int hash_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
|
||||||
|
unsigned char hash[ hash_length ];
|
||||||
|
gcry_md_hash_buffer(GCRY_MD_SHA1, hash, str, msg_length);
|
||||||
|
|
||||||
gnutls_hash_init(&dig, algorithm);
|
return g_base64_encode(hash, sizeof(hash));
|
||||||
gnutls_hash(dig, str, strlen(str));
|
|
||||||
|
|
||||||
unsigned char output[20];
|
|
||||||
gnutls_hash_output(dig, output);
|
|
||||||
|
|
||||||
return g_base64_encode(output, sizeof(output));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gnutls/gnutls.h>
|
|
||||||
|
|
||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
#include "chat_session.h"
|
#include "chat_session.h"
|
||||||
@ -258,7 +257,6 @@ _init(const int disable_tls, char *log_level)
|
|||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
// ignore SIGPIPE
|
// ignore SIGPIPE
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
gnutls_global_init();
|
|
||||||
_create_directories();
|
_create_directories();
|
||||||
log_level_t prof_log_level = log_level_from_string(log_level);
|
log_level_t prof_log_level = log_level_from_string(log_level);
|
||||||
prefs_load();
|
prefs_load();
|
||||||
@ -307,7 +305,6 @@ _shutdown(void)
|
|||||||
accounts_close();
|
accounts_close();
|
||||||
cmd_uninit();
|
cmd_uninit();
|
||||||
log_close();
|
log_close();
|
||||||
gnutls_global_deinit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user