1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into otrsmp

Conflicts:
	install-all.sh
This commit is contained in:
James Booth 2014-05-02 00:59:40 +01:00
commit aa0d4fe892
9 changed files with 103 additions and 22 deletions

View File

@ -122,6 +122,9 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])])
PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.8.0], [],
[AC_MSG_ERROR([gnutls is required for profanity])])
AS_IF([test "x$PLATFORM" = xosx], [LIBS="$LIBS -lcurl"])
### Check for desktop notification support
@ -216,9 +219,9 @@ AC_CHECK_HEADERS([ncurses.h], [], [])
AM_CFLAGS="-Wall -Wno-deprecated-declarations"
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS"
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $LIBGNUTLS_CFLAGS"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$LIBS $glib_LIBS $curl_LIBS $libnotify_LIBS"
LIBS="$LIBS $glib_LIBS $curl_LIBS $libnotify_LIBS $LIBGNUTLS_LIBS"
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)

View File

@ -24,7 +24,7 @@ debian_prepare()
echo
echo Profanity installer... installing dependencies
echo
sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev
sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libgnutls-dev
}
@ -36,7 +36,7 @@ fedora_prepare()
ARCH=`arch`
sudo yum -y install gcc git autoconf automake openssl-devel.$ARCH expat-devel.$ARCH ncurses-devel.$ARCH glib2-devel.$ARCH libnotify-devel.$ARCH libcurl-devel.$ARCH libXScrnSaver-devel.$ARCH libotr3-devel.$ARCH
sudo yum -y install gcc git autoconf automake openssl-devel.$ARCH expat-devel.$ARCH ncurses-devel.$ARCH glib2-devel.$ARCH libnotify-devel.$ARCH libcurl-devel.$ARCH libXScrnSaver-devel.$ARCH libotr3-devel.$ARCH gnutls-devel.$ARCH
}
opensuse_prepare()
@ -44,7 +44,7 @@ opensuse_prepare()
echo
echo Profanity installer...installing dependencies
echo
sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel
sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel libgnutls-devel
}
cygwin_prepare()
@ -59,9 +59,9 @@ cygwin_prepare()
mv apt-cyg /usr/local/bin/
if [ -n "$CYG_MIRROR" ]; then
apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel
apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel gnutls-devel
else
apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel
apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel gnutls-devel
fi

View File

@ -31,6 +31,8 @@
#include <curl/curl.h>
#include <curl/easy.h>
#include <glib.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include "log.h"
#include "common.h"
@ -388,6 +390,21 @@ generate_unique_id(char *prefix)
return result;
}
char *
sha1_hash(char *str)
{
gnutls_hash_hd_t dig;
gnutls_digest_algorithm_t algorithm = GNUTLS_DIG_SHA1;
gnutls_hash_init(&dig, algorithm);
gnutls_hash(dig, str, strlen(str));
unsigned char output[20];
gnutls_hash_output(dig, output);
return g_base64_encode(output, sizeof(output));
}
int
cmp_win_num(gconstpointer a, gconstpointer b)
{

View File

@ -88,6 +88,7 @@ const char * string_from_resource_presence(resource_presence_t presence);
resource_presence_t resource_presence_from_string(const char * const str);
contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence);
char * sha1_hash(char *str);
char * generate_unique_id(char *prefix);
int cmp_win_num(gconstpointer a, gconstpointer b);

View File

@ -31,6 +31,7 @@
#include <string.h>
#include <glib.h>
#include <gnutls/gnutls.h>
#include "profanity.h"
#include "chat_session.h"
@ -257,6 +258,7 @@ _init(const int disable_tls, char *log_level)
setlocale(LC_ALL, "");
// ignore SIGPIPE
signal(SIGPIPE, SIG_IGN);
gnutls_global_init();
_create_directories();
log_level_t prof_log_level = log_level_from_string(log_level);
prefs_load();
@ -305,6 +307,7 @@ _shutdown(void)
accounts_close();
cmd_uninit();
log_close();
gnutls_global_deinit();
}
static void

View File

@ -30,7 +30,6 @@
#include <string.h>
#include <glib.h>
#include <openssl/evp.h>
#include <strophe.h>
#include "common.h"
@ -203,20 +202,7 @@ caps_create_sha1_str(xmpp_stanza_t * const query)
curr = g_slist_next(curr);
}
EVP_MD_CTX mdctx;
const EVP_MD *md;
unsigned char md_value[EVP_MAX_MD_SIZE];
unsigned int md_len;
OpenSSL_add_all_digests();
md = EVP_get_digestbyname("SHA1");
EVP_MD_CTX_init(&mdctx);
EVP_DigestInit_ex(&mdctx, md, NULL);
EVP_DigestUpdate(&mdctx, s->str, strlen(s->str));
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
EVP_MD_CTX_cleanup(&mdctx);
char *result = g_base64_encode(md_value, md_len);
char *result = sha1_hash(s->str);
g_string_free(s, TRUE);
g_slist_free_full(identities, g_free);

File diff suppressed because one or more lines are too long

View File

@ -38,3 +38,11 @@ void test_dnd_is_valid_resource_presence_string(void **state);
void test_available_is_not_valid_resource_presence_string(void **state);
void test_unavailable_is_not_valid_resource_presence_string(void **state);
void test_blah_is_not_valid_resource_presence_string(void **state);
void test_sha1_hash1(void **state);
void test_sha1_hash2(void **state);
void test_sha1_hash3(void **state);
void test_sha1_hash4(void **state);
void test_sha1_hash5(void **state);
void test_sha1_hash6(void **state);
void test_sha1_hash6(void **state);
void test_sha1_hash7(void **state);

View File

@ -74,6 +74,13 @@ int main(int argc, char* argv[]) {
unit_test(test_available_is_not_valid_resource_presence_string),
unit_test(test_unavailable_is_not_valid_resource_presence_string),
unit_test(test_blah_is_not_valid_resource_presence_string),
unit_test(test_sha1_hash1),
unit_test(test_sha1_hash2),
unit_test(test_sha1_hash3),
unit_test(test_sha1_hash4),
unit_test(test_sha1_hash5),
unit_test(test_sha1_hash6),
unit_test(test_sha1_hash7),
unit_test(clear_empty),
unit_test(reset_after_create),