1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 06:46:38 +02:00

core: move crypto functions to wee-crypto.c, rename API function string_hash to crypto_hash

This commit is contained in:
Sébastien Helleu
2020-03-01 18:02:39 +01:00
parent c4ef3d6c2e
commit 9a6a27ef58
32 changed files with 1094 additions and 1017 deletions
-53
View File
@@ -32,7 +32,6 @@ extern "C"
#include <string.h>
#include <regex.h>
#include "tests/tests.h"
#include "tests/unit/core/test-core.h"
#include "src/core/weechat.h"
#include "src/core/wee-string.h"
#include "src/core/wee-hashtable.h"
@@ -108,27 +107,6 @@ extern "C"
STRCMP_EQUAL(__result, str); \
free (str);
#define WEE_CHECK_HASH(__result_code, __result_hash, \
__data, __data_size, __hash_algo) \
if (__result_hash) \
{ \
hash_size_expected = string_base16_decode (__result_hash, \
hash_expected); \
} \
else \
{ \
hash_size_expected = 0; \
} \
hash_size = -1; \
LONGS_EQUAL(__result_code, \
string_hash (__data, __data_size, __hash_algo, \
hash, &hash_size)); \
if (__result_hash) \
{ \
MEMCMP_EQUAL(hash_expected, hash, hash_size); \
} \
LONGS_EQUAL(hash_size_expected, hash_size);
extern struct t_hashtable *string_hashtable_shared;
TEST_GROUP(CoreString)
@@ -1932,37 +1910,6 @@ TEST(CoreString, Hex_dump)
str);
}
/*
* Tests functions:
* string_hash
*/
TEST(CoreString, Hash)
{
const char *data = DATA_HASH;
char hash_expected[4096], hash[4096];
int data_size, hash_size_expected, hash_size;
data_size = strlen (data);
WEE_CHECK_HASH(0, NULL, NULL, 0, NULL);
WEE_CHECK_HASH(0, NULL, DATA_HASH, 0, NULL);
WEE_CHECK_HASH(0, NULL, DATA_HASH, data_size, NULL);
WEE_CHECK_HASH(0, NULL, DATA_HASH, data_size, "not_an_algo");
WEE_CHECK_HASH(1, DATA_HASH_CRC32, data, data_size, "crc32");
WEE_CHECK_HASH(1, DATA_HASH_MD5, data, data_size, "md5");
WEE_CHECK_HASH(1, DATA_HASH_SHA1, data, data_size, "sha1");
WEE_CHECK_HASH(1, DATA_HASH_SHA224, data, data_size, "sha224");
WEE_CHECK_HASH(1, DATA_HASH_SHA256, data, data_size, "sha256");
WEE_CHECK_HASH(1, DATA_HASH_SHA384, data, data_size, "sha384");
WEE_CHECK_HASH(1, DATA_HASH_SHA512, data, data_size, "sha512");
WEE_CHECK_HASH(1, DATA_HASH_SHA3_224, data, data_size, "sha3-224");
WEE_CHECK_HASH(1, DATA_HASH_SHA3_256, data, data_size, "sha3-256");
WEE_CHECK_HASH(1, DATA_HASH_SHA3_384, data, data_size, "sha3-384");
WEE_CHECK_HASH(1, DATA_HASH_SHA3_512, data, data_size, "sha3-512");
}
/*
* Tests functions:
* string_is_command_char