Rizin
unix-like reverse engineering framework and cli tools
algo_xxhash32.c File Reference
#include <rz_hash.h>
#include <rz_util/rz_assert.h>
#include <xxhash.h>

Go to the source code of this file.

Macros

#define RZ_HASH_XXHASH32_DIGEST_SIZE   4
 
#define RZ_HASH_XXHASH32_BLOCK_LENGTH   0
 

Functions

static void * plugin_xxhash32_context_new ()
 
static void plugin_xxhash32_context_free (void *context)
 
static RzHashSize plugin_xxhash32_digest_size (void *context)
 
static RzHashSize plugin_xxhash32_block_size (void *context)
 
static bool plugin_xxhash32_init (void *context)
 
static bool plugin_xxhash32_update (void *context, const ut8 *data, ut64 size)
 
static bool plugin_xxhash32_final (void *context, ut8 *digest)
 
static bool plugin_xxhash32_small_block (const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size)
 

Variables

RzHashPlugin rz_hash_plugin_xxhash32
 
RZ_API RzLibStruct rizin_plugin
 

Macro Definition Documentation

◆ RZ_HASH_XXHASH32_BLOCK_LENGTH

#define RZ_HASH_XXHASH32_BLOCK_LENGTH   0

Definition at line 9 of file algo_xxhash32.c.

◆ RZ_HASH_XXHASH32_DIGEST_SIZE

#define RZ_HASH_XXHASH32_DIGEST_SIZE   4

Definition at line 8 of file algo_xxhash32.c.

Function Documentation

◆ plugin_xxhash32_block_size()

static RzHashSize plugin_xxhash32_block_size ( void *  context)
static

Definition at line 23 of file algo_xxhash32.c.

23  {
25 }
#define RZ_HASH_XXHASH32_BLOCK_LENGTH
Definition: algo_xxhash32.c:9

References RZ_HASH_XXHASH32_BLOCK_LENGTH.

◆ plugin_xxhash32_context_free()

static void plugin_xxhash32_context_free ( void *  context)
static

Definition at line 15 of file algo_xxhash32.c.

15  {
17 }
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t *statePtr)
Definition: xxhash.c:426
struct XXH32_state_s XXH32_state_t
Definition: xxhash.h:172

References XXH32_freeState().

◆ plugin_xxhash32_context_new()

static void* plugin_xxhash32_context_new ( )
static

Definition at line 11 of file algo_xxhash32.c.

11  {
12  return XXH32_createState();
13 }
XXH_PUBLIC_API XXH32_state_t * XXH32_createState(void)
Definition: xxhash.c:422

References XXH32_createState().

◆ plugin_xxhash32_digest_size()

static RzHashSize plugin_xxhash32_digest_size ( void *  context)
static

Definition at line 19 of file algo_xxhash32.c.

19  {
21 }
#define RZ_HASH_XXHASH32_DIGEST_SIZE
Definition: algo_xxhash32.c:8

References RZ_HASH_XXHASH32_DIGEST_SIZE.

◆ plugin_xxhash32_final()

static bool plugin_xxhash32_final ( void *  context,
ut8 digest 
)
static

Definition at line 41 of file algo_xxhash32.c.

41  {
42  rz_return_val_if_fail(context && digest, false);
43 
45  rz_write_le32(digest, dgst);
46  return true;
47 }
uint32_t ut32
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
Definition: xxhash.c:546
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static void rz_write_le32(void *dest, ut32 val)
Definition: rz_endian.h:256

References rz_return_val_if_fail, rz_write_le32(), and XXH32_digest().

◆ plugin_xxhash32_init()

static bool plugin_xxhash32_init ( void *  context)
static

Definition at line 27 of file algo_xxhash32.c.

27  {
29 
31  return true;
32 }
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, unsigned int seed)
Definition: xxhash.c:437

References rz_return_val_if_fail, and XXH32_reset().

◆ plugin_xxhash32_small_block()

static bool plugin_xxhash32_small_block ( const ut8 data,
ut64  size,
ut8 **  digest,
RzHashSize digest_size 
)
static

Definition at line 49 of file algo_xxhash32.c.

49  {
50  rz_return_val_if_fail(data && digest, false);
52  if (!dgst) {
53  return false;
54  }
55 
56  ut32 result = XXH32(data, size, 0);
57  rz_write_le32(dgst, result);
58 
59  *digest = dgst;
60  if (digest_size) {
61  *digest_size = RZ_HASH_XXHASH32_DIGEST_SIZE;
62  }
63  return true;
64 }
voidpf void uLong size
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * malloc(size_t size)
Definition: malloc.c:123
XXH_PUBLIC_API unsigned int XXH32(const void *input, size_t len, unsigned int seed)
Definition: xxhash.c:392

References malloc(), RZ_HASH_XXHASH32_DIGEST_SIZE, rz_return_val_if_fail, rz_write_le32(), and XXH32().

◆ plugin_xxhash32_update()

static bool plugin_xxhash32_update ( void *  context,
const ut8 data,
ut64  size 
)
static

Definition at line 34 of file algo_xxhash32.c.

34  {
35  rz_return_val_if_fail(context && data, false);
36 
38  return true;
39 }
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
Definition: xxhash.c:515

References rz_return_val_if_fail, and XXH32_update().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.version = RZ_VERSION
}
RzHashPlugin rz_hash_plugin_xxhash32
Definition: algo_xxhash32.c:66
@ RZ_LIB_TYPE_HASH
Definition: rz_lib.h:82
#define RZ_VERSION
Definition: rz_version.h:8

Definition at line 82 of file algo_xxhash32.c.

◆ rz_hash_plugin_xxhash32

RzHashPlugin rz_hash_plugin_xxhash32
Initial value:
= {
.name = "xxhash32",
.license = "LGPL3",
.author = "deroad",
.support_hmac = false,
}
static void plugin_xxhash32_context_free(void *context)
Definition: algo_xxhash32.c:15
static bool plugin_xxhash32_init(void *context)
Definition: algo_xxhash32.c:27
static void * plugin_xxhash32_context_new()
Definition: algo_xxhash32.c:11
static bool plugin_xxhash32_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size)
Definition: algo_xxhash32.c:49
static bool plugin_xxhash32_update(void *context, const ut8 *data, ut64 size)
Definition: algo_xxhash32.c:34
static RzHashSize plugin_xxhash32_digest_size(void *context)
Definition: algo_xxhash32.c:19
static bool plugin_xxhash32_final(void *context, ut8 *digest)
Definition: algo_xxhash32.c:41
static RzHashSize plugin_xxhash32_block_size(void *context)
Definition: algo_xxhash32.c:23

Definition at line 66 of file algo_xxhash32.c.