mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 05:09:43 +00:00
Simplify print hash ##crypto
This commit is contained in:
parent
ab6b7d30f7
commit
a527f716d8
@ -18,340 +18,6 @@ static RCoreHelpMessage help_msg_hash = {
|
||||
NULL
|
||||
};
|
||||
|
||||
typedef void (*HashHandler)(const ut8 *block, int len);
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
HashHandler handler;
|
||||
} RHashHashHandlers;
|
||||
|
||||
static inline void hexprint(const ut8 *data, int len) {
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
r_cons_printf ("%02x", data[i]);
|
||||
}
|
||||
r_cons_newline ();
|
||||
}
|
||||
|
||||
static void handle_md4(const ut8 *block, int len) {
|
||||
RHash *ctx = r_hash_new (true, R_HASH_MD4);
|
||||
const ut8 *c = r_hash_do_md4 (ctx, block, len);
|
||||
hexprint (c, R_HASH_SIZE_MD4);
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
static void handle_md5(const ut8 *block, int len) {
|
||||
RHash *ctx = r_hash_new (true, R_HASH_MD5);
|
||||
const ut8 *c = r_hash_do_md5 (ctx, block, len);
|
||||
hexprint (c, R_HASH_SIZE_MD5);
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
static void handle_sha1(const ut8 *block, int len) {
|
||||
RHash *ctx = r_hash_new (true, R_HASH_SHA1);
|
||||
const ut8 *c = r_hash_do_sha1 (ctx, block, len);
|
||||
hexprint (c, R_HASH_SIZE_SHA1);
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
static void handle_sha256(const ut8 *block, int len) {
|
||||
RHash *ctx = r_hash_new (true, R_HASH_SHA256);
|
||||
const ut8 *c = r_hash_do_sha256 (ctx, block, len);
|
||||
hexprint (c, R_HASH_SIZE_SHA256);
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
static void handle_sha512(const ut8 *block, int len) {
|
||||
RHash *ctx = r_hash_new (true, R_HASH_SHA512);
|
||||
const ut8 *c = r_hash_do_sha512 (ctx, block, len);
|
||||
hexprint (c, R_HASH_SIZE_SHA512);
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
static void handle_adler32(const ut8 *block, int len) {
|
||||
ut32 hn = r_hash_adler32 (block, len);
|
||||
hexprint ((ut8 *)&hn, sizeof (ut32));
|
||||
}
|
||||
|
||||
static void handle_xor(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02x\n", r_hash_xor (block, len));
|
||||
}
|
||||
|
||||
static void handle_xorpair(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04x\n", r_hash_xorpair (block, len));
|
||||
}
|
||||
|
||||
static void handle_entropy(const ut8 *block, int len) {
|
||||
r_cons_printf ("%f\n", r_hash_entropy (block, len));
|
||||
}
|
||||
|
||||
static void handle_parity(const ut8 *block, int len) {
|
||||
r_cons_printf ("%d\n", r_hash_parity (block, len)?1:0);
|
||||
}
|
||||
|
||||
static void handle_hamdist(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02x\n", r_hash_hamdist (block, len));
|
||||
}
|
||||
|
||||
static void handle_pcprint(const ut8 *block, int len) {
|
||||
r_cons_printf ("%d\n", r_hash_pcprint (block, len));
|
||||
//r_cons_printf ("%02x\n", r_hash_pcprint (block, len));
|
||||
}
|
||||
|
||||
static void handle_mod255(const ut8 *block, int len) {
|
||||
r_cons_printf ("%d\n", r_hash_mod255 (block, len));
|
||||
//r_cons_printf ("%02x\n", r_hash_pcprint (block, len));
|
||||
}
|
||||
|
||||
static void handle_xxhash(const ut8 *block, int len) {
|
||||
r_cons_printf ("%" PFMT32x "\n", r_hash_xxhash (block, len));
|
||||
}
|
||||
|
||||
static void handle_luhn(const ut8 *block, int len) {
|
||||
r_cons_printf ("%" PFMT64u "\n", r_hash_luhn (block, len));
|
||||
}
|
||||
|
||||
static void handle_ssdeep(const ut8 *block, int len) {
|
||||
char *res = r_hash_ssdeep (block, len);
|
||||
r_cons_printf ("%s\n", res);
|
||||
free (res);
|
||||
}
|
||||
|
||||
static void handle_crc8_smbus(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_8_SMBUS));
|
||||
}
|
||||
|
||||
#if R_HAVE_CRC8_EXTRA
|
||||
static void handle_crc8_cdma2000(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_CDMA2000));
|
||||
}
|
||||
|
||||
static void handle_crc8_darc(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_DARC));
|
||||
}
|
||||
|
||||
static void handle_crc8_dvb_s2(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_DVB_S2));
|
||||
}
|
||||
|
||||
static void handle_crc8_ebu(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_EBU));
|
||||
}
|
||||
|
||||
static void handle_crc8_icode(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_ICODE));
|
||||
}
|
||||
|
||||
static void handle_crc8_itu(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_ITU));
|
||||
}
|
||||
|
||||
static void handle_crc8_maxim(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_MAXIM));
|
||||
}
|
||||
|
||||
static void handle_crc8_rohc(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_ROHC));
|
||||
}
|
||||
|
||||
static void handle_crc8_wcdma(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC8_WCDMA));
|
||||
}
|
||||
#endif /* #if R_HAVE_CRC8_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC15_EXTRA
|
||||
static void handle_crc15_can(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_15_CAN));
|
||||
}
|
||||
#endif /* #if R_HAVE_CRC15_EXTRA */
|
||||
|
||||
static void handle_crc16(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_16));
|
||||
}
|
||||
|
||||
static void handle_crc16_hdlc(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_16_HDLC));
|
||||
}
|
||||
|
||||
static void handle_crc16_usb(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_16_USB));
|
||||
}
|
||||
|
||||
static void handle_crc16_citt(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_16_CITT));
|
||||
}
|
||||
|
||||
#if R_HAVE_CRC16_EXTRA
|
||||
static void handle_crc16_aug_ccitt(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_AUG_CCITT));
|
||||
}
|
||||
|
||||
static void handle_crc16_buypass(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_BUYPASS));
|
||||
}
|
||||
|
||||
static void handle_crc16_cdma2000(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_CDMA2000));
|
||||
}
|
||||
|
||||
static void handle_crc16_dds110(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_DDS110));
|
||||
}
|
||||
|
||||
static void handle_crc16_dect_r(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_DECT_R));
|
||||
}
|
||||
|
||||
static void handle_crc16_dect_x(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_DECT_X));
|
||||
}
|
||||
|
||||
static void handle_crc16_dnp(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_DNP));
|
||||
}
|
||||
|
||||
static void handle_crc16_en13757(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_EN13757));
|
||||
}
|
||||
|
||||
static void handle_crc16_genibus(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_GENIBUS));
|
||||
}
|
||||
|
||||
static void handle_crc16_maxim(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_MAXIM));
|
||||
}
|
||||
|
||||
static void handle_crc16_mcrf4xx(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_MCRF4XX));
|
||||
}
|
||||
|
||||
static void handle_crc16_riello(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_RIELLO));
|
||||
}
|
||||
|
||||
static void handle_crc16_t10dif (const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_T10_DIF));
|
||||
}
|
||||
|
||||
static void handle_crc16_teledisk(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_TELEDISK));
|
||||
}
|
||||
|
||||
static void handle_crc16_tms37157(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_TMS37157));
|
||||
}
|
||||
|
||||
static void handle_crca(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRCA));
|
||||
}
|
||||
|
||||
static void handle_crc16_kermit(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_KERMIT));
|
||||
}
|
||||
|
||||
static void handle_crc16_modbus(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_MODBUS));
|
||||
}
|
||||
|
||||
static void handle_crc16_x25(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_X25));
|
||||
}
|
||||
|
||||
static void handle_crc16_xmodem(const ut8 *block, int len) {
|
||||
r_cons_printf ("%04" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC16_XMODEM));
|
||||
}
|
||||
#endif /* #if R_HAVE_CRC16_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC24
|
||||
static void handle_crc24(const ut8 *block, int len) {
|
||||
r_cons_printf ("%06" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_24));
|
||||
}
|
||||
#endif /* #if R_HAVE_CRC24 */
|
||||
|
||||
static void handle_crc32(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_32));
|
||||
}
|
||||
|
||||
static void handle_crc32c(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_32C));
|
||||
}
|
||||
|
||||
static void handle_crc32_ecma_267(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_32_ECMA_267));
|
||||
}
|
||||
|
||||
#if R_HAVE_CRC32_EXTRA
|
||||
static void handle_crc32_bzip2(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32_BZIP2));
|
||||
}
|
||||
|
||||
static void handle_crc32d(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32D));
|
||||
}
|
||||
|
||||
static void handle_crc32_mpeg2(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32_MPEG2));
|
||||
}
|
||||
|
||||
static void handle_crc32_posix(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32_POSIX));
|
||||
}
|
||||
|
||||
static void handle_crc32q(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32Q));
|
||||
}
|
||||
|
||||
static void handle_crc32_jamcrc(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32_JAMCRC));
|
||||
}
|
||||
|
||||
static void handle_crc32_xfer(const ut8 *block, int len) {
|
||||
r_cons_printf ("%08" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC32_XFER));
|
||||
}
|
||||
#endif /* #ifR_HAVE_CRC32_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC64
|
||||
static void handle_crc64(const ut8 *block, int len) {
|
||||
r_cons_printf ("%016" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC64));
|
||||
}
|
||||
#endif /* #if R_HAVE_CRC64 */
|
||||
|
||||
#if R_HAVE_CRC64_EXTRA
|
||||
static void handle_crc64_ecma182(const ut8 *block, int len) {
|
||||
r_cons_printf ("%016" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC64_ECMA182));
|
||||
}
|
||||
|
||||
static void handle_crc64_we(const ut8 *block, int len) {
|
||||
r_cons_printf ("%016" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC64_WE));
|
||||
}
|
||||
|
||||
static void handle_crc64_xz(const ut8 *block, int len) {
|
||||
r_cons_printf ("%016" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC64_XZ));
|
||||
}
|
||||
|
||||
static void handle_crc64_iso(const ut8 *block, int len) {
|
||||
r_cons_printf ("%016" PFMTCRCx "\n", r_hash_crc_preset (block, len, CRC_PRESET_CRC64_ISO));
|
||||
}
|
||||
|
||||
#endif /* #if R_HAVE_CRC64_EXTRA */
|
||||
|
||||
static void handle_fletcher8(const ut8 *block, int len) {
|
||||
r_cons_printf ("%x\n", r_hash_fletcher8 (block, len));
|
||||
}
|
||||
|
||||
static void handle_fletcher16(const ut8 *block, int len) {
|
||||
r_cons_printf ("%02x\n", r_hash_fletcher16 (block, len));
|
||||
}
|
||||
|
||||
static void handle_fletcher32(const ut8 *block, int len) {
|
||||
r_cons_printf ("%" PFMT32x "\n", r_hash_fletcher32 (block, len));
|
||||
}
|
||||
|
||||
static void handle_fletcher64(const ut8 *block, int len) {
|
||||
r_cons_printf ("%" PFMT64x "\n", r_hash_fletcher64 (block, len));
|
||||
}
|
||||
|
||||
static int cmd_hash_bang(RCore *core, const char *input) {
|
||||
if (r_sandbox_enable (0)) {
|
||||
R_LOG_ERROR ("hashbang disabled in sandbox mode");
|
||||
@ -469,100 +135,4 @@ static int cmd_hash(void *data, const char *input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static RHashHashHandlers hash_handlers[] = {
|
||||
{ "md4", handle_md4},
|
||||
{ "md5", handle_md5},
|
||||
{ "sha1", handle_sha1},
|
||||
{ "sha256", handle_sha256},
|
||||
{ "sha512", handle_sha512},
|
||||
{ "adler32", handle_adler32},
|
||||
{ "xor", handle_xor},
|
||||
{ "xorpair", handle_xorpair},
|
||||
{ "entropy", handle_entropy},
|
||||
{ "parity", handle_parity},
|
||||
{ "hamdist", handle_hamdist},
|
||||
{ "pcprint", handle_pcprint},
|
||||
{ "mod255", handle_mod255},
|
||||
{ "xxhash", handle_xxhash},
|
||||
{ "luhn", handle_luhn},
|
||||
{ "ssdeep", handle_ssdeep},
|
||||
|
||||
{ "crc8smbus", handle_crc8_smbus},
|
||||
#if R_HAVE_CRC8_EXTRA
|
||||
{ /* CRC-8/CDMA2000 */ "crc8cdma2000", handle_crc8_cdma2000},
|
||||
{ /* CRC-8/DARC */ "crc8darc", handle_crc8_darc},
|
||||
{ /* CRC-8/DVB-S2 */ "crc8dvbs2", handle_crc8_dvb_s2},
|
||||
{ /* CRC-8/EBU */ "crc8ebu", handle_crc8_ebu},
|
||||
{ /* CRC-8/I-CODE */ "crc8icode", handle_crc8_icode},
|
||||
{ /* CRC-8/ITU */ "crc8itu", handle_crc8_itu},
|
||||
{ /* CRC-8/MAXIM */ "crc8maxim", handle_crc8_maxim},
|
||||
{ /* CRC-8/ROHC */ "crc8rohc", handle_crc8_rohc},
|
||||
{ /* CRC-8/WCDMA */ "crc8wcdma", handle_crc8_wcdma},
|
||||
#endif /* #if R_HAVE_CRC8_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC15_EXTRA
|
||||
{ "crc15can", handle_crc15_can},
|
||||
#endif /* #if R_HAVE_CRC15_EXTRA */
|
||||
|
||||
{ "crc16", handle_crc16},
|
||||
{ "crc16hdlc", handle_crc16_hdlc},
|
||||
{ /* CRC-16/USB */ "crc16usb", handle_crc16_usb},
|
||||
{ /* CRC-16/CCITT-FALSE */ "crc16citt", handle_crc16_citt},
|
||||
#if R_HAVE_CRC16_EXTRA
|
||||
{ /* CRC-16/AUG-CCITT */ "crc16augccitt", handle_crc16_aug_ccitt },
|
||||
{ /* CRC-16/BUYPASS */ "crc16buypass", handle_crc16_buypass },
|
||||
{ /* CRC-16/CDMA2000 */ "crc16cdma2000", handle_crc16_cdma2000 },
|
||||
{ /* CRC-16/DDS-110 */ "crc16dds110", handle_crc16_dds110 },
|
||||
{ /* CRC-16/RECT-R */ "crc16dectr", handle_crc16_dect_r },
|
||||
{ /* CRC-16/RECT-X */ "crc16dectx", handle_crc16_dect_x },
|
||||
{ /* CRC-16/DNP */ "crc16dnp", handle_crc16_dnp },
|
||||
{ /* CRC-16/EN-13757 */ "crc16en13757", handle_crc16_en13757 },
|
||||
{ /* CRC-16/GENIBUS */ "crc16genibus", handle_crc16_genibus },
|
||||
{ /* CRC-16/MAXIM */ "crc16maxim", handle_crc16_maxim },
|
||||
{ /* CRC-16/MCRF4XX */ "crc16mcrf4xx", handle_crc16_mcrf4xx },
|
||||
{ /* CRC-16/RIELLO */ "crc16riello", handle_crc16_riello },
|
||||
{ /* CRC-16/T10-DIF */ "crc16t10dif", handle_crc16_t10dif },
|
||||
{ /* CRC-16/TELEDISK */ "crc16teledisk", handle_crc16_teledisk },
|
||||
{ /* CRC-16/TMS37157 */ "crc16tms37157", handle_crc16_tms37157 },
|
||||
{ /* CRC-A */ "crca", handle_crca },
|
||||
{ /* CRC-16/KERMIT */ "crc16kermit", handle_crc16_kermit },
|
||||
{ /* CRC-16/MODBUS */ "crc16modbus", handle_crc16_modbus },
|
||||
{ /* CRC-16/X-25 */ "crc16x25", handle_crc16_x25 },
|
||||
{ /* CRC-16/XMODEM */ "crc16xmodem", handle_crc16_xmodem },
|
||||
#endif /* #if R_HAVE_CRC16_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC24
|
||||
{ "crc24", handle_crc24},
|
||||
#endif /* #if R_HAVE_CRC24 */
|
||||
|
||||
{ "crc32", handle_crc32},
|
||||
{ "crc32c", handle_crc32c},
|
||||
{ "crc32ecma267", handle_crc32_ecma_267},
|
||||
#if R_HAVE_CRC32_EXTRA
|
||||
{ /* CRC-32/BZIP2 */ "crc32bzip2", handle_crc32_bzip2 },
|
||||
{ /* CRC-32D */ "crc32d", handle_crc32d },
|
||||
{ /* CRC-32/MPEG-2 */ "crc32mpeg2", handle_crc32_mpeg2 },
|
||||
{ /* CRC-32/POSIX */ "crc32posix", handle_crc32_posix },
|
||||
{ /* CRC-32Q */ "crc32q", handle_crc32q },
|
||||
{ /* CRC-32/JAMCRC */ "crc32jamcrc", handle_crc32_jamcrc },
|
||||
{ /* CRC-32/XFER */ "crc32xfer", handle_crc32_xfer },
|
||||
#endif /* #if R_HAVE_CRC32_EXTRA */
|
||||
|
||||
#if R_HAVE_CRC64
|
||||
{ /* CRC-64 */ "crc64", handle_crc64 },
|
||||
#endif /* #if R_HAVE_CRC64 */
|
||||
|
||||
#if R_HAVE_CRC64_EXTRA
|
||||
{ /* CRC-64/ECMA-182 */ "crc64ecma182", handle_crc64_ecma182 },
|
||||
{ /* CRC-64/WE */ "crc64we", handle_crc64_we },
|
||||
{ /* CRC-64/XZ */ "crc64xz", handle_crc64_xz },
|
||||
{ /* CRC-64/ISO */ "crc64iso", handle_crc64_iso },
|
||||
#endif /* #if R_HAVE_CRC64_EXTRA */
|
||||
{ "fletcher8", handle_fletcher8},
|
||||
{ "fletcher16", handle_fletcher16},
|
||||
{ "fletcher32", handle_fletcher32},
|
||||
{ "fletcher64", handle_fletcher64},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
#endif // R_INCLUDE_BEGIN
|
||||
|
@ -3908,7 +3908,7 @@ restore_conf:
|
||||
static bool cmd_print_ph(RCore *core, const char *input) {
|
||||
char *algo = NULL;
|
||||
ut32 osize = 0, len = core->blocksize;
|
||||
int pos = 0, handled_cmd = false;
|
||||
int handled_cmd = false;
|
||||
|
||||
const char i0 = input[0];
|
||||
if (i0 == '?') {
|
||||
@ -3958,29 +3958,7 @@ static bool cmd_print_ph(RCore *core, const char *input) {
|
||||
} else {
|
||||
osize = len;
|
||||
}
|
||||
RCryptoJob *cj = r_crypto_use (core->crypto, algo);
|
||||
if (cj && cj->h->type == R_CRYPTO_TYPE_HASHER) {
|
||||
r_crypto_job_update (cj, (const ut8 *)core->block, len);
|
||||
int result_size = 0;
|
||||
ut8 *result = r_crypto_job_get_output (cj, &result_size);
|
||||
if (result) {
|
||||
hexprint (result, result_size);
|
||||
}
|
||||
} else {
|
||||
/* TODO: Simplify this spaguetti monster */
|
||||
while (osize > 0 && hash_handlers[pos].name) {
|
||||
if (!r_str_ccmp (hash_handlers[pos].name, input, ' ')) {
|
||||
hash_handlers[pos].handler (core->block, len);
|
||||
handled_cmd = true;
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
if (osize) {
|
||||
r_core_block_size (core, osize);
|
||||
}
|
||||
r_cons_printf ("%s\n", r_hash_tostring (NULL, algo, core->block, len));
|
||||
return handled_cmd;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ static bool end(RCryptoJob *cj, const ut8 *buf, int len) {
|
||||
RCryptoPlugin r_crypto_plugin_entropy = {
|
||||
.meta = {
|
||||
.name = "entropy",
|
||||
.desc = "Collected randomness by a syustem",
|
||||
.desc = "Shannon entropy",
|
||||
.author = "pancake",
|
||||
.license = "MIT",
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ fa8715078d45101200a6e2bf7321aa04
|
||||
5eb63bbbe01eeed093cb22bb8f5acdc3
|
||||
5eb63bbbe01eeed093cb22bb8f5acdc3
|
||||
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
|
||||
11
|
||||
0b
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -61,6 +61,28 @@ EXPECT=<<EOF
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ph entropy
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
w "hello world Shannon entropy"
|
||||
ph entropy 0x1b
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
3.58785880
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ph entropy
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
w syscall
|
||||
ph elf 7
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
5c98090b
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=crca 'hello world'
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
@ -161,6 +183,6 @@ CMDS=<<EOF
|
||||
phj
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
[{"name":"aes-ecb","type":"encryption","author":"pancake","description":"Rijndael block cipher with Electronic Code Book mode","license":"MIT"},{"name":"aes-cbc","type":"encryption","author":"pancake","description":"Rijndael block cipher with Cipher Block Chaining mode","license":"LGPL-3.0-only"},{"name":"aes-wrap","type":"encryption","author":"Sylvain Pelissier","description":"Rijndael block cipher with Key Wrap Algorithm (RFC 3394)","license":"LGPL-3.0-only"},{"name":"base64","type":"encoder","author":"rakholiyajenish.07","description":"Binary to text encoding scheme using 64 ascii characters","license":"LGPL-3.0-only"},{"name":"base91","type":"encoder","author":"rakholiyajenish.07","description":"Binary to text encoding scheme using 91 ascii characters","license":"MIT"},{"name":"bech32","type":"encoder","author":"W0nda","license":"BSD-3-Clause"},{"name":"blowfish","type":"encryption","author":"pancake","description":"Bruce Schneier's symetric-key block cipher","license":"LGPL-3.0-only"},{"name":"cps2","type":"encryption","author":"pof,esanfelix","description":"Capcom Play System 2","license":"LGPL-3.0-only"},{"name":"des-ecb","type":"encryption","author":"deroad","description":"DES with with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"ed25519","type":"signature","author":"Sylvain Pelissier","description":"Elliptic curve pubkey cryptographic algorithm used for signing and verification","license":"Zlib"},{"name":"entropy","type":"hash","author":"pancake","description":"Collected randomness by a syustem","license":"MIT"},{"name":"punycode","type":"encoder","author":"pancake","description":"Unicoded represented in plain ascii","license":"LGPL-3.0-only"},{"name":"rc2","type":"encryption","author":"pancake","description":"Ron Rivest's Code symmetric key encryption also known as ARC2","license":"LGPL-3.0-only"},{"name":"rc4","type":"encryption","author":"pancake","description":"Rivest Cipher 4","license":"LGPL-3.0-only"},{"name":"rc6","type":"encryption","author":"pancake","description":"Rivest's Cipher 6","license":"LGPL-3.0-only"},{"name":"rol","type":"encoder","author":"pancake","description":"Rotate Left N bits","license":"LGPL-3.0-only"},{"name":"ror","type":"encoder","author":"pancake","description":"Rotate Right N bits","license":"LGPL-3.0-only"},{"name":"rot","type":"encoder","author":"pancake","description":"Rotate Encryption","license":"MIT"},{"name":"serpent-ecb","type":"encryption","author":"pancake","description":"Serpent block cipher with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"sip","type":"hash","author":"pancake","description":"SipHash-2-4","license":"MIT"},{"name":"sm4-ecb","type":"encryption","author":"Sylvain Pelissier","description":"ShāngMì4 block cipher with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"strhash","type":"hash","author":"pancake","description":"String hash using a modified DJB2 xor","license":"MIT"},{"name":"xor","type":"encryption","author":"pancake","description":"Byte level Exclusive Or","license":"MIT"},{"type":"hash","name":"md5"},{"type":"hash","name":"sha1"},{"type":"hash","name":"sha256"},{"type":"hash","name":"sha384"},{"type":"hash","name":"sha512"},{"type":"hash","name":"md4"},{"type":"hash","name":"xor"},{"type":"hash","name":"xorpair"},{"type":"hash","name":"parity"},{"type":"hash","name":"entropy"},{"type":"hash","name":"hamdist"},{"type":"hash","name":"pcprint"},{"type":"hash","name":"mod255"},{"type":"hash","name":"xxhash"},{"type":"hash","name":"adler32"},{"type":"hash","name":"luhn"},{"type":"hash","name":"ssdeep"},{"type":"hash","name":"crc8smbus"},{"type":"hash","name":"crc15can"},{"type":"hash","name":"crc16"},{"type":"hash","name":"crc16hdlc"},{"type":"hash","name":"crc16usb"},{"type":"hash","name":"crc16citt"},{"type":"hash","name":"crc24"},{"type":"hash","name":"crc32"},{"type":"hash","name":"crc32c"},{"type":"hash","name":"crc32ecma267"},{"type":"hash","name":"crc32bzip2"},{"type":"hash","name":"crc32d"},{"type":"hash","name":"crc32mpeg2"},{"type":"hash","name":"crc32posix"},{"type":"hash","name":"crc32q"},{"type":"hash","name":"crc32jamcrc"},{"type":"hash","name":"crc32xfer"},{"type":"hash","name":"crc64"},{"type":"hash","name":"crc64ecma"},{"type":"hash","name":"crc64we"},{"type":"hash","name":"crc64xz"},{"type":"hash","name":"crc64iso"},{"type":"hash","name":"fletcher8"},{"type":"hash","name":"fletcher16"},{"type":"hash","name":"fletcher32"},{"type":"hash","name":"fletcher64"},{"type":"hash","name":"elf"}]
|
||||
[{"name":"aes-ecb","type":"encryption","author":"pancake","description":"Rijndael block cipher with Electronic Code Book mode","license":"MIT"},{"name":"aes-cbc","type":"encryption","author":"pancake","description":"Rijndael block cipher with Cipher Block Chaining mode","license":"LGPL-3.0-only"},{"name":"aes-wrap","type":"encryption","author":"Sylvain Pelissier","description":"Rijndael block cipher with Key Wrap Algorithm (RFC 3394)","license":"LGPL-3.0-only"},{"name":"base64","type":"encoder","author":"rakholiyajenish.07","description":"Binary to text encoding scheme using 64 ascii characters","license":"LGPL-3.0-only"},{"name":"base91","type":"encoder","author":"rakholiyajenish.07","description":"Binary to text encoding scheme using 91 ascii characters","license":"MIT"},{"name":"bech32","type":"encoder","author":"W0nda","license":"BSD-3-Clause"},{"name":"blowfish","type":"encryption","author":"pancake","description":"Bruce Schneier's symetric-key block cipher","license":"LGPL-3.0-only"},{"name":"cps2","type":"encryption","author":"pof,esanfelix","description":"Capcom Play System 2","license":"LGPL-3.0-only"},{"name":"des-ecb","type":"encryption","author":"deroad","description":"DES with with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"ed25519","type":"signature","author":"Sylvain Pelissier","description":"Elliptic curve pubkey cryptographic algorithm used for signing and verification","license":"Zlib"},{"name":"entropy","type":"hash","author":"pancake","description":"Shannon entropy","license":"MIT"},{"name":"punycode","type":"encoder","author":"pancake","description":"Unicoded represented in plain ascii","license":"LGPL-3.0-only"},{"name":"rc2","type":"encryption","author":"pancake","description":"Ron Rivest's Code symmetric key encryption also known as ARC2","license":"LGPL-3.0-only"},{"name":"rc4","type":"encryption","author":"pancake","description":"Rivest Cipher 4","license":"LGPL-3.0-only"},{"name":"rc6","type":"encryption","author":"pancake","description":"Rivest's Cipher 6","license":"LGPL-3.0-only"},{"name":"rol","type":"encoder","author":"pancake","description":"Rotate Left N bits","license":"LGPL-3.0-only"},{"name":"ror","type":"encoder","author":"pancake","description":"Rotate Right N bits","license":"LGPL-3.0-only"},{"name":"rot","type":"encoder","author":"pancake","description":"Rotate Encryption","license":"MIT"},{"name":"serpent-ecb","type":"encryption","author":"pancake","description":"Serpent block cipher with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"sip","type":"hash","author":"pancake","description":"SipHash-2-4","license":"MIT"},{"name":"sm4-ecb","type":"encryption","author":"Sylvain Pelissier","description":"ShāngMì4 block cipher with Electronic Code Book mode","license":"LGPL-3.0-only"},{"name":"strhash","type":"hash","author":"pancake","description":"String hash using a modified DJB2 xor","license":"MIT"},{"name":"xor","type":"encryption","author":"pancake","description":"Byte level Exclusive Or","license":"MIT"},{"type":"hash","name":"md5"},{"type":"hash","name":"sha1"},{"type":"hash","name":"sha256"},{"type":"hash","name":"sha384"},{"type":"hash","name":"sha512"},{"type":"hash","name":"md4"},{"type":"hash","name":"xor"},{"type":"hash","name":"xorpair"},{"type":"hash","name":"parity"},{"type":"hash","name":"entropy"},{"type":"hash","name":"hamdist"},{"type":"hash","name":"pcprint"},{"type":"hash","name":"mod255"},{"type":"hash","name":"xxhash"},{"type":"hash","name":"adler32"},{"type":"hash","name":"luhn"},{"type":"hash","name":"ssdeep"},{"type":"hash","name":"crc8smbus"},{"type":"hash","name":"crc15can"},{"type":"hash","name":"crc16"},{"type":"hash","name":"crc16hdlc"},{"type":"hash","name":"crc16usb"},{"type":"hash","name":"crc16citt"},{"type":"hash","name":"crc24"},{"type":"hash","name":"crc32"},{"type":"hash","name":"crc32c"},{"type":"hash","name":"crc32ecma267"},{"type":"hash","name":"crc32bzip2"},{"type":"hash","name":"crc32d"},{"type":"hash","name":"crc32mpeg2"},{"type":"hash","name":"crc32posix"},{"type":"hash","name":"crc32q"},{"type":"hash","name":"crc32jamcrc"},{"type":"hash","name":"crc32xfer"},{"type":"hash","name":"crc64"},{"type":"hash","name":"crc64ecma"},{"type":"hash","name":"crc64we"},{"type":"hash","name":"crc64xz"},{"type":"hash","name":"crc64iso"},{"type":"hash","name":"fletcher8"},{"type":"hash","name":"fletcher16"},{"type":"hash","name":"fletcher32"},{"type":"hash","name":"fletcher64"},{"type":"hash","name":"elf"}]
|
||||
EOF
|
||||
RUN
|
||||
|
@ -172,7 +172,7 @@ c blowfish Bruce Schneier's symetric-key block cipher
|
||||
c cps2 Capcom Play System 2
|
||||
c des-ecb DES with with Electronic Code Book mode
|
||||
s ed25519 Elliptic curve pubkey cryptographic algorithm used for signing and verification
|
||||
h entropy Collected randomness by a syustem
|
||||
h entropy Shannon entropy
|
||||
e punycode Unicoded represented in plain ascii
|
||||
c rc2 Ron Rivest's Code symmetric key encryption also known as ARC2
|
||||
c rc4 Rivest Cipher 4
|
||||
|
Loading…
Reference in New Issue
Block a user