diff options
author | Michael Vetter <jubalh@iodoru.org> | 2018-09-04 13:19:23 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2018-09-05 11:31:33 +0200 |
commit | dcc249a616d9efe48d56a1ad5f86d178e824f6c1 (patch) | |
tree | 5c1749533a901e8a1567cf6371b3a5c7e6582406 /src | |
parent | 82f77a92858cc265b83a064907b8f778962bd7a9 (diff) | |
download | profani-tty-dcc249a616d9efe48d56a1ad5f86d178e824f6c1.tar.gz |
Use libstrophe sha1 functions
Using libstrophes sha1 functions in p_sha1_hash() to get rid of the p_sha1.c dependency. Relates to https://github.com/boothj5/profanity/issues/882
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/common.c b/src/common.c index 164523a2..a4120e9b 100644 --- a/src/common.c +++ b/src/common.c @@ -55,7 +55,7 @@ #include "log.h" #include "common.h" -#include "tools/p_sha1.h" +#include <strophe.h> struct curl_data_t { @@ -333,17 +333,16 @@ release_is_new(char *found_version) char* p_sha1_hash(char *str) { - P_SHA1_CTX ctx; - uint8_t digest[20]; - uint8_t *input = (uint8_t*)malloc(strlen(str) + 1); - memcpy(input, str, strlen(str) + 1); + unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE); + assert(digest != NULL); - P_SHA1_Init(&ctx); - P_SHA1_Update(&ctx, input, strlen(str)); - P_SHA1_Final(&ctx, digest); + xmpp_sha1_digest((unsigned char*)str, strlen(str), digest); - free(input); - return g_base64_encode(digest, sizeof(digest)); + char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE); + assert(b64 != NULL); + free(digest); + + return b64; } static size_t |