7 #include "../algorithms/fletcher/fletcher.h"
9 #define rz_fletcher_common_plugin_context_new(bits) \
10 static void *plugin_fletcher##bits##_context_new() { \
11 return RZ_NEW0(RzFletcher##bits); \
14 #define rz_fletcher_common_plugin_context_free(bits) \
15 static void plugin_fletcher##bits##_context_free(void *context) { \
19 #define rz_fletcher_common_plugin_digest_size(bits) \
20 static RzHashSize plugin_fletcher##bits##_digest_size(void *context) { \
21 return RZ_HASH_FLETCHER##bits##_DIGEST_SIZE; \
24 #define rz_fletcher_common_plugin_init(bits) \
25 static bool plugin_fletcher##bits##_init(void *context) { \
26 rz_return_val_if_fail(context, false); \
27 rz_fletcher##bits##_init((RzFletcher##bits *)context); \
31 #define rz_fletcher_common_plugin_update(bits) \
32 static bool plugin_fletcher##bits##_update(void *context, const ut8 *data, ut64 size) { \
33 rz_return_val_if_fail(context &&data, false); \
34 rz_fletcher##bits##_update((RzFletcher##bits *)context, data, size); \
38 #define rz_fletcher_common_plugin_final(bits) \
39 static bool plugin_fletcher##bits##_final(void *context, ut8 *digest) { \
40 rz_return_val_if_fail(context &&digest, false); \
41 rz_fletcher##bits##_final(digest, (RzFletcher##bits *)context); \
45 #define rz_fletcher_common_plugin_small_block(bits) \
46 static bool plugin_fletcher##bits##_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size) { \
47 rz_return_val_if_fail(data &&digest, false); \
48 ut8 *dgst = malloc(RZ_HASH_FLETCHER##bits##_DIGEST_SIZE); \
52 RzFletcher##bits ctx; \
53 rz_fletcher##bits##_init(&ctx); \
54 rz_fletcher##bits##_update(&ctx, data, size); \
55 rz_fletcher##bits##_final(dgst, &ctx); \
58 *digest_size = RZ_HASH_FLETCHER##bits##_DIGEST_SIZE; \
63 #ifndef RZ_PLUGIN_INCORE
64 #define rz_lib_fletcher_common(bits) \
65 RZ_API RzLibStruct rizin_plugin = { \
66 .type = RZ_LIB_TYPE_HASH, \
67 .data = &rz_hash_plugin_fletcher##bits, \
68 .version = RZ_VERSION \
71 #define rz_lib_fletcher_common(bits)
74 #define rz_fletcher_common_plugin_define_hash_cfg(bits) \
75 rz_fletcher_common_plugin_context_new(bits); \
76 rz_fletcher_common_plugin_context_free(bits); \
77 rz_fletcher_common_plugin_digest_size(bits); \
78 rz_fletcher_common_plugin_init(bits); \
79 rz_fletcher_common_plugin_update(bits); \
80 rz_fletcher_common_plugin_final(bits); \
81 rz_fletcher_common_plugin_small_block(bits); \
82 RzHashPlugin rz_hash_plugin_fletcher##bits = { \
83 .name = "fletcher" #bits, \
86 .support_hmac = false, \
87 .context_new = plugin_fletcher##bits##_context_new, \
88 .context_free = plugin_fletcher##bits##_context_free, \
89 .digest_size = plugin_fletcher##bits##_digest_size, \
90 .block_size = plugin_fletcher_block_size, \
91 .init = plugin_fletcher##bits##_init, \
92 .update = plugin_fletcher##bits##_update, \
93 .final = plugin_fletcher##bits##_final, \
94 .small_block = plugin_fletcher##bits##_small_block, \
96 rz_lib_fletcher_common(bits)
#define rz_fletcher_common_plugin_define_hash_cfg(bits)
static RzHashSize plugin_fletcher_block_size(void *context)
#define RZ_HASH_FLETCHER_BLOCK_LENGTH