Rizin
unix-like reverse engineering framework and cli tools
hash.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "config.h"
5 #include <rz_hash.h>
6 #include <rz_util.h>
7 #include <xxhash.h>
8 
9 RZ_LIB_VERSION(rz_hash);
10 
11 #define hash_cfg_can_hmac(c) ((c)->status == RZ_MSG_DIGEST_STATUS_ALLOC)
12 #define hash_cfg_can_init(c) ((c)->status == RZ_MSG_DIGEST_STATUS_FINAL || (c)->status == RZ_MSG_DIGEST_STATUS_ALLOC)
13 #define hash_cfg_can_update(c) ((c)->status == RZ_MSG_DIGEST_STATUS_INIT || (c)->status == RZ_MSG_DIGEST_STATUS_UPDATE)
14 #define hash_cfg_can_final(c) ((c)->status == RZ_MSG_DIGEST_STATUS_ALLOC || (c)->status == RZ_MSG_DIGEST_STATUS_INIT || (c)->status == RZ_MSG_DIGEST_STATUS_UPDATE)
15 #define hash_cfg_has_finshed(c) ((c)->status == RZ_MSG_DIGEST_STATUS_FINAL)
16 
17 typedef struct hash_cfg_config_t {
18  void *context;
24 
26 
29  return XXH32(input, size, 0);
30 }
31 
33  rz_return_val_if_fail(data, 0.0);
34  const RzHashPlugin *plugin = &rz_hash_plugin_entropy;
35  ut8 *digest = NULL;
36  if (!plugin->small_block(data, len, &digest, NULL)) {
37  RZ_LOG_ERROR("msg digest: cannot calculate entropy\n");
38  return 0.0;
39  }
40  double e = rz_read_be_double(digest);
41  free(digest);
42  return e;
43 }
44 
46  rz_return_val_if_fail(data, 0.0);
48  ut8 *digest = NULL;
49  if (!plugin->small_block(data, len, &digest, NULL)) {
50  RZ_LOG_ERROR("msg digest: cannot calculate entropy fraction\n");
51  return 0.0;
52  }
53  double e = rz_read_be_double(digest);
54  free(digest);
55  return e;
56 }
57 
58 static int hash_cfg_config_compare(const void *value, const void *data) {
59  const HashCfgConfig *mdc = (const HashCfgConfig *)data;
60  const char *name = (const char *)value;
61  return strcmp(name, mdc->plugin->name);
62 }
63 
65  rz_return_if_fail(mdc && mdc->plugin);
66 
67  mdc->plugin->context_free(mdc->context);
68  free(mdc->hmac_key);
69  free(mdc->digest);
70  free(mdc);
71 }
72 
74  rz_return_val_if_fail(plugin, NULL);
75 
77  if (!mdc) {
78  RZ_LOG_ERROR("msg digest: cannot allocate memory for config.\n");
79  return NULL;
80  }
81 
82  mdc->context = plugin->context_new();
83  if (!mdc->context) {
84  RZ_LOG_ERROR("msg digest: cannot allocate memory for context.\n");
85  free(mdc);
86  return NULL;
87  }
88 
89  mdc->digest_size = plugin->digest_size(mdc->context);
90  rz_warn_if_fail(mdc->digest_size > 0);
91 
92  mdc->digest = RZ_NEWS0(ut8, mdc->digest_size);
93  if (!mdc->context) {
94  RZ_LOG_ERROR("msg digest: cannot allocate memory for digest.\n");
95  plugin->context_free(mdc->context);
96  free(mdc);
97  return NULL;
98  }
99  mdc->plugin = plugin;
100 
101  return mdc;
102 }
103 
106 
107  RzListIter *it;
108  const RzHashPlugin *rhp;
109  size_t i = 0;
110 
111  rz_list_foreach (rh->plugins, it, rhp) {
112  if (i == index) {
113  return rhp;
114  }
115  i++;
116  }
117  return NULL;
118 }
119 
122 
123  RzListIter *it;
124  const RzHashPlugin *rhp;
125 
126  rz_list_foreach (rh->plugins, it, rhp) {
127  if (!strcmp(rhp->name, name)) {
128  return rhp;
129  }
130  }
131  return NULL;
132 }
133 
136 
138  if (!md) {
139  RZ_LOG_ERROR("msg digest: cannot allocate memory.\n");
140  return NULL;
141  }
142 
143  md->configurations = rz_list_newf((RzListFree)hash_cfg_config_free);
144  if (!md->configurations) {
145  RZ_LOG_ERROR("msg digest: cannot allocate memory for the configurations.\n");
146  free(md);
147  return NULL;
148  }
149  md->hash = rh;
150 
151  return md;
152 }
153 
164  if (!md) {
165  return NULL;
166  }
167 
168  if (!rz_hash_cfg_configure(md, name)) {
170  return NULL;
171  }
172 
173  if (key && !rz_hash_cfg_hmac(md, key, key_size)) {
175  return NULL;
176  }
177 
178  if (!rz_hash_cfg_init(md)) {
180  return NULL;
181  }
182 
183  return md;
184 }
185 
188 
189  rz_list_free(md->configurations);
190  free(md);
191 }
192 
200  rz_return_val_if_fail(md && name, false);
201 
202  if (rz_list_find(md->configurations, name, hash_cfg_config_compare)) {
203  RZ_LOG_WARN("msg digest: '%s' was already configured; skipping.\n", name);
204  return false;
205  }
206 
207  bool is_all = !strcmp(name, "all");
208 
209  if (is_all && rz_list_length(md->configurations) > 0) {
210  RZ_LOG_WARN("msg digest: '%s' was already configured; skipping.\n", name);
211  return false;
212  }
213 
214  HashCfgConfig *mdc = NULL;
215  RzListIter *it;
216  const RzHashPlugin *plugin;
217 
218  rz_list_foreach (md->hash->plugins, it, plugin) {
219  if (is_all || !strcmp(plugin->name, name)) {
220  mdc = hash_cfg_config_new(plugin);
221  if (!mdc) {
222  return false;
223  }
224 
225  if (!rz_list_append(md->configurations, mdc)) {
226  RZ_LOG_ERROR("msg digest: cannot allocate memory for list entry.\n");
228  return false;
229  }
230 
231  if (!is_all) {
232  return true;
233  }
234  }
235  }
236 
237  if (is_all) {
238  return true;
239  }
240 
241  RZ_LOG_ERROR("msg digest: '%s' does not exists.\n", name);
242  return false;
243 }
244 
251  rz_return_val_if_fail(md && key && key_size && hash_cfg_can_hmac(md), false);
252 
253  RzHashSize block_size = 0;
254  RzListIter *iter = NULL;
255  HashCfgConfig *mdc = NULL;
256  rz_list_foreach (md->configurations, iter, mdc) {
257  if (!mdc->plugin->support_hmac) {
258  // RZ_LOG_ERROR("msg digest: hmac is not supported by %s.\n", mdc->plugin->name);
259  continue;
260  }
261 
262  block_size = mdc->plugin->block_size(mdc->context);
263  if (block_size < 1) {
264  RZ_LOG_ERROR("msg digest: hmac block size is < 1.\n");
265  return false;
266  }
267 
268  mdc->hmac_key = malloc(block_size);
269  if (!mdc->hmac_key) {
270  RZ_LOG_ERROR("msg digest: cannot allocate memory for hmac key.\n");
271  return false;
272  }
273 
274  memset(mdc->hmac_key, 0, block_size);
275  if (block_size < key_size) {
276  RzHashSize tmp_size;
277  ut8 *tmp = NULL;
278  if (!mdc->plugin->small_block(key, key_size, &tmp, &tmp_size)) {
279  RZ_LOG_ERROR("msg digest: failed to call init for hmac %s key.\n", mdc->plugin->name);
280  return false;
281  }
282  memcpy(mdc->hmac_key, tmp, tmp_size);
283  free(tmp);
284  } else {
285  memcpy(mdc->hmac_key, key, key_size);
286  }
287  }
288 
289  return true;
290 }
291 
300 
301  RzListIter *iter = NULL;
302  HashCfgConfig *mdc = NULL;
303  rz_list_foreach (md->configurations, iter, mdc) {
304  if (!mdc->plugin->init(mdc->context)) {
305  RZ_LOG_ERROR("msg digest: failed to call init for %s.\n", mdc->plugin->name);
306  return false;
307  }
308  if (mdc->hmac_key) {
309  RzHashSize block_size = mdc->plugin->block_size(mdc->context);
310  ut8 *i_pad = malloc(block_size);
311  if (!i_pad) {
312  RZ_LOG_ERROR("msg digest: failed to allocate memory for ipad.\n");
313  return false;
314  }
315  for (ut32 i = 0; i < block_size; i++) {
316  i_pad[i] = 0x36 ^ mdc->hmac_key[i];
317  }
318  if (!mdc->plugin->update(mdc->context, i_pad, block_size)) {
319  RZ_LOG_ERROR("msg digest: failed to call update for hmac %s ipad.\n", mdc->plugin->name);
320  free(i_pad);
321  return false;
322  }
323  free(i_pad);
324  }
325  }
326 
327  md->status = RZ_MSG_DIGEST_STATUS_INIT;
328  return true;
329 }
330 
339 
340  RzListIter *iter = NULL;
341  HashCfgConfig *mdc = NULL;
342  rz_list_foreach (md->configurations, iter, mdc) {
343  if (!mdc->plugin->update(mdc->context, data, size)) {
344  RZ_LOG_ERROR("msg digest: failed to call update for %s.\n", mdc->plugin->name);
345  return false;
346  }
347  }
348 
350  return true;
351 }
352 
361 
362  RzListIter *iter = NULL;
363  HashCfgConfig *mdc = NULL;
364  rz_list_foreach (md->configurations, iter, mdc) {
365  if (!mdc->plugin->final(mdc->context, mdc->digest)) {
366  RZ_LOG_ERROR("msg digest: failed to call final for %s.\n", mdc->plugin->name);
367  return false;
368  }
369 
370  if (mdc->hmac_key) {
371  RzHashSize block_size = mdc->plugin->block_size(mdc->context);
372  ut8 *o_pad = malloc(block_size);
373  if (!o_pad) {
374  RZ_LOG_ERROR("msg digest: failed to allocate memory for opad.\n");
375  return false;
376  }
377 
378  for (ut32 i = 0; i < block_size; i++) {
379  o_pad[i] = 0x5c ^ mdc->hmac_key[i];
380  }
381 
382  if (!mdc->plugin->init(mdc->context)) {
383  RZ_LOG_ERROR("msg digest: failed to call init for hmac %s opad.\n", mdc->plugin->name);
384  free(o_pad);
385  return false;
386  }
387  if (!mdc->plugin->update(mdc->context, o_pad, block_size)) {
388  RZ_LOG_ERROR("msg digest: failed to call update for hmac %s opad.\n", mdc->plugin->name);
389  free(o_pad);
390  return false;
391  }
392  free(o_pad);
393  if (!mdc->plugin->update(mdc->context, mdc->digest, mdc->digest_size)) {
394  RZ_LOG_ERROR("msg digest: failed to call update for hmac %s opad.\n", mdc->plugin->name);
395  return false;
396  }
397  if (!mdc->plugin->final(mdc->context, mdc->digest)) {
398  RZ_LOG_ERROR("msg digest: failed to call final for hmac %s opad.\n", mdc->plugin->name);
399  return false;
400  }
401  }
402  }
403 
404  md->status = RZ_MSG_DIGEST_STATUS_FINAL;
405  return true;
406 }
407 
416 
417  RzListIter *iter = NULL;
418  HashCfgConfig *mdc = NULL;
419  rz_list_foreach (md->configurations, iter, mdc) {
420  for (size_t i = 0; i < iterate; ++i) {
421  if (!mdc->plugin->init(mdc->context)) {
422  RZ_LOG_ERROR("msg digest: failed to call init %s for iteration.\n", mdc->plugin->name);
423  return false;
424  }
425  if (!mdc->plugin->update(mdc->context, mdc->digest, mdc->digest_size)) {
426  RZ_LOG_ERROR("msg digest: failed to call update %s for iteration.\n", mdc->plugin->name);
427  return false;
428  }
429  if (!mdc->plugin->final(mdc->context, mdc->digest)) {
430  RZ_LOG_ERROR("msg digest: failed to call final %s for iteration.\n", mdc->plugin->name);
431  return false;
432  }
433  }
434  }
435 
436  return true;
437 }
438 
447 
448  RzListIter *it = rz_list_find(md->configurations, name, hash_cfg_config_compare);
449  if (!it) {
450  RZ_LOG_ERROR("msg digest: cannot find configuration for '%s' algorithm.\n", name);
451  return NULL;
452  }
453 
456 
457  if (size) {
458  *size = mdc->digest_size;
459  }
460  return mdc->digest;
461 }
462 
471 
472  ut32 pos = 0;
473  RzListIter *it = rz_list_find(md->configurations, name, hash_cfg_config_compare);
474  if (!it) {
475  RZ_LOG_ERROR("msg digest: cannot find configuration for '%s' algorithm.\n", name);
476  return NULL;
477  }
478 
481 
482  if (!strncmp(name, "entropy", 7)) {
483  double entropy = rz_read_be_double(mdc->digest);
484  return rz_str_newf("%.8f", entropy);
485  }
486 
487  char *string = malloc((mdc->digest_size * 2) + 1);
488  if (!string) {
489  RZ_LOG_ERROR("msg digest: cannot find allocate memory for string result.\n");
490  return NULL;
491  }
492 
493  for (ut32 i = 0; i < mdc->digest_size; i++) {
494  pos = invert ? (mdc->digest_size - 1 - i) : i;
495  sprintf(&string[i * 2], "%02x", mdc->digest[pos]);
496  }
497  string[mdc->digest_size * 2] = 0;
498 
499  if (size) {
500  *size = (mdc->digest_size * 2) + 1;
501  }
502  return string;
503 }
504 
512 
513  RzListIter *it = rz_list_find(md->configurations, name, hash_cfg_config_compare);
514  if (!it) {
515  RZ_LOG_ERROR("msg digest: cannot find configuration for '%s' algorithm.\n", name);
516  return 0;
517  }
518 
520  rz_return_val_if_fail(mdc, 0);
521  return mdc->plugin->digest_size(mdc->context);
522 }
523 
531 
532  ut8 *result = NULL;
533  const RzHashPlugin *plugin = rz_hash_plugin_by_name(rh, name);
534  if (!plugin) {
535  return NULL;
536  }
537 
538  if (!plugin->small_block(buffer, bsize, &result, osize)) {
539  RZ_LOG_ERROR("msg digest: cannot calculate small block with %s.\n", plugin->name);
540  return NULL;
541  }
542  return result;
543 }
544 
547 
548  ut32 pos = 0;
549  RzHashSize digest_size = 0;
550  ut8 *digest = NULL;
551  if (!(digest = rz_hash_cfg_calculate_small_block(rh, name, buffer, bsize, &digest_size))) {
552  return NULL;
553  }
554 
555  if (!strncmp(name, "entropy", 7)) {
556  double entropy = rz_read_be_double(digest);
557  free(digest);
558  return rz_str_newf("%.8f", entropy);
559  }
560 
561  char *string = malloc((digest_size * 2) + 1);
562  if (!string) {
563  RZ_LOG_ERROR("msg digest: cannot find allocate memory for string result.\n");
564  free(digest);
565  return NULL;
566  }
567 
568  for (ut32 i = 0; i < digest_size; i++) {
569  pos = invert ? (digest_size - 1 - i) : i;
570  sprintf(&string[i * 2], "%02x", digest[pos]);
571  }
572  string[digest_size * 2] = 0;
573 
574  if (size) {
575  *size = (digest_size * 2) + 1;
576  }
577  free(digest);
578  return string;
579 }
580 
586  RzHash *rh = RZ_NEW0(RzHash);
587  if (!rh) {
588  return NULL;
589  }
590  rh->plugins = rz_list_new();
591  for (int i = 0; i < RZ_ARRAY_SIZE(hash_static_plugins); i++) {
593  }
594  return rh;
595 }
596 
598  if (!rh) {
599  return;
600  }
601  rz_list_free(rh->plugins);
602  free(rh);
603 }
604 
610  if (!plugin) {
611  return false;
612  }
613  RzListIter *it;
614  RzHashPlugin *p;
615 
616  rz_list_foreach (rh->plugins, it, p) {
617  if (!strcmp(p->name, plugin->name)) {
618  return false;
619  }
620  }
621  rz_list_append(rh->plugins, (RzHashPlugin *)plugin);
622  return true;
623 }
size_t len
Definition: 6502dis.c:15
static unsigned invert(unsigned x)
Definition: aesdata.c:73
RzHashPlugin rz_hash_plugin_entropy
Definition: algo_entropy.c:65
RzHashPlugin rz_hash_plugin_entropy_fract
#define e(frag)
lzma_index ** i
Definition: index.h:629
#define RZ_HASH_STATIC_PLUGINS
Definition: config.h:25
static int value
Definition: cmd_api.c:93
#define RZ_API
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
uint32_t ut32
RZ_LIB_VERSION(rz_hash)
RZ_API double rz_hash_entropy_fraction(RZ_NONNULL RzHash *rh, RZ_NONNULL const ut8 *data, ut64 len)
Definition: hash.c:45
RZ_API RZ_BORROW const ut8 * rz_hash_cfg_get_result(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name, RZ_NONNULL ut32 *size)
Returns the digest value of the requested algorithm name.
Definition: hash.c:445
RZ_API RZ_OWN RzHashCfg * rz_hash_cfg_new(RZ_NONNULL RzHash *rh)
Definition: hash.c:134
RZ_API bool rz_hash_plugin_add(RZ_NONNULL RzHash *rh, RZ_NONNULL RZ_OWN const RzHashPlugin *plugin)
Add a new plugin to rh so that RzHashCfg can be created using specific algorithms.
Definition: hash.c:609
#define hash_cfg_can_update(c)
Definition: hash.c:13
RZ_API RZ_OWN char * rz_hash_cfg_calculate_small_block_string(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NONNULL const ut8 *buffer, ut64 bsize, RZ_NULLABLE ut32 *size, bool invert)
Definition: hash.c:545
RZ_API void rz_hash_cfg_free(RZ_NONNULL RzHashCfg *md)
Definition: hash.c:186
#define hash_cfg_can_hmac(c)
Definition: hash.c:11
RZ_API bool rz_hash_cfg_iterate(RZ_NONNULL RzHashCfg *md, size_t iterate)
Calculate the final hash by iterating its result N times.
Definition: hash.c:414
RZ_API RzHashSize rz_hash_cfg_size(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name)
Returns the digest size of the requested algorithm name.
Definition: hash.c:510
RZ_API void rz_hash_free(RzHash *rh)
Definition: hash.c:597
RZ_API RZ_BORROW const RzHashPlugin * rz_hash_plugin_by_name(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name)
Definition: hash.c:120
#define hash_cfg_can_final(c)
Definition: hash.c:14
#define hash_cfg_has_finshed(c)
Definition: hash.c:15
static HashCfgConfig * hash_cfg_config_new(const RzHashPlugin *plugin)
Definition: hash.c:73
RZ_API RZ_BORROW const RzHashPlugin * rz_hash_plugin_by_index(RZ_NONNULL RzHash *rh, size_t index)
Definition: hash.c:104
RZ_API ut32 rz_hash_xxhash(RZ_NONNULL RzHash *rh, RZ_NONNULL const ut8 *input, size_t size)
Definition: hash.c:27
RZ_API RzHash * rz_hash_new(void)
Definition: hash.c:585
RZ_API RZ_OWN ut8 * rz_hash_cfg_calculate_small_block(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NONNULL const ut8 *buffer, ut64 bsize, RZ_NONNULL RzHashSize *osize)
Returns the digest size of the requested algorithm name.
Definition: hash.c:529
RZ_API RZ_OWN RzHashCfg * rz_hash_cfg_new_with_algo(RZ_NONNULL RzHash *rh, RZ_NONNULL const char *name, RZ_NULLABLE const ut8 *key, ut64 key_size)
Returns a message digest context with the give algo already configured.
Definition: hash.c:161
static int hash_cfg_config_compare(const void *value, const void *data)
Definition: hash.c:58
struct hash_cfg_config_t HashCfgConfig
static void hash_cfg_config_free(HashCfgConfig *mdc)
Definition: hash.c:64
RZ_API bool rz_hash_cfg_configure(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name)
Allocates and configures the plugin message digest context.
Definition: hash.c:199
RZ_API double rz_hash_entropy(RZ_NONNULL RzHash *rh, RZ_NONNULL const ut8 *data, ut64 len)
Definition: hash.c:32
RZ_API bool rz_hash_cfg_hmac(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const ut8 *key, ut64 key_size)
Sets the key for the hmac algorithm.
Definition: hash.c:250
#define hash_cfg_can_init(c)
Definition: hash.c:12
RZ_API bool rz_hash_cfg_init(RZ_NONNULL RzHashCfg *md)
Resets/initialize the message digest contextes.
Definition: hash.c:298
RZ_API bool rz_hash_cfg_update(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const ut8 *data, ut64 size)
Inserts data into each the message digest contextes.
Definition: hash.c:337
RZ_API bool rz_hash_cfg_final(RZ_NONNULL RzHashCfg *md)
Generates the final value of the message digest contextes.
Definition: hash.c:359
static const RzHashPlugin * hash_static_plugins[]
Definition: hash.c:25
RZ_API RZ_OWN char * rz_hash_cfg_get_result_string(RZ_NONNULL RzHashCfg *md, RZ_NONNULL const char *name, RZ_NULLABLE ut32 *size, bool invert)
Returns the digest value of the requested algorithm name.
Definition: hash.c:469
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
sprintf
Definition: kernel.h:365
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RZ_BORROW RzListIter * rz_list_find(RZ_NONNULL const RzList *list, const void *p, RZ_NONNULL RzListComparator cmp)
Returns RzListIter element which matches via the RzListComparator.
Definition: list.c:620
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API void * rz_list_iter_get_data(RzListIter *list)
returns the value stored in the list element
Definition: list.c:42
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
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
#define rz_warn_if_fail(expr)
Definition: rz_assert.h:35
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static double rz_read_be_double(const void *src)
Definition: rz_endian.h:157
@ RZ_MSG_DIGEST_STATUS_INIT
Definition: rz_hash.h:19
@ RZ_MSG_DIGEST_STATUS_UPDATE
Definition: rz_hash.h:20
@ RZ_MSG_DIGEST_STATUS_FINAL
Definition: rz_hash.h:21
ut32 RzHashSize
Definition: rz_hash.h:24
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define RZ_BORROW
Definition: rz_types.h:63
Definition: buffer.h:15
ut8 * hmac_key
Definition: hash.c:20
ut8 * digest
Definition: hash.c:19
RzHashSize digest_size
Definition: hash.c:21
const RzHashPlugin * plugin
Definition: hash.c:22
void * context
Definition: hash.c:18
Definition: z80asm.h:102
const char * name
Definition: rz_hash.h:27
bool support_hmac
Definition: rz_hash.h:30
RzHashSize(* block_size)(void *context)
Definition: rz_hash.h:34
RzHashSize(* digest_size)(void *context)
Definition: rz_hash.h:33
bool(* small_block)(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size)
Definition: rz_hash.h:38
bool(* update)(void *context, const ut8 *data, ut64 size)
Definition: rz_hash.h:36
bool(* init)(void *context)
Definition: rz_hash.h:35
void(* context_free)(void *context)
Definition: rz_hash.h:32
bool(* final)(void *context, ut8 *digest)
Definition: rz_hash.h:37
void *(* context_new)()
Definition: rz_hash.h:31
RzList * plugins
Definition: rz_hash.h:42
int pos
Definition: main.c:11
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)