diff --git a/librz/arch/isa/ppc/ppc_il.h b/librz/arch/isa/ppc/ppc_il.h index dc14088b6a..5d3c6178c9 100644 --- a/librz/arch/isa/ppc/ppc_il.h +++ b/librz/arch/isa/ppc/ppc_il.h @@ -52,16 +52,16 @@ * \brief Rotates a 64bit value. Rotate \p x left by \p y bits. * \p y should be U8, \p x should be U32 and U64 respectively. */ -#define ROTL64(x, y) LET("rotl64_x", x, \ +#define PPC_IL_ROTL64(x, y) LET("rotl64_x", x, \ LET("rotl64_y", y, \ (LOGOR(SHIFTL0(VARLP("rotl64_x"), VARLP("rotl64_y")), SHIFTR0(VARLP("rotl64_x"), SUB(U8(64), UNSIGNED(8, VARLP("rotl64_y")))))))) /** * \brief Rotates a 32bit value. If the the VM is in 64bit mode "ROTL64(x||x, y)" is executed instead. */ -#define ROTL32(x, y) LET("rotl32_x", x, \ +#define PPC_IL_ROTL32(x, y) LET("rotl32_x", x, \ LET("rotl32_y", y, \ - (IN_64BIT_MODE ? ROTL64(APPEND(VARLP("rotl32_x"), VARLP("rotl32_x")), VARLP("rotl32_y")) \ + (IN_64BIT_MODE ? PPC_IL_ROTL64(APPEND(VARLP("rotl32_x"), VARLP("rotl32_x")), VARLP("rotl32_y")) \ : LOGOR(SHIFTL0(VARLP("rotl32_x"), VARLP("rotl32_y")), SHIFTR0(VARLP("rotl32_x"), SUB(U8(32), UNSIGNED(8, VARLP("rotl32_y")))))))) /** diff --git a/librz/arch/isa/ppc/ppc_il_ops.c b/librz/arch/isa/ppc/ppc_il_ops.c index 4d9f239e62..8477edae88 100644 --- a/librz/arch/isa/ppc/ppc_il_ops.c +++ b/librz/arch/isa/ppc/ppc_il_ops.c @@ -1204,7 +1204,7 @@ static RzILOpEffect *shift_and_rotate(RZ_BORROW csh handle, RZ_BORROW cs_insn *i } else { n = U8(sH); } - r = ROTL32(UNSIGNED(32, VARG(rS)), n); + r = PPC_IL_ROTL32(UNSIGNED(32, VARG(rS)), n); #if CS_NEXT_VERSION >= 6 b = mB + 32; e = mE + 32; @@ -1254,7 +1254,7 @@ static RzILOpEffect *shift_and_rotate(RZ_BORROW csh handle, RZ_BORROW cs_insn *i n = U8(sH); } n = LOGAND(U8(0x3f), n); - r = ROTL64(VARG(rS), n); + r = PPC_IL_ROTL64(VARG(rS), n); #if CS_NEXT_VERSION >= 6 if (id == PPC_INS_RLDICR || id == PPC_INS_RLDCR) { b = 0; diff --git a/librz/hash/algorithms/murmur3/murmur3.c b/librz/hash/algorithms/murmur3/murmur3.c new file mode 100644 index 0000000000..aff8b94aa4 --- /dev/null +++ b/librz/hash/algorithms/murmur3/murmur3.c @@ -0,0 +1,386 @@ +// SPDX-FileCopyrightText: 2015 Andrey Jivsov +// SPDX-License-Identifier: MIT + +/** + * \file MurmurHash3.cpp + * High performance non cryptographic hashing algorithm. + * Implementation of the MurmurHash3 algorithm. + * 3 variants of this algo are provided to hash 32,64 and 128 bit data + * MurmurHash3 was written by Austin Appleby, and is placed in the public domain. + * is engineered for speed and high-quality distribution, + * passing the full SMHasher test suite. This makes it a go-to choice for + * hash tables, bloom filters, and large-scale data de-duplication where + * performance is the primary constraint. + * + * Note - The x86 and x64 versions do _not_ produce the same results, as the + * algorithms are optimized for their respective platforms. You can still + * compile and run any of them on any platform, but your performance with the + * non-native version will be less than optimal. + * + */ + +#include "murmur3.h" +#include "rz_types.h" +#include "rz_types_base.h" +#include + +static RZ_INLINE ut32 rotl32(ut32 x, int8_t r) { + return (x << r) | (x >> (32 - r)); +} + +static RZ_INLINE ut64 rotl64(ut64 x, int8_t r) { + return (x << r) | (x >> (64 - r)); +} + +/** + * \brief Block read - if your platform needs to do endian-swapping or can only + * handle aligned reads, do the conversion here + */ +#define getblock(p, i) \ + (sizeof(*(p)) == 8 ? rz_read_le64(p + i) : rz_read_le32(p + i)) + +/* + * \brief Finalization mix - force all bits of a hash block to avalanche + */ +static RZ_INLINE ut32 fmix32(ut32 h) { + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + + return h; +} + +static RZ_INLINE ut64 fmix64(ut64 k) { + k ^= k >> 33; + k *= BIG_CONSTANT(0xff51afd7ed558ccd); + k ^= k >> 33; + k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53); + k ^= k >> 33; + + return k; +} + +RZ_IPI void MurmurHash3_x86_32(const void *key, RzRef len, size_t seed, void *out) { + const ut8 *data = (const ut8 *)key; + const RzRef nblocks = len / 4; + RzRef i; + + ut32 h1 = seed; + + ut32 c1 = 0xcc9e2d51; + ut32 c2 = 0x1b873593; + const ut32 *blocks = (const ut32 *)(data + nblocks * 4); + + for (i = -nblocks; i; i++) { + ut32 k1 = getblock(blocks, i); + + k1 *= c1; + k1 = ROTL32_Murmur3(k1, 15); + k1 *= c2; + + h1 ^= k1; + h1 = ROTL32_Murmur3(h1, 13); + h1 = h1 * 5 + 0xe6546b64; + } + + const ut8 *tail = (const ut8 *)(data + nblocks * 4); + + ut32 k1 = 0; + + switch (len & 3) { + case 3: + k1 ^= tail[2] << 16; + /* fall through */ + case 2: + k1 ^= tail[1] << 8; + /* fall through */ + case 1: + k1 ^= tail[0]; + k1 *= c1; + k1 = ROTL32_Murmur3(k1, 15); + k1 *= c2; + h1 ^= k1; + }; + + // finalization + h1 ^= len; + h1 = fmix32(h1); + *(ut32 *)out = h1; +} + +RZ_IPI void MurmurHash3_x86_128(const void *key, const RzRef len, size_t seed, void *out) { + const ut8 *data = (const ut8 *)key; + const RzRef nblocks = len / 16; + RzRef i; + + size_t h1 = seed; + size_t h2 = seed; + size_t h3 = seed; + size_t h4 = seed; + + const size_t c1 = 0x239b961b; + const size_t c2 = 0xab0e9789; + const size_t c3 = 0x38b34ae5; + const size_t c4 = 0xa1e38b93; + + const ut32 *blocks = (const ut32 *)(data + nblocks * 16); + + for (i = -nblocks; i; i++) { + ut32 k1 = getblock(blocks, i * 4 + 0); + ut32 k2 = getblock(blocks, i * 4 + 1); + ut32 k3 = getblock(blocks, i * 4 + 2); + ut32 k4 = getblock(blocks, i * 4 + 3); + + k1 *= c1; + k1 = ROTL32_Murmur3(k1, 15); + k1 *= c2; + h1 ^= k1; + + h1 = ROTL32_Murmur3(h1, 19); + h1 += h2; + h1 = h1 * 5 + 0x561ccd1b; + + k2 *= c2; + k2 = ROTL32_Murmur3(k2, 16); + k2 *= c3; + h2 ^= k2; + + h2 = ROTL32_Murmur3(h2, 17); + h2 += h3; + h2 = h2 * 5 + 0x0bcaa747; + + k3 *= c3; + k3 = ROTL32_Murmur3(k3, 17); + k3 *= c4; + h3 ^= k3; + + h3 = ROTL32_Murmur3(h3, 15); + h3 += h4; + h3 = h3 * 5 + 0x96cd1c35; + + k4 *= c4; + k4 = ROTL32_Murmur3(k4, 18); + k4 *= c1; + h4 ^= k4; + + h4 = ROTL32_Murmur3(h4, 13); + h4 += h1; + h4 = h4 * 5 + 0x32ac3b17; + } + + const ut8 *tail = (const ut8 *)(data + nblocks * 16); + + ut32 k1 = 0; + ut32 k2 = 0; + ut32 k3 = 0; + ut32 k4 = 0; + + switch (len & 15) { + case 15: + k4 ^= tail[14] << 16; + /* fall through */ + case 14: + k4 ^= tail[13] << 8; + /* fall through */ + case 13: + k4 ^= tail[12] << 0; + k4 *= c4; + k4 = ROTL32_Murmur3(k4, 18); + k4 *= c1; + h4 ^= k4; + /* fall through */ + + case 12: + k3 ^= tail[11] << 24; + /* fall through */ + case 11: + k3 ^= tail[10] << 16; + /* fall through */ + case 10: + k3 ^= tail[9] << 8; + /* fall through */ + case 9: + k3 ^= tail[8] << 0; + k3 *= c3; + k3 = ROTL32_Murmur3(k3, 17); + k3 *= c4; + h3 ^= k3; + /* fall through */ + + case 8: + k2 ^= tail[7] << 24; + /* fall through */ + case 7: + k2 ^= tail[6] << 16; + /* fall through */ + case 6: + k2 ^= tail[5] << 8; + /* fall through */ + case 5: + k2 ^= tail[4] << 0; + k2 *= c2; + k2 = ROTL32_Murmur3(k2, 16); + k2 *= c3; + h2 ^= k2; + /* fall through */ + + case 4: + k1 ^= tail[3] << 24; + /* fall through */ + case 3: + k1 ^= tail[2] << 16; + /* fall through */ + case 2: + k1 ^= tail[1] << 8; + /* fall through */ + case 1: + k1 ^= tail[0] << 0; + k1 *= c1; + k1 = ROTL32_Murmur3(k1, 15); + k1 *= c2; + h1 ^= k1; + }; + + h1 ^= len; + h2 ^= len; + h3 ^= len; + h4 ^= len; + + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + + h1 = fmix32(h1); + h2 = fmix32(h2); + h3 = fmix32(h3); + h4 = fmix32(h4); + + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + + ((ut32 *)out)[0] = h1; + ((ut32 *)out)[1] = h2; + ((ut32 *)out)[2] = h3; + ((ut32 *)out)[3] = h4; +} + +RZ_IPI void MurmurHash3_x64_128(const void *key, const RzRef len, const ut64 seed, void *out) { + const ut8 *data = (const ut8 *)key; + const RzRef nblocks = len / 16; + RzRef i; + + ut64 h1 = seed; + ut64 h2 = seed; + + const ut64 c1 = BIG_CONSTANT(0x87c37b91114253d5); + const ut64 c2 = BIG_CONSTANT(0x4cf5ad432745937f); + + const ut64 *blocks = (const ut64 *)(data); + + for (i = 0; i < nblocks; i++) { + ut64 k1 = getblock(blocks, i * 2 + 0); + ut64 k2 = getblock(blocks, i * 2 + 1); + + k1 *= c1; + k1 = ROTL64_Murmur3(k1, 31); + k1 *= c2; + h1 ^= k1; + + h1 = ROTL64_Murmur3(h1, 27); + h1 += h2; + h1 = h1 * 5 + 0x52dce729; + + k2 *= c2; + k2 = ROTL64_Murmur3(k2, 33); + k2 *= c1; + h2 ^= k2; + + h2 = ROTL64_Murmur3(h2, 31); + h2 += h1; + h2 = h2 * 5 + 0x38495ab5; + } + + const ut8 *tail = (const ut8 *)(data + nblocks * 16); + + ut64 k1 = 0; + ut64 k2 = 0; + + switch (len & 15) { + case 15: + k2 ^= (ut64)(tail[14]) << 48; + /* fall through */ + case 14: + k2 ^= (ut64)(tail[13]) << 40; + /* fall through */ + case 13: + k2 ^= (ut64)(tail[12]) << 32; + /* fall through */ + case 12: + k2 ^= (ut64)(tail[11]) << 24; + /* fall through */ + case 11: + k2 ^= (ut64)(tail[10]) << 16; + /* fall through */ + case 10: + k2 ^= (ut64)(tail[9]) << 8; + /* fall through */ + case 9: + k2 ^= (ut64)(tail[8]) << 0; + k2 *= c2; + k2 = ROTL64_Murmur3(k2, 33); + k2 *= c1; + h2 ^= k2; + /* fall through */ + case 8: + k1 ^= (ut64)(tail[7]) << 56; + /* fall through */ + case 7: + k1 ^= (ut64)(tail[6]) << 48; + /* fall through */ + case 6: + k1 ^= (ut64)(tail[5]) << 40; + /* fall through */ + case 5: + k1 ^= (ut64)(tail[4]) << 32; + /* fall through */ + case 4: + k1 ^= (ut64)(tail[3]) << 24; + /* fall through */ + case 3: + k1 ^= (ut64)(tail[2]) << 16; + /* fall through */ + case 2: + k1 ^= (ut64)(tail[1]) << 8; + /* fall through */ + case 1: + k1 ^= (ut64)(tail[0]) << 0; + k1 *= c1; + k1 = ROTL64_Murmur3(k1, 31); + k1 *= c2; + h1 ^= k1; + }; + + h1 ^= len; + h2 ^= len; + + h1 += h2; + h2 += h1; + + h1 = fmix64(h1); + h2 = fmix64(h2); + + h1 += h2; + h2 += h1; + + ((ut64 *)out)[0] = h1; + ((ut64 *)out)[1] = h2; +} diff --git a/librz/hash/algorithms/murmur3/murmur3.h b/librz/hash/algorithms/murmur3/murmur3.h new file mode 100644 index 0000000000..b3a4525619 --- /dev/null +++ b/librz/hash/algorithms/murmur3/murmur3.h @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2015 Andrey Jivsov +// SPDX-License-Identifier: MIT + +// MurmurHash3 was written by Austin Appleby, and is placed in the public +// domain. The author hereby disclaims copyright to this source code. + +#ifndef _MURMURHASH3_H_ +#define _MURMURHASH3_H_ + +#include + +#define MURMUR3_32_DIGEST_LENGTH 4 +#define MURMUR3_128_DIGEST_LENGTH 16 + +#define ROTL32_Murmur3(x, y) rotl32(x, y) +#define ROTL64_Murmur3(x, y) rotl64(x, y) + +RZ_IPI void MurmurHash3_x86_32(const void *key, RzRef len, size_t seed, void *out); +RZ_IPI void MurmurHash3_x86_128(const void *key, RzRef len, size_t seed, void *out); +RZ_IPI void MurmurHash3_x64_128(const void *key, RzRef len, ut64 seed, void *out); + +#endif // _MURMURHASH3_H_ diff --git a/librz/hash/meson.build b/librz/hash/meson.build index 7dbb976364..c017808863 100644 --- a/librz/hash/meson.build +++ b/librz/hash/meson.build @@ -13,6 +13,9 @@ hash_plugins_list = [ 'keccak_256', 'keccak_384', 'keccak_512', + 'murmur3_x86_32', + 'murmur3_x86_128', + 'murmur3_x64_128', 'sm3', 'blake2b', 'blake2bp', @@ -123,6 +126,9 @@ rz_hash_sources = [ 'p/algo_keccak_256.c', 'p/algo_keccak_384.c', 'p/algo_keccak_512.c', + 'p/algo_murmur3_x64_128.c', + 'p/algo_murmur3_x86_32.c', + 'p/algo_murmur3_x86_128.c', 'p/algo_xor8.c', 'p/algo_xor16.c', 'p/algo_xxhash32.c', @@ -141,7 +147,8 @@ rz_hash_sources = [ 'algorithms/fletcher/fletcher.c', 'algorithms/ssdeep/ssdeep.c', 'algorithms/md2/md2.c', - 'algorithms/sha3/sha3.c' + 'algorithms/sha3/sha3.c', + 'algorithms/murmur3/murmur3.c', ] dependencies = [mth, rz_util_dep, xxhash_dep, blake3_dep, blake2_dep] diff --git a/librz/hash/p/algo_murmur3_x64_128.c b/librz/hash/p/algo_murmur3_x64_128.c new file mode 100644 index 0000000000..bd5ec003db --- /dev/null +++ b/librz/hash/p/algo_murmur3_x64_128.c @@ -0,0 +1,119 @@ +// SPDX-FileCopyrightText: 2026 Ashish Kumar +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include + +#include "../algorithms/murmur3/murmur3.h" + +typedef struct { + ut8 *buffer; + ut64 buffer_len; + ut64 buffer_alloc; + uint32_t seed; +} Murmur3x64_128Context; + +static void *plugin_murmur3_x64_128_context_new() { + return RZ_NEW0(Murmur3x64_128Context); +} + +static void plugin_murmur3_x64_128_context_free(void *context) { + if (context) { + Murmur3x64_128Context *ctx = (Murmur3x64_128Context *)context; + free(ctx->buffer); + free(ctx); + } +} + +static RzHashSize plugin_murmur3_x64_128_digest_size(void *context) { + return MURMUR3_128_DIGEST_LENGTH; +} + +static RzHashSize plugin_murmur3_x64_128_block_size(void *context) { + return 16; +} + +static bool plugin_murmur3_x64_128_init(void *context) { + rz_return_val_if_fail(context, false); + Murmur3x64_128Context *ctx = (Murmur3x64_128Context *)context; + free(ctx->buffer); + ctx->buffer = NULL; + ctx->buffer_len = 0; + ctx->buffer_alloc = 0; + ctx->seed = 0; + return true; +} + +static bool plugin_murmur3_x64_128_update(void *context, const ut8 *data, ut64 size) { + rz_return_val_if_fail(context && data, false); + Murmur3x64_128Context *ctx = (Murmur3x64_128Context *)context; + + ut64 new_len = ctx->buffer_len + size; + if (new_len > ctx->buffer_alloc) { + ut64 new_alloc = RZ_MAX(new_len, ctx->buffer_alloc * 2); + ut8 *tmp = realloc(ctx->buffer, new_alloc); + if (!tmp) { + return false; + } + ctx->buffer = tmp; + ctx->buffer_alloc = new_alloc; + } + memcpy(ctx->buffer + ctx->buffer_len, data, size); + ctx->buffer_len = new_len; + return true; +} + +static bool plugin_murmur3_x64_128_final(void *context, ut8 *digest) { + rz_return_val_if_fail(context && digest, false); + Murmur3x64_128Context *ctx = (Murmur3x64_128Context *)context; + + ut64 result[2] = { 0 }; + ut8 empty = 0; + MurmurHash3_x64_128(ctx->buffer ? ctx->buffer : &empty, (int)ctx->buffer_len, ctx->seed, result); + rz_write_be64(digest + 0, result[1]); + rz_write_be64(digest + 8, result[0]); + return true; +} + +static bool plugin_murmur3_x64_128_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size) { + rz_return_val_if_fail(data && digest, false); + ut8 *dgst = malloc(MURMUR3_128_DIGEST_LENGTH); + if (!dgst) { + return false; + } + + ut64 result[2] = { 0 }; + MurmurHash3_x64_128(data, (int)size, 0, result); + rz_write_be64(dgst + 0, result[1]); + rz_write_be64(dgst + 8, result[0]); + + *digest = dgst; + if (digest_size) { + *digest_size = MURMUR3_128_DIGEST_LENGTH; + } + return true; +} + +RzHashPlugin rz_hash_plugin_murmur3_x64_128 = { + .name = "murmur3-x64-128", + .author = "Austin Appleby", + .license = "MIT", + .description = "MurmurHash3 x64 128-bit non-cryptographic hash", + .support_hmac = false, + .context_new = plugin_murmur3_x64_128_context_new, + .context_free = plugin_murmur3_x64_128_context_free, + .digest_size = plugin_murmur3_x64_128_digest_size, + .block_size = plugin_murmur3_x64_128_block_size, + .init = plugin_murmur3_x64_128_init, + .update = plugin_murmur3_x64_128_update, + .final = plugin_murmur3_x64_128_final, + .small_block = plugin_murmur3_x64_128_small_block, +}; + +#ifndef RZ_PLUGIN_INCORE +RZ_API RzLibStruct rizin_plugin = { + .type = RZ_LIB_TYPE_HASH, + .data = &rz_hash_plugin_murmur3_x64_128, + .version = RZ_VERSION +}; +#endif diff --git a/librz/hash/p/algo_murmur3_x86_128.c b/librz/hash/p/algo_murmur3_x86_128.c new file mode 100644 index 0000000000..ced68f3f3e --- /dev/null +++ b/librz/hash/p/algo_murmur3_x86_128.c @@ -0,0 +1,123 @@ +// SPDX-FileCopyrightText: 2026 Ashish Kumar +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include + +#include "../algorithms/murmur3/murmur3.h" + +typedef struct { + ut8 *buffer; + ut64 buffer_len; + ut64 buffer_alloc; + uint32_t seed; +} Murmur3x86_128Context; + +static void *plugin_murmur3_x86_128_context_new() { + return RZ_NEW0(Murmur3x86_128Context); +} + +static void plugin_murmur3_x86_128_context_free(void *context) { + if (context) { + Murmur3x86_128Context *ctx = (Murmur3x86_128Context *)context; + free(ctx->buffer); + free(ctx); + } +} + +static RzHashSize plugin_murmur3_x86_128_digest_size(void *context) { + return MURMUR3_128_DIGEST_LENGTH; +} + +static RzHashSize plugin_murmur3_x86_128_block_size(void *context) { + return 16; +} + +static bool plugin_murmur3_x86_128_init(void *context) { + rz_return_val_if_fail(context, false); + Murmur3x86_128Context *ctx = (Murmur3x86_128Context *)context; + free(ctx->buffer); + ctx->buffer = NULL; + ctx->buffer_len = 0; + ctx->buffer_alloc = 0; + ctx->seed = 0; + return true; +} + +static bool plugin_murmur3_x86_128_update(void *context, const ut8 *data, ut64 size) { + rz_return_val_if_fail(context && data, false); + Murmur3x86_128Context *ctx = (Murmur3x86_128Context *)context; + + ut64 new_len = ctx->buffer_len + size; + if (new_len > ctx->buffer_alloc) { + ut64 new_alloc = RZ_MAX(new_len, ctx->buffer_alloc * 2); + ut8 *tmp = realloc(ctx->buffer, new_alloc); + if (!tmp) { + return false; + } + ctx->buffer = tmp; + ctx->buffer_alloc = new_alloc; + } + memcpy(ctx->buffer + ctx->buffer_len, data, size); + ctx->buffer_len = new_len; + return true; +} + +static bool plugin_murmur3_x86_128_final(void *context, ut8 *digest) { + rz_return_val_if_fail(context && digest, false); + Murmur3x86_128Context *ctx = (Murmur3x86_128Context *)context; + + ut32 result[4] = { 0 }; + ut8 empty = 0; + MurmurHash3_x86_128(ctx->buffer ? ctx->buffer : &empty, (int)ctx->buffer_len, ctx->seed, result); + rz_write_be32(digest + 0, result[3]); + rz_write_be32(digest + 4, result[2]); + rz_write_be32(digest + 8, result[1]); + rz_write_be32(digest + 12, result[0]); + return true; +} + +static bool plugin_murmur3_x86_128_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size) { + rz_return_val_if_fail(data && digest, false); + ut8 *dgst = malloc(MURMUR3_128_DIGEST_LENGTH); + if (!dgst) { + return false; + } + + ut32 result[4] = { 0 }; + MurmurHash3_x86_128(data, (int)size, 0, result); + rz_write_be32(dgst + 0, result[3]); + rz_write_be32(dgst + 4, result[2]); + rz_write_be32(dgst + 8, result[1]); + rz_write_be32(dgst + 12, result[0]); + + *digest = dgst; + if (digest_size) { + *digest_size = MURMUR3_128_DIGEST_LENGTH; + } + return true; +} + +RzHashPlugin rz_hash_plugin_murmur3_x86_128 = { + .name = "murmur3-x86-128", + .author = "Austin Appleby", + .license = "MIT", + .description = "MurmurHash3 x86 128-bit non-cryptographic hash", + .support_hmac = false, + .context_new = plugin_murmur3_x86_128_context_new, + .context_free = plugin_murmur3_x86_128_context_free, + .digest_size = plugin_murmur3_x86_128_digest_size, + .block_size = plugin_murmur3_x86_128_block_size, + .init = plugin_murmur3_x86_128_init, + .update = plugin_murmur3_x86_128_update, + .final = plugin_murmur3_x86_128_final, + .small_block = plugin_murmur3_x86_128_small_block, +}; + +#ifndef RZ_PLUGIN_INCORE +RZ_API RzLibStruct rizin_plugin = { + .type = RZ_LIB_TYPE_HASH, + .data = &rz_hash_plugin_murmur3_x86_128, + .version = RZ_VERSION +}; +#endif diff --git a/librz/hash/p/algo_murmur3_x86_32.c b/librz/hash/p/algo_murmur3_x86_32.c new file mode 100644 index 0000000000..4441d4642e --- /dev/null +++ b/librz/hash/p/algo_murmur3_x86_32.c @@ -0,0 +1,117 @@ +// SPDX-FileCopyrightText: 2026 Ashish Kumar +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include + +#include "../algorithms/murmur3/murmur3.h" + +typedef struct { + ut8 *buffer; + ut64 buffer_len; + ut64 buffer_alloc; + uint32_t seed; +} Murmur3x86_32Context; + +static void *plugin_murmur3_x86_32_context_new() { + return RZ_NEW0(Murmur3x86_32Context); +} + +static void plugin_murmur3_x86_32_context_free(void *context) { + if (context) { + Murmur3x86_32Context *ctx = (Murmur3x86_32Context *)context; + free(ctx->buffer); + free(ctx); + } +} + +static RzHashSize plugin_murmur3_x86_32_digest_size(void *context) { + return MURMUR3_32_DIGEST_LENGTH; +} + +static RzHashSize plugin_murmur3_x86_32_block_size(void *context) { + return 4; +} + +static bool plugin_murmur3_x86_32_init(void *context) { + rz_return_val_if_fail(context, false); + Murmur3x86_32Context *ctx = (Murmur3x86_32Context *)context; + free(ctx->buffer); + ctx->buffer = NULL; + ctx->buffer_len = 0; + ctx->buffer_alloc = 0; + ctx->seed = 0; + return true; +} + +static bool plugin_murmur3_x86_32_update(void *context, const ut8 *data, ut64 size) { + rz_return_val_if_fail(context && data, false); + Murmur3x86_32Context *ctx = (Murmur3x86_32Context *)context; + + ut64 new_len = ctx->buffer_len + size; + if (new_len > ctx->buffer_alloc) { + ut64 new_alloc = RZ_MAX(new_len, ctx->buffer_alloc * 2); + ut8 *tmp = realloc(ctx->buffer, new_alloc); + if (!tmp) { + return false; + } + ctx->buffer = tmp; + ctx->buffer_alloc = new_alloc; + } + memcpy(ctx->buffer + ctx->buffer_len, data, size); + ctx->buffer_len = new_len; + return true; +} + +static bool plugin_murmur3_x86_32_final(void *context, ut8 *digest) { + rz_return_val_if_fail(context && digest, false); + Murmur3x86_32Context *ctx = (Murmur3x86_32Context *)context; + + ut32 result = 0; + ut8 empty = 0; + MurmurHash3_x86_32(ctx->buffer ? ctx->buffer : &empty, (int)ctx->buffer_len, ctx->seed, &result); + rz_write_be32(digest, result); + return true; +} + +static bool plugin_murmur3_x86_32_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size) { + rz_return_val_if_fail(data && digest, false); + ut8 *dgst = malloc(MURMUR3_32_DIGEST_LENGTH); + if (!dgst) { + return false; + } + + ut32 result = 0; + MurmurHash3_x86_32(data, (int)size, 0, &result); + rz_write_be32(dgst, result); + + *digest = dgst; + if (digest_size) { + *digest_size = MURMUR3_32_DIGEST_LENGTH; + } + return true; +} + +RzHashPlugin rz_hash_plugin_murmur3_x86_32 = { + .name = "murmur3-x86-32", + .author = "Austin Appleby", + .license = "MIT", + .description = "MurmurHash3 x86 32-bit non-cryptographic hash", + .support_hmac = false, + .context_new = plugin_murmur3_x86_32_context_new, + .context_free = plugin_murmur3_x86_32_context_free, + .digest_size = plugin_murmur3_x86_32_digest_size, + .block_size = plugin_murmur3_x86_32_block_size, + .init = plugin_murmur3_x86_32_init, + .update = plugin_murmur3_x86_32_update, + .final = plugin_murmur3_x86_32_final, + .small_block = plugin_murmur3_x86_32_small_block, +}; + +#ifndef RZ_PLUGIN_INCORE +RZ_API RzLibStruct rizin_plugin = { + .type = RZ_LIB_TYPE_HASH, + .data = &rz_hash_plugin_murmur3_x86_32, + .version = RZ_VERSION +}; +#endif diff --git a/librz/include/rz_hash.h b/librz/include/rz_hash.h index abf7b07d2a..410efd238a 100644 --- a/librz/include/rz_hash.h +++ b/librz/include/rz_hash.h @@ -115,6 +115,9 @@ extern RzHashPlugin rz_hash_plugin_sha3_512; extern RzHashPlugin rz_hash_plugin_keccak_256; extern RzHashPlugin rz_hash_plugin_keccak_384; extern RzHashPlugin rz_hash_plugin_keccak_512; +extern RzHashPlugin rz_hash_plugin_murmur3_x86_32; +extern RzHashPlugin rz_hash_plugin_murmur3_x86_128; +extern RzHashPlugin rz_hash_plugin_murmur3_x64_128; extern RzHashPlugin rz_hash_plugin_fletcher8; extern RzHashPlugin rz_hash_plugin_fletcher16; extern RzHashPlugin rz_hash_plugin_fletcher32; diff --git a/librz/include/rz_types_base.h b/librz/include/rz_types_base.h index 865518945a..fad0335ab8 100644 --- a/librz/include/rz_types_base.h +++ b/librz/include/rz_types_base.h @@ -231,4 +231,12 @@ typedef struct _utX { #define RZ_STR_DEF(s) RZ_STR(s) #define RZ_STR(s) #s +#ifdef __GNUC__ +#define RZ_INLINE __attribute__((always_inline)) inline +#else +#define RZ_INLINE inline +#endif + +#define BIG_CONSTANT(x) (x##LLU) + #endif // RZ_TYPES_BASE_H diff --git a/subprojects/rzspp/spp.h b/subprojects/rzspp/spp.h index 918a0d7f40..335a8eb0dc 100644 --- a/subprojects/rzspp/spp.h +++ b/subprojects/rzspp/spp.h @@ -20,8 +20,6 @@ #endif #if RZ_SWIG #define S_API export -#elif RZ_INLINE - #define S_API inline #else #if defined(__GNUC__) && __GNUC__ >= 4 #define S_API __attribute__((visibility("default"))) diff --git a/test/db/cmd/cmd_list b/test/db/cmd/cmd_list index 197217eb21..1a4b3e500f 100644 --- a/test/db/cmd/cmd_list +++ b/test/db/cmd/cmd_list @@ -447,6 +447,9 @@ md2 LGPL3 swedenspy MD2 cryptographic hash md4 LGPL3 deroad MD4 cryptographic hash md5 LGPL2 Alan DeKok MD5 cryptographic hash mod255 LGPL3 deroad Modulo 255 checksum +murmur3-x64-128 MIT Austin Appleby MurmurHash3 x64 128-bit non-cryptographic hash +murmur3-x86-128 MIT Austin Appleby MurmurHash3 x86 128-bit non-cryptographic hash +murmur3-x86-32 MIT Austin Appleby MurmurHash3 x86 32-bit non-cryptographic hash parity LGPL3 deroad Parity checksum sha1 LGPL3 deroad SHA-1 cryptographic hash sha256 BSD-3 Aaron D. Gifford SHA-256 cryptographic hash @@ -462,96 +465,99 @@ temperature LGPL3 Seva Binary temperature [0.0 xor16 LGPL3 deroad XOR-16 checksum xor8 LGPL3 deroad XOR-8 checksum xxhash32 LGPL3 deroad xxHash32 non-cryptographic hash -[{"name":"adler32","license":"LGPL3","author":"deroad","description":"Adler-32 checksum"},{"name":"blake2b","license":"LGPL3","author":"Farhan-25","description":"BLAKE2b cryptographic hash"},{"name":"blake2bp","license":"LGPL3","author":"Farhan-25","description":"BLAKE2bp cryptographic hash"},{"name":"blake2s","license":"LGPL3","author":"Farhan-25","description":"BLAKE2s cryptographic hash"},{"name":"blake2sp","license":"LGPL3","author":"Farhan-25","description":"BLAKE2sp cryptographic hash"},{"name":"blake2xb","license":"LGPL3","author":"Farhan-25","description":"BLAKE2xb cryptographic hash"},{"name":"blake2xs","license":"LGPL3","author":"Farhan-25","description":"BLAKE2xs cryptographic hash"},{"name":"blake3","license":"CC0","author":"Samuel Neves,Jack O'Connor","description":"BLAKE3 cryptographic hash"},{"name":"crc15can","license":"LGPL3","author":"deroad","description":"CRC-15 CAN checksum"},{"name":"crc16","license":"LGPL3","author":"deroad","description":"CRC-16 IBM/ARC checksum"},{"name":"crc16augccitt","license":"LGPL3","author":"deroad","description":"CRC-16 AUG-CCITT checksum"},{"name":"crc16buypass","license":"LGPL3","author":"deroad","description":"CRC-16 BUYPASS checksum"},{"name":"crc16cdma2000","license":"LGPL3","author":"deroad","description":"CRC-16 CDMA-2000 checksum"},{"name":"crc16citt","license":"LGPL3","author":"deroad","description":"CRC-16 CITT checksum"},{"name":"crc16dds110","license":"LGPL3","author":"deroad","description":"CRC-16 DDS110 checksum"},{"name":"crc16dectr","license":"LGPL3","author":"deroad","description":"CRC-16 DECT-R checksum"},{"name":"crc16dectx","license":"LGPL3","author":"deroad","description":"CRC-16 DECT-X checksum"},{"name":"crc16dnp","license":"LGPL3","author":"deroad","description":"CRC-16 DNP checksum"},{"name":"crc16en13757","license":"LGPL3","author":"deroad","description":"CRC-16 EN-13757 checksum"},{"name":"crc16genibus","license":"LGPL3","author":"deroad","description":"CRC-16 GENIBUS checksum"},{"name":"crc16hdlc","license":"LGPL3","author":"deroad","description":"CRC-16 HDLC checksum"},{"name":"crc16kermit","license":"LGPL3","author":"deroad","description":"CRC-16 KERMIT checksum"},{"name":"crc16maxim","license":"LGPL3","author":"deroad","description":"CRC-16 MAXIM checksum"},{"name":"crc16mcrf4xx","license":"LGPL3","author":"deroad","description":"CRC-16 MCRF4XX checksum"},{"name":"crc16modbus","license":"LGPL3","author":"deroad","description":"CRC-16 MODBUS checksum"},{"name":"crc16riello","license":"LGPL3","author":"deroad","description":"CRC-16 RIELLO checksum"},{"name":"crc16t10dif","license":"LGPL3","author":"deroad","description":"CRC-16 T10-DIF checksum"},{"name":"crc16teledisk","license":"LGPL3","author":"deroad","description":"CRC-16 TELEDISK checksum"},{"name":"crc16tms37157","license":"LGPL3","author":"deroad","description":"CRC-16 TMS37157 checksum"},{"name":"crc16usb","license":"LGPL3","author":"deroad","description":"CRC-16 USB checksum"},{"name":"crc16x25","license":"LGPL3","author":"deroad","description":"CRC-16 X25 checksum"},{"name":"crc16xmodem","license":"LGPL3","author":"deroad","description":"CRC-16 XMODEM checksum"},{"name":"crc24","license":"LGPL3","author":"deroad","description":"CRC-24 checksum"},{"name":"crc32","license":"LGPL3","author":"deroad","description":"CRC-32 checksum"},{"name":"crc32bzip2","license":"LGPL3","author":"deroad","description":"CRC-32 BZIP2 checksum"},{"name":"crc32c","license":"LGPL3","author":"deroad","description":"CRC-32C checksum"},{"name":"crc32d","license":"LGPL3","author":"deroad","description":"CRC-32D checksum"},{"name":"crc32ecma267","license":"LGPL3","author":"deroad","description":"CRC-32 ECMA-267 checksum (EDC for DVD sectors)"},{"name":"crc32jamcrc","license":"LGPL3","author":"deroad","description":"CRC-32 JAMCRC checksum"},{"name":"crc32mpeg2","license":"LGPL3","author":"deroad","description":"CRC-32 MPEG2 checksum"},{"name":"crc32posix","license":"LGPL3","author":"deroad","description":"CRC-32 POSIX checksum"},{"name":"crc32q","license":"LGPL3","author":"deroad","description":"CRC-32Q checksum"},{"name":"crc32xfer","license":"LGPL3","author":"deroad","description":"CRC-32 XFER checksum"},{"name":"crc64","license":"LGPL3","author":"deroad","description":"CRC-64 checksum"},{"name":"crc64ecma182","license":"LGPL3","author":"deroad","description":"CRC-64 ECMA-182 checksum"},{"name":"crc64iso","license":"LGPL3","author":"deroad","description":"CRC-64 ISO checksum"},{"name":"crc64we","license":"LGPL3","author":"deroad","description":"CRC-64 WE checksum"},{"name":"crc64xz","license":"LGPL3","author":"deroad","description":"CRC-64 XZ checksum"},{"name":"crc8cdma2000","license":"LGPL3","author":"deroad","description":"CRC-8 CDMA-2000 checksum"},{"name":"crc8darc","license":"LGPL3","author":"deroad","description":"CRC-8 DARC checksum"},{"name":"crc8dvbs2","license":"LGPL3","author":"deroad","description":"CRC-8 DVB-S2 checksum"},{"name":"crc8ebu","license":"LGPL3","author":"deroad","description":"CRC-8 EBU checksum"},{"name":"crc8icode","license":"LGPL3","author":"deroad","description":"CRC-8 I-CODE checksum"},{"name":"crc8itu","license":"LGPL3","author":"deroad","description":"CRC-8 ITU checksum"},{"name":"crc8maxim","license":"LGPL3","author":"deroad","description":"CRC-8 MAXIM checksum"},{"name":"crc8rohc","license":"LGPL3","author":"deroad","description":"CRC-8 ROHC checksum"},{"name":"crc8smbus","license":"LGPL3","author":"deroad","description":"CRC-8 SMBUS checksum"},{"name":"crc8wcdma","license":"LGPL3","author":"deroad","description":"CRC-8 WCDMA checksum"},{"name":"crca","license":"LGPL3","author":"deroad","description":"CRC-16/CRCA checksum"},{"name":"entropy","license":"LGPL3","author":"deroad","description":"Entropy [0.0-8.0] range"},{"name":"entropy_fract","license":"LGPL3","author":"deroad","description":"Fractional entropy [0.0-1.0] range"},{"name":"fletcher16","license":"LGPL3","author":"deroad","description":"Fletcher16 checksum"},{"name":"fletcher32","license":"LGPL3","author":"deroad","description":"Fletcher32 checksum"},{"name":"fletcher64","license":"LGPL3","author":"deroad","description":"Fletcher64 checksum"},{"name":"fletcher8","license":"LGPL3","author":"deroad","description":"Fletcher8 checksum"},{"name":"keccak-256","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-256 cryptographic hash"},{"name":"keccak-384","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-384 cryptographic hash"},{"name":"keccak-512","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-512 cryptographic hash"},{"name":"md2","license":"LGPL3","author":"swedenspy","description":"MD2 cryptographic hash"},{"name":"md4","license":"LGPL3","author":"deroad","description":"MD4 cryptographic hash"},{"name":"md5","license":"LGPL2","author":"Alan DeKok","description":"MD5 cryptographic hash"},{"name":"mod255","license":"LGPL3","author":"deroad","description":"Modulo 255 checksum"},{"name":"parity","license":"LGPL3","author":"deroad","description":"Parity checksum"},{"name":"sha1","license":"LGPL3","author":"deroad","description":"SHA-1 cryptographic hash"},{"name":"sha256","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-256 cryptographic hash"},{"name":"sha3-224","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-224 cryptographic hash"},{"name":"sha3-256","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-256 cryptographic hash"},{"name":"sha3-384","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-384 cryptographic hash"},{"name":"sha3-512","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-512 cryptographic hash"},{"name":"sha384","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-384 cryptographic hash"},{"name":"sha512","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-512 cryptographic hash"},{"name":"sm3","license":"LGPL2","author":"FSF/deroad","description":"ShangMi 3 (SM3) cryptographic hash"},{"name":"ssdeep","license":"LGPL3","author":"deroad","description":"SSDeep Context Triggered Piecewise Hash (CTPH, fuzzy hash)"},{"name":"temperature","license":"LGPL3","author":"Seva","description":"Binary temperature [0.0-1.0] range"},{"name":"xor16","license":"LGPL3","author":"deroad","description":"XOR-16 checksum"},{"name":"xor8","license":"LGPL3","author":"deroad","description":"XOR-8 checksum"},{"name":"xxhash32","license":"LGPL3","author":"deroad","description":"xxHash32 non-cryptographic hash"}] -algorithm license author description ------------------------------------------------------------------------------------------------------------- -adler32 LGPL3 deroad Adler-32 checksum -blake2b LGPL3 Farhan-25 BLAKE2b cryptographic hash -blake2bp LGPL3 Farhan-25 BLAKE2bp cryptographic hash -blake2s LGPL3 Farhan-25 BLAKE2s cryptographic hash -blake2sp LGPL3 Farhan-25 BLAKE2sp cryptographic hash -blake2xb LGPL3 Farhan-25 BLAKE2xb cryptographic hash -blake2xs LGPL3 Farhan-25 BLAKE2xs cryptographic hash -blake3 CC0 Samuel Neves,Jack O'Connor BLAKE3 cryptographic hash -crc15can LGPL3 deroad CRC-15 CAN checksum -crc16 LGPL3 deroad CRC-16 IBM/ARC checksum -crc16augccitt LGPL3 deroad CRC-16 AUG-CCITT checksum -crc16buypass LGPL3 deroad CRC-16 BUYPASS checksum -crc16cdma2000 LGPL3 deroad CRC-16 CDMA-2000 checksum -crc16citt LGPL3 deroad CRC-16 CITT checksum -crc16dds110 LGPL3 deroad CRC-16 DDS110 checksum -crc16dectr LGPL3 deroad CRC-16 DECT-R checksum -crc16dectx LGPL3 deroad CRC-16 DECT-X checksum -crc16dnp LGPL3 deroad CRC-16 DNP checksum -crc16en13757 LGPL3 deroad CRC-16 EN-13757 checksum -crc16genibus LGPL3 deroad CRC-16 GENIBUS checksum -crc16hdlc LGPL3 deroad CRC-16 HDLC checksum -crc16kermit LGPL3 deroad CRC-16 KERMIT checksum -crc16maxim LGPL3 deroad CRC-16 MAXIM checksum -crc16mcrf4xx LGPL3 deroad CRC-16 MCRF4XX checksum -crc16modbus LGPL3 deroad CRC-16 MODBUS checksum -crc16riello LGPL3 deroad CRC-16 RIELLO checksum -crc16t10dif LGPL3 deroad CRC-16 T10-DIF checksum -crc16teledisk LGPL3 deroad CRC-16 TELEDISK checksum -crc16tms37157 LGPL3 deroad CRC-16 TMS37157 checksum -crc16usb LGPL3 deroad CRC-16 USB checksum -crc16x25 LGPL3 deroad CRC-16 X25 checksum -crc16xmodem LGPL3 deroad CRC-16 XMODEM checksum -crc24 LGPL3 deroad CRC-24 checksum -crc32 LGPL3 deroad CRC-32 checksum -crc32bzip2 LGPL3 deroad CRC-32 BZIP2 checksum -crc32c LGPL3 deroad CRC-32C checksum -crc32d LGPL3 deroad CRC-32D checksum -crc32ecma267 LGPL3 deroad CRC-32 ECMA-267 checksum (EDC for DVD sectors) -crc32jamcrc LGPL3 deroad CRC-32 JAMCRC checksum -crc32mpeg2 LGPL3 deroad CRC-32 MPEG2 checksum -crc32posix LGPL3 deroad CRC-32 POSIX checksum -crc32q LGPL3 deroad CRC-32Q checksum -crc32xfer LGPL3 deroad CRC-32 XFER checksum -crc64 LGPL3 deroad CRC-64 checksum -crc64ecma182 LGPL3 deroad CRC-64 ECMA-182 checksum -crc64iso LGPL3 deroad CRC-64 ISO checksum -crc64we LGPL3 deroad CRC-64 WE checksum -crc64xz LGPL3 deroad CRC-64 XZ checksum -crc8cdma2000 LGPL3 deroad CRC-8 CDMA-2000 checksum -crc8darc LGPL3 deroad CRC-8 DARC checksum -crc8dvbs2 LGPL3 deroad CRC-8 DVB-S2 checksum -crc8ebu LGPL3 deroad CRC-8 EBU checksum -crc8icode LGPL3 deroad CRC-8 I-CODE checksum -crc8itu LGPL3 deroad CRC-8 ITU checksum -crc8maxim LGPL3 deroad CRC-8 MAXIM checksum -crc8rohc LGPL3 deroad CRC-8 ROHC checksum -crc8smbus LGPL3 deroad CRC-8 SMBUS checksum -crc8wcdma LGPL3 deroad CRC-8 WCDMA checksum -crca LGPL3 deroad CRC-16/CRCA checksum -entropy LGPL3 deroad Entropy [0.0-8.0] range -entropy_fract LGPL3 deroad Fractional entropy [0.0-1.0] range -fletcher16 LGPL3 deroad Fletcher16 checksum -fletcher32 LGPL3 deroad Fletcher32 checksum -fletcher64 LGPL3 deroad Fletcher64 checksum -fletcher8 LGPL3 deroad Fletcher8 checksum -keccak-256 BSD-3 Andrey Jivsov KECCAK-256 cryptographic hash -keccak-384 BSD-3 Andrey Jivsov KECCAK-384 cryptographic hash -keccak-512 BSD-3 Andrey Jivsov KECCAK-512 cryptographic hash -md2 LGPL3 swedenspy MD2 cryptographic hash -md4 LGPL3 deroad MD4 cryptographic hash -md5 LGPL2 Alan DeKok MD5 cryptographic hash -mod255 LGPL3 deroad Modulo 255 checksum -parity LGPL3 deroad Parity checksum -sha1 LGPL3 deroad SHA-1 cryptographic hash -sha256 BSD-3 Aaron D. Gifford SHA-256 cryptographic hash -sha3-224 BSD-3 Andrey Jivsov SHA3-224 cryptographic hash -sha3-256 BSD-3 Andrey Jivsov SHA3-256 cryptographic hash -sha3-384 BSD-3 Andrey Jivsov SHA3-384 cryptographic hash -sha3-512 BSD-3 Andrey Jivsov SHA3-512 cryptographic hash -sha384 BSD-3 Aaron D. Gifford SHA-384 cryptographic hash -sha512 BSD-3 Aaron D. Gifford SHA-512 cryptographic hash -sm3 LGPL2 FSF/deroad ShangMi 3 (SM3) cryptographic hash -ssdeep LGPL3 deroad SSDeep Context Triggered Piecewise Hash (CTPH, fuzzy hash) -temperature LGPL3 Seva Binary temperature [0.0-1.0] range -xor16 LGPL3 deroad XOR-16 checksum -xor8 LGPL3 deroad XOR-8 checksum -xxhash32 LGPL3 deroad xxHash32 non-cryptographic hash +[{"name":"adler32","license":"LGPL3","author":"deroad","description":"Adler-32 checksum"},{"name":"blake2b","license":"LGPL3","author":"Farhan-25","description":"BLAKE2b cryptographic hash"},{"name":"blake2bp","license":"LGPL3","author":"Farhan-25","description":"BLAKE2bp cryptographic hash"},{"name":"blake2s","license":"LGPL3","author":"Farhan-25","description":"BLAKE2s cryptographic hash"},{"name":"blake2sp","license":"LGPL3","author":"Farhan-25","description":"BLAKE2sp cryptographic hash"},{"name":"blake2xb","license":"LGPL3","author":"Farhan-25","description":"BLAKE2xb cryptographic hash"},{"name":"blake2xs","license":"LGPL3","author":"Farhan-25","description":"BLAKE2xs cryptographic hash"},{"name":"blake3","license":"CC0","author":"Samuel Neves,Jack O'Connor","description":"BLAKE3 cryptographic hash"},{"name":"crc15can","license":"LGPL3","author":"deroad","description":"CRC-15 CAN checksum"},{"name":"crc16","license":"LGPL3","author":"deroad","description":"CRC-16 IBM/ARC checksum"},{"name":"crc16augccitt","license":"LGPL3","author":"deroad","description":"CRC-16 AUG-CCITT checksum"},{"name":"crc16buypass","license":"LGPL3","author":"deroad","description":"CRC-16 BUYPASS checksum"},{"name":"crc16cdma2000","license":"LGPL3","author":"deroad","description":"CRC-16 CDMA-2000 checksum"},{"name":"crc16citt","license":"LGPL3","author":"deroad","description":"CRC-16 CITT checksum"},{"name":"crc16dds110","license":"LGPL3","author":"deroad","description":"CRC-16 DDS110 checksum"},{"name":"crc16dectr","license":"LGPL3","author":"deroad","description":"CRC-16 DECT-R checksum"},{"name":"crc16dectx","license":"LGPL3","author":"deroad","description":"CRC-16 DECT-X checksum"},{"name":"crc16dnp","license":"LGPL3","author":"deroad","description":"CRC-16 DNP checksum"},{"name":"crc16en13757","license":"LGPL3","author":"deroad","description":"CRC-16 EN-13757 checksum"},{"name":"crc16genibus","license":"LGPL3","author":"deroad","description":"CRC-16 GENIBUS checksum"},{"name":"crc16hdlc","license":"LGPL3","author":"deroad","description":"CRC-16 HDLC checksum"},{"name":"crc16kermit","license":"LGPL3","author":"deroad","description":"CRC-16 KERMIT checksum"},{"name":"crc16maxim","license":"LGPL3","author":"deroad","description":"CRC-16 MAXIM checksum"},{"name":"crc16mcrf4xx","license":"LGPL3","author":"deroad","description":"CRC-16 MCRF4XX checksum"},{"name":"crc16modbus","license":"LGPL3","author":"deroad","description":"CRC-16 MODBUS checksum"},{"name":"crc16riello","license":"LGPL3","author":"deroad","description":"CRC-16 RIELLO checksum"},{"name":"crc16t10dif","license":"LGPL3","author":"deroad","description":"CRC-16 T10-DIF checksum"},{"name":"crc16teledisk","license":"LGPL3","author":"deroad","description":"CRC-16 TELEDISK checksum"},{"name":"crc16tms37157","license":"LGPL3","author":"deroad","description":"CRC-16 TMS37157 checksum"},{"name":"crc16usb","license":"LGPL3","author":"deroad","description":"CRC-16 USB checksum"},{"name":"crc16x25","license":"LGPL3","author":"deroad","description":"CRC-16 X25 checksum"},{"name":"crc16xmodem","license":"LGPL3","author":"deroad","description":"CRC-16 XMODEM checksum"},{"name":"crc24","license":"LGPL3","author":"deroad","description":"CRC-24 checksum"},{"name":"crc32","license":"LGPL3","author":"deroad","description":"CRC-32 checksum"},{"name":"crc32bzip2","license":"LGPL3","author":"deroad","description":"CRC-32 BZIP2 checksum"},{"name":"crc32c","license":"LGPL3","author":"deroad","description":"CRC-32C checksum"},{"name":"crc32d","license":"LGPL3","author":"deroad","description":"CRC-32D checksum"},{"name":"crc32ecma267","license":"LGPL3","author":"deroad","description":"CRC-32 ECMA-267 checksum (EDC for DVD sectors)"},{"name":"crc32jamcrc","license":"LGPL3","author":"deroad","description":"CRC-32 JAMCRC checksum"},{"name":"crc32mpeg2","license":"LGPL3","author":"deroad","description":"CRC-32 MPEG2 checksum"},{"name":"crc32posix","license":"LGPL3","author":"deroad","description":"CRC-32 POSIX checksum"},{"name":"crc32q","license":"LGPL3","author":"deroad","description":"CRC-32Q checksum"},{"name":"crc32xfer","license":"LGPL3","author":"deroad","description":"CRC-32 XFER checksum"},{"name":"crc64","license":"LGPL3","author":"deroad","description":"CRC-64 checksum"},{"name":"crc64ecma182","license":"LGPL3","author":"deroad","description":"CRC-64 ECMA-182 checksum"},{"name":"crc64iso","license":"LGPL3","author":"deroad","description":"CRC-64 ISO checksum"},{"name":"crc64we","license":"LGPL3","author":"deroad","description":"CRC-64 WE checksum"},{"name":"crc64xz","license":"LGPL3","author":"deroad","description":"CRC-64 XZ checksum"},{"name":"crc8cdma2000","license":"LGPL3","author":"deroad","description":"CRC-8 CDMA-2000 checksum"},{"name":"crc8darc","license":"LGPL3","author":"deroad","description":"CRC-8 DARC checksum"},{"name":"crc8dvbs2","license":"LGPL3","author":"deroad","description":"CRC-8 DVB-S2 checksum"},{"name":"crc8ebu","license":"LGPL3","author":"deroad","description":"CRC-8 EBU checksum"},{"name":"crc8icode","license":"LGPL3","author":"deroad","description":"CRC-8 I-CODE checksum"},{"name":"crc8itu","license":"LGPL3","author":"deroad","description":"CRC-8 ITU checksum"},{"name":"crc8maxim","license":"LGPL3","author":"deroad","description":"CRC-8 MAXIM checksum"},{"name":"crc8rohc","license":"LGPL3","author":"deroad","description":"CRC-8 ROHC checksum"},{"name":"crc8smbus","license":"LGPL3","author":"deroad","description":"CRC-8 SMBUS checksum"},{"name":"crc8wcdma","license":"LGPL3","author":"deroad","description":"CRC-8 WCDMA checksum"},{"name":"crca","license":"LGPL3","author":"deroad","description":"CRC-16/CRCA checksum"},{"name":"entropy","license":"LGPL3","author":"deroad","description":"Entropy [0.0-8.0] range"},{"name":"entropy_fract","license":"LGPL3","author":"deroad","description":"Fractional entropy [0.0-1.0] range"},{"name":"fletcher16","license":"LGPL3","author":"deroad","description":"Fletcher16 checksum"},{"name":"fletcher32","license":"LGPL3","author":"deroad","description":"Fletcher32 checksum"},{"name":"fletcher64","license":"LGPL3","author":"deroad","description":"Fletcher64 checksum"},{"name":"fletcher8","license":"LGPL3","author":"deroad","description":"Fletcher8 checksum"},{"name":"keccak-256","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-256 cryptographic hash"},{"name":"keccak-384","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-384 cryptographic hash"},{"name":"keccak-512","license":"BSD-3","author":"Andrey Jivsov","description":"KECCAK-512 cryptographic hash"},{"name":"md2","license":"LGPL3","author":"swedenspy","description":"MD2 cryptographic hash"},{"name":"md4","license":"LGPL3","author":"deroad","description":"MD4 cryptographic hash"},{"name":"md5","license":"LGPL2","author":"Alan DeKok","description":"MD5 cryptographic hash"},{"name":"mod255","license":"LGPL3","author":"deroad","description":"Modulo 255 checksum"},{"name":"murmur3-x64-128","license":"MIT","author":"Austin Appleby","description":"MurmurHash3 x64 128-bit non-cryptographic hash"},{"name":"murmur3-x86-128","license":"MIT","author":"Austin Appleby","description":"MurmurHash3 x86 128-bit non-cryptographic hash"},{"name":"murmur3-x86-32","license":"MIT","author":"Austin Appleby","description":"MurmurHash3 x86 32-bit non-cryptographic hash"},{"name":"parity","license":"LGPL3","author":"deroad","description":"Parity checksum"},{"name":"sha1","license":"LGPL3","author":"deroad","description":"SHA-1 cryptographic hash"},{"name":"sha256","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-256 cryptographic hash"},{"name":"sha3-224","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-224 cryptographic hash"},{"name":"sha3-256","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-256 cryptographic hash"},{"name":"sha3-384","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-384 cryptographic hash"},{"name":"sha3-512","license":"BSD-3","author":"Andrey Jivsov","description":"SHA3-512 cryptographic hash"},{"name":"sha384","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-384 cryptographic hash"},{"name":"sha512","license":"BSD-3","author":"Aaron D. Gifford","description":"SHA-512 cryptographic hash"},{"name":"sm3","license":"LGPL2","author":"FSF/deroad","description":"ShangMi 3 (SM3) cryptographic hash"},{"name":"ssdeep","license":"LGPL3","author":"deroad","description":"SSDeep Context Triggered Piecewise Hash (CTPH, fuzzy hash)"},{"name":"temperature","license":"LGPL3","author":"Seva","description":"Binary temperature [0.0-1.0] range"},{"name":"xor16","license":"LGPL3","author":"deroad","description":"XOR-16 checksum"},{"name":"xor8","license":"LGPL3","author":"deroad","description":"XOR-8 checksum"},{"name":"xxhash32","license":"LGPL3","author":"deroad","description":"xxHash32 non-cryptographic hash"}] +algorithm license author description +-------------------------------------------------------------------------------------------------------------- +adler32 LGPL3 deroad Adler-32 checksum +blake2b LGPL3 Farhan-25 BLAKE2b cryptographic hash +blake2bp LGPL3 Farhan-25 BLAKE2bp cryptographic hash +blake2s LGPL3 Farhan-25 BLAKE2s cryptographic hash +blake2sp LGPL3 Farhan-25 BLAKE2sp cryptographic hash +blake2xb LGPL3 Farhan-25 BLAKE2xb cryptographic hash +blake2xs LGPL3 Farhan-25 BLAKE2xs cryptographic hash +blake3 CC0 Samuel Neves,Jack O'Connor BLAKE3 cryptographic hash +crc15can LGPL3 deroad CRC-15 CAN checksum +crc16 LGPL3 deroad CRC-16 IBM/ARC checksum +crc16augccitt LGPL3 deroad CRC-16 AUG-CCITT checksum +crc16buypass LGPL3 deroad CRC-16 BUYPASS checksum +crc16cdma2000 LGPL3 deroad CRC-16 CDMA-2000 checksum +crc16citt LGPL3 deroad CRC-16 CITT checksum +crc16dds110 LGPL3 deroad CRC-16 DDS110 checksum +crc16dectr LGPL3 deroad CRC-16 DECT-R checksum +crc16dectx LGPL3 deroad CRC-16 DECT-X checksum +crc16dnp LGPL3 deroad CRC-16 DNP checksum +crc16en13757 LGPL3 deroad CRC-16 EN-13757 checksum +crc16genibus LGPL3 deroad CRC-16 GENIBUS checksum +crc16hdlc LGPL3 deroad CRC-16 HDLC checksum +crc16kermit LGPL3 deroad CRC-16 KERMIT checksum +crc16maxim LGPL3 deroad CRC-16 MAXIM checksum +crc16mcrf4xx LGPL3 deroad CRC-16 MCRF4XX checksum +crc16modbus LGPL3 deroad CRC-16 MODBUS checksum +crc16riello LGPL3 deroad CRC-16 RIELLO checksum +crc16t10dif LGPL3 deroad CRC-16 T10-DIF checksum +crc16teledisk LGPL3 deroad CRC-16 TELEDISK checksum +crc16tms37157 LGPL3 deroad CRC-16 TMS37157 checksum +crc16usb LGPL3 deroad CRC-16 USB checksum +crc16x25 LGPL3 deroad CRC-16 X25 checksum +crc16xmodem LGPL3 deroad CRC-16 XMODEM checksum +crc24 LGPL3 deroad CRC-24 checksum +crc32 LGPL3 deroad CRC-32 checksum +crc32bzip2 LGPL3 deroad CRC-32 BZIP2 checksum +crc32c LGPL3 deroad CRC-32C checksum +crc32d LGPL3 deroad CRC-32D checksum +crc32ecma267 LGPL3 deroad CRC-32 ECMA-267 checksum (EDC for DVD sectors) +crc32jamcrc LGPL3 deroad CRC-32 JAMCRC checksum +crc32mpeg2 LGPL3 deroad CRC-32 MPEG2 checksum +crc32posix LGPL3 deroad CRC-32 POSIX checksum +crc32q LGPL3 deroad CRC-32Q checksum +crc32xfer LGPL3 deroad CRC-32 XFER checksum +crc64 LGPL3 deroad CRC-64 checksum +crc64ecma182 LGPL3 deroad CRC-64 ECMA-182 checksum +crc64iso LGPL3 deroad CRC-64 ISO checksum +crc64we LGPL3 deroad CRC-64 WE checksum +crc64xz LGPL3 deroad CRC-64 XZ checksum +crc8cdma2000 LGPL3 deroad CRC-8 CDMA-2000 checksum +crc8darc LGPL3 deroad CRC-8 DARC checksum +crc8dvbs2 LGPL3 deroad CRC-8 DVB-S2 checksum +crc8ebu LGPL3 deroad CRC-8 EBU checksum +crc8icode LGPL3 deroad CRC-8 I-CODE checksum +crc8itu LGPL3 deroad CRC-8 ITU checksum +crc8maxim LGPL3 deroad CRC-8 MAXIM checksum +crc8rohc LGPL3 deroad CRC-8 ROHC checksum +crc8smbus LGPL3 deroad CRC-8 SMBUS checksum +crc8wcdma LGPL3 deroad CRC-8 WCDMA checksum +crca LGPL3 deroad CRC-16/CRCA checksum +entropy LGPL3 deroad Entropy [0.0-8.0] range +entropy_fract LGPL3 deroad Fractional entropy [0.0-1.0] range +fletcher16 LGPL3 deroad Fletcher16 checksum +fletcher32 LGPL3 deroad Fletcher32 checksum +fletcher64 LGPL3 deroad Fletcher64 checksum +fletcher8 LGPL3 deroad Fletcher8 checksum +keccak-256 BSD-3 Andrey Jivsov KECCAK-256 cryptographic hash +keccak-384 BSD-3 Andrey Jivsov KECCAK-384 cryptographic hash +keccak-512 BSD-3 Andrey Jivsov KECCAK-512 cryptographic hash +md2 LGPL3 swedenspy MD2 cryptographic hash +md4 LGPL3 deroad MD4 cryptographic hash +md5 LGPL2 Alan DeKok MD5 cryptographic hash +mod255 LGPL3 deroad Modulo 255 checksum +murmur3-x64-128 MIT Austin Appleby MurmurHash3 x64 128-bit non-cryptographic hash +murmur3-x86-128 MIT Austin Appleby MurmurHash3 x86 128-bit non-cryptographic hash +murmur3-x86-32 MIT Austin Appleby MurmurHash3 x86 32-bit non-cryptographic hash +parity LGPL3 deroad Parity checksum +sha1 LGPL3 deroad SHA-1 cryptographic hash +sha256 BSD-3 Aaron D. Gifford SHA-256 cryptographic hash +sha3-224 BSD-3 Andrey Jivsov SHA3-224 cryptographic hash +sha3-256 BSD-3 Andrey Jivsov SHA3-256 cryptographic hash +sha3-384 BSD-3 Andrey Jivsov SHA3-384 cryptographic hash +sha3-512 BSD-3 Andrey Jivsov SHA3-512 cryptographic hash +sha384 BSD-3 Aaron D. Gifford SHA-384 cryptographic hash +sha512 BSD-3 Aaron D. Gifford SHA-512 cryptographic hash +sm3 LGPL2 FSF/deroad ShangMi 3 (SM3) cryptographic hash +ssdeep LGPL3 deroad SSDeep Context Triggered Piecewise Hash (CTPH, fuzzy hash) +temperature LGPL3 Seva Binary temperature [0.0-1.0] range +xor16 LGPL3 deroad XOR-16 checksum +xor8 LGPL3 deroad XOR-8 checksum +xxhash32 LGPL3 deroad xxHash32 non-cryptographic hash adler32 blake2b blake2bp @@ -624,6 +630,9 @@ md2 md4 md5 mod255 +murmur3-x64-128 +murmur3-x86-128 +murmur3-x86-32 parity sha1 sha256 diff --git a/test/db/tools/rz_hash b/test/db/tools/rz_hash index 41bf41dcbc..e4ce678d48 100644 --- a/test/db/tools/rz_hash +++ b/test/db/tools/rz_hash @@ -280,6 +280,9 @@ ____hm md2 LGPL3 swedenspy MD2 cryptographi ____hm md4 LGPL3 deroad MD4 cryptographic hash ____hm md5 LGPL2 Alan DeKok MD5 cryptographic hash ____h_ mod255 LGPL3 deroad Modulo 255 checksum +____h_ murmur3-x64-128 MIT Austin Appleby MurmurHash3 x64 128-bit non-cryptographic hash +____h_ murmur3-x86-128 MIT Austin Appleby MurmurHash3 x86 128-bit non-cryptographic hash +____h_ murmur3-x86-32 MIT Austin Appleby MurmurHash3 x86 32-bit non-cryptographic hash ____h_ parity LGPL3 deroad Parity checksum ____hm sha1 LGPL3 deroad SHA-1 cryptographic hash ____hm sha256 BSD-3 Aaron D. Gifford SHA-256 cryptographic hash @@ -753,6 +756,9 @@ string: 0x00000000-0x00000005 md2: computed hash doesn't match the expected one string: 0x00000000-0x00000005 md4: computed hash doesn't match the expected one string: 0x00000000-0x00000005 md5: computed hash matches the expected one string: 0x00000000-0x00000005 mod255: computed hash doesn't match the expected one +string: 0x00000000-0x00000005 murmur3-x64-128: computed hash doesn't match the expected one +string: 0x00000000-0x00000005 murmur3-x86-128: computed hash doesn't match the expected one +string: 0x00000000-0x00000005 murmur3-x86-32: computed hash doesn't match the expected one string: 0x00000000-0x00000005 parity: computed hash doesn't match the expected one string: 0x00000000-0x00000005 sha1: computed hash doesn't match the expected one string: 0x00000000-0x00000005 sha256: computed hash doesn't match the expected one diff --git a/test/unit/test_hash.c b/test/unit/test_hash.c index 9955348387..3cd89a71cc 100644 --- a/test/unit/test_hash.c +++ b/test/unit/test_hash.c @@ -52,6 +52,9 @@ static hash_data_t hashes_to_test[] = { { INDATA("password"), .algo = "sha3-256", .expected = "c0067d4af4e87f00dbac63b6156828237059172d1bbeac67427345d6a9fda484" }, { INDATA("password"), .algo = "sha3-384", .expected = "9c1565e99afa2ce7800e96a73c125363c06697c5674d59f227b3368fd00b85ead506eefa90702673d873cb2c9357eafc" }, { INDATA("password"), .algo = "sha3-512", .expected = "e9a75486736a550af4fea861e2378305c4a555a05094dee1dca2f68afea49cc3a50e8de6ea131ea521311f4d6fb054a146e8282f8e35ff2e6368c1a62e909716" }, + { INDATA("password"), .algo = "murmur3-x86-32", .expected = "7cc00d26" }, + { INDATA("password"), .algo = "murmur3-x86-128", .expected = "695a03df695a03df5bcfb52d38c8196c" }, + { INDATA("password"), .algo = "murmur3-x64-128", .expected = "4f345112bc5a9590d5bd0cde2957bf46" }, { INDATA("password"), .algo = "keccak-256", .expected = "b68fe43f0d1a0d7aef123722670be50268e15365401c442f8806ef83b612976b" }, { INDATA("password"), .algo = "keccak-384", .expected = "e0779e9bb200a589bc70e499a9f7db1006e181519394990ef41800bebe452c23b4a8372fd89df8d5e0d951af240be7bc" }, { INDATA("password"), .algo = "keccak-512", .expected = "a6818b8188b36c44d17784c5551f63accc5deaf8786f9d0ad1ae3cd8d887cbab4f777286dbb315fb14854c8774dc0d10b5567e4a705536cc2a1d61ec0a16a7a6" },