Merge branch 'master' into otrsmp
Conflicts: install-all.sh
This commit is contained in:
17
src/common.c
17
src/common.c
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user