Rizin
unix-like reverse engineering framework and cli tools
algo_entropy_fractional.c File Reference

Go to the source code of this file.

Functions

static void * plugin_entropy_context_new ()
 
static void plugin_entropy_context_free (void *context)
 
static RzHashSize plugin_entropy_digest_size (void *context)
 
static RzHashSize plugin_entropy_block_size (void *context)
 
static bool plugin_entropy_init (void *context)
 
static bool plugin_entropy_update (void *context, const ut8 *data, ut64 size)
 
static bool plugin_entropy_final (void *context, ut8 *digest)
 
static bool plugin_entropy_small_block (const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size)
 

Variables

RzHashPlugin rz_hash_plugin_entropy_fract
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ plugin_entropy_block_size()

static RzHashSize plugin_entropy_block_size ( void *  context)
static

Definition at line 21 of file algo_entropy_fractional.c.

21  {
22  return 0;
23 }

◆ plugin_entropy_context_free()

static void plugin_entropy_context_free ( void *  context)
static

Definition at line 13 of file algo_entropy_fractional.c.

13  {
14  free(context);
15 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130

References free().

◆ plugin_entropy_context_new()

static void* plugin_entropy_context_new ( )
static

Definition at line 9 of file algo_entropy_fractional.c.

9  {
10  return RZ_NEW0(RzEntropy);
11 }
#define RZ_NEW0(x)
Definition: rz_types.h:284

References RZ_NEW0.

◆ plugin_entropy_digest_size()

static RzHashSize plugin_entropy_digest_size ( void *  context)
static

Definition at line 17 of file algo_entropy_fractional.c.

17  {
18  return sizeof(double);
19 }

◆ plugin_entropy_final()

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

Definition at line 39 of file algo_entropy_fractional.c.

39  {
40  rz_return_val_if_fail(context && digest, false);
41 
42  rz_entropy_final(digest, (RzEntropy *)context, true);
43  return true;
44 }
bool rz_entropy_final(ut8 *digest, RzEntropy *ctx, bool fraction)
Definition: entropy.c:24
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108

References rz_entropy_final(), and rz_return_val_if_fail.

◆ plugin_entropy_init()

static bool plugin_entropy_init ( void *  context)
static

Definition at line 25 of file algo_entropy_fractional.c.

25  {
27 
29  return true;
30 }
bool rz_entropy_init(RzEntropy *ctx)
Definition: entropy.c:9

References rz_entropy_init(), and rz_return_val_if_fail.

◆ plugin_entropy_small_block()

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

Definition at line 46 of file algo_entropy_fractional.c.

46  {
47  rz_return_val_if_fail(data && digest, false);
48  ut8 *dgst = malloc(sizeof(double));
49  if (!dgst) {
50  return false;
51  }
52 
53  RzEntropy ctx;
55  rz_entropy_update(&ctx, data, size);
56  rz_entropy_final(dgst, &ctx, true);
57 
58  *digest = dgst;
59  if (digest_size) {
60  *digest_size = sizeof(double);
61  }
62  return true;
63 }
bool rz_entropy_update(RzEntropy *ctx, const ut8 *data, size_t len)
Definition: entropy.c:15
voidpf void uLong size
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * malloc(size_t size)
Definition: malloc.c:123

References malloc(), rz_entropy_final(), rz_entropy_init(), rz_entropy_update(), and rz_return_val_if_fail.

◆ plugin_entropy_update()

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

Definition at line 32 of file algo_entropy_fractional.c.

32  {
33  rz_return_val_if_fail(context && data, false);
34 
36  return true;
37 }

References rz_entropy_update(), and rz_return_val_if_fail.

Variable Documentation

◆ rizin_plugin

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

Definition at line 81 of file algo_entropy_fractional.c.

◆ rz_hash_plugin_entropy_fract

RzHashPlugin rz_hash_plugin_entropy_fract
Initial value:
= {
.name = "entropy_fract",
.license = "LGPL3",
.author = "deroad",
.support_hmac = false,
.context_free = plugin_entropy_context_free,
}
static bool plugin_entropy_init(void *context)
static void plugin_entropy_context_free(void *context)
static RzHashSize plugin_entropy_block_size(void *context)
static void * plugin_entropy_context_new()
static RzHashSize plugin_entropy_digest_size(void *context)
static bool plugin_entropy_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size)
static bool plugin_entropy_final(void *context, ut8 *digest)
static bool plugin_entropy_update(void *context, const ut8 *data, ut64 size)

Definition at line 65 of file algo_entropy_fractional.c.

Referenced by rz_hash_entropy_fraction().