7 #include "../algorithms/crc/crca.h"
9 #define plugin_crca_preset_context_new(crcalgo, preset) \
10 static void *plugin_crca_##crcalgo##_context_new() { \
11 RzCrc *crc = RZ_NEW0(RzCrc); \
15 crc_init_preset(crc, preset); \
19 #define plugin_crca_preset_init(crcalgo, preset) \
20 static bool plugin_crca_##crcalgo##_init(void *context) { \
21 rz_return_val_if_fail(context, false); \
22 crc_init_preset((RzCrc *)context, preset); \
26 #define plugin_crca_preset_small_block(crcalgo, preset) \
27 static bool plugin_crca_##crcalgo##_small_block(const ut8 *data, ut64 size, ut8 **digest, RzHashSize *digest_size) { \
28 rz_return_val_if_fail(data &&digest, false); \
30 crc_init_preset(&ctx, preset); \
31 ut8 *dgst = malloc(plugin_crca_digest_size(&ctx)); \
35 crc_update(&ctx, data, size); \
36 plugin_crca_final((void *)&ctx, dgst); \
39 *digest_size = plugin_crca_digest_size(&ctx); \
53 }
else if (
ctx->size > 8 &&
ctx->size <= 16) {
55 }
else if (
ctx->size > 16 &&
ctx->size <= 32) {
57 }
else if (
ctx->size > 32 &&
ctx->size <= 64) {
82 }
else if (
ctx->size > 8 &&
ctx->size <= 16) {
84 }
else if (
ctx->size > 16 &&
ctx->size <= 32) {
86 }
else if (
ctx->size > 32 &&
ctx->size <= 64) {
94 #define rz_hash_plugin_crca_preset(crcalgo, preset) \
95 plugin_crca_preset_context_new(crcalgo, preset); \
96 plugin_crca_preset_init(crcalgo, preset); \
97 plugin_crca_preset_small_block(crcalgo, preset); \
98 RzHashPlugin rz_hash_plugin_crca_##crcalgo = { \
100 .license = "LGPL3", \
101 .author = "deroad", \
102 .support_hmac = false, \
103 .context_new = plugin_crca_##crcalgo##_context_new, \
104 .context_free = plugin_crca_context_free, \
105 .digest_size = plugin_crca_digest_size, \
106 .block_size = plugin_crca_block_size, \
107 .init = plugin_crca_##crcalgo##_init, \
108 .update = plugin_crca_update, \
109 .final = plugin_crca_final, \
110 .small_block = plugin_crca_##crcalgo##_small_block, \
113 #ifndef RZ_PLUGIN_INCORE
114 #define rz_lib_plugin_crca_preset(crcalgo) \
115 RZ_API RzLibStruct rizin_plugin = { \
116 .type = RZ_LIB_TYPE_HASH, \
117 .data = &rz_hash_plugin_crca_##crcalgo, \
118 .version = RZ_VERSION \
121 #define rz_lib_plugin_crca_preset(crcalgo)
124 #define rz_plugin_crca_preset_definition(crcalgo, preset) \
125 rz_hash_plugin_crca_preset(crcalgo, preset); \
126 rz_lib_plugin_crca_preset(crcalgo)
static bool plugin_crca_final(void *context, ut8 *digest)
static RzHashSize plugin_crca_digest_size(void *context)
static void plugin_crca_context_free(void *context)
static RzHashSize plugin_crca_block_size(void *context)
static bool plugin_crca_update(void *context, const ut8 *data, ut64 size)
#define rz_plugin_crca_preset_definition(crcalgo, preset)
void crc_final(RzCrc *ctx, utcrc *r)
void crc_update(RzCrc *ctx, const ut8 *data, ut32 sz)
@ CRC_PRESET_CRC16_RIELLO
@ CRC_PRESET_CRC16_TELEDISK
@ CRC_PRESET_CRC16_CDMA2000
@ CRC_PRESET_CRC8_CDMA2000
@ CRC_PRESET_CRC16_AUG_CCITT
@ CRC_PRESET_CRC16_MCRF4XX
@ CRC_PRESET_CRC16_GENIBUS
@ CRC_PRESET_CRC32_JAMCRC
@ CRC_PRESET_CRC16_DECT_R
@ CRC_PRESET_CRC16_DDS110
@ CRC_PRESET_CRC16_DECT_X
@ CRC_PRESET_CRC16_MODBUS
@ CRC_PRESET_CRC16_KERMIT
@ CRC_PRESET_CRC64_ECMA182
@ CRC_PRESET_CRC16_BUYPASS
@ CRC_PRESET_CRC16_TMS37157
@ CRC_PRESET_CRC16_T10_DIF
@ CRC_PRESET_CRC16_XMODEM
@ CRC_PRESET_CRC16_EN13757
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define rz_return_val_if_fail(expr, val)
static void rz_write_be16(void *dest, ut16 val)
static void rz_write_be64(void *dest, ut64 val)
static void rz_write_be8(void *dest, ut8 val)
static void rz_write_be32(void *dest, ut32 val)
#define RZ_LOG_ERROR(fmtstr,...)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)