From d1b1a64a8c0ce28cf1f1e4fe1f2ac6ff0cb8bd4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Go=C5=82awski?= Date: Thu, 8 Feb 2024 15:38:07 +0100 Subject: [PATCH] VeraCrypt modules code cleanup --- OpenCL/m13711-pure.cl | 6 ++++- OpenCL/m13712-pure.cl | 4 +++- OpenCL/m13713-pure.cl | 4 +++- OpenCL/m13721-pure.cl | 4 +++- OpenCL/m13722-pure.cl | 4 +++- OpenCL/m13723-pure.cl | 4 +++- OpenCL/m13731-pure.cl | 4 +++- OpenCL/m13732-pure.cl | 4 +++- OpenCL/m13733-pure.cl | 4 +++- OpenCL/m13751-pure.cl | 4 +++- OpenCL/m13752-pure.cl | 4 +++- OpenCL/m13753-pure.cl | 4 +++- OpenCL/m13771-pure.cl | 4 +++- OpenCL/m13772-pure.cl | 4 +++- OpenCL/m13773-pure.cl | 4 +++- src/modules/module_13711.c | 26 ++++++++-------------- src/modules/module_13712.c | 26 ++++++++-------------- src/modules/module_13713.c | 26 ++++++++-------------- src/modules/module_13721.c | 26 ++++++++-------------- src/modules/module_13722.c | 26 ++++++++-------------- src/modules/module_13723.c | 26 ++++++++-------------- src/modules/module_13731.c | 26 ++++++++-------------- src/modules/module_13732.c | 26 ++++++++-------------- src/modules/module_13733.c | 26 ++++++++-------------- src/modules/module_13741.c | 26 ++++++++-------------- src/modules/module_13742.c | 26 ++++++++-------------- src/modules/module_13743.c | 26 ++++++++-------------- src/modules/module_13751.c | 26 ++++++++-------------- src/modules/module_13752.c | 26 ++++++++-------------- src/modules/module_13753.c | 26 ++++++++-------------- src/modules/module_13761.c | 26 ++++++++-------------- src/modules/module_13762.c | 26 ++++++++-------------- src/modules/module_13763.c | 26 ++++++++-------------- src/modules/module_13771.c | 26 ++++++++-------------- src/modules/module_13772.c | 26 ++++++++-------------- src/modules/module_13773.c | 26 ++++++++-------------- src/modules/module_13781.c | 26 ++++++++-------------- src/modules/module_13782.c | 26 ++++++++-------------- src/modules/module_13783.c | 26 ++++++++-------------- src/modules/module_29411.c | 45 +++++++++++++------------------------- src/modules/module_29412.c | 45 +++++++++++++------------------------- src/modules/module_29413.c | 45 +++++++++++++------------------------- src/modules/module_29421.c | 45 +++++++++++++------------------------- src/modules/module_29422.c | 45 +++++++++++++------------------------- src/modules/module_29423.c | 45 +++++++++++++------------------------- src/modules/module_29431.c | 45 +++++++++++++------------------------- src/modules/module_29432.c | 45 +++++++++++++------------------------- src/modules/module_29433.c | 45 +++++++++++++------------------------- src/modules/module_29441.c | 45 +++++++++++++------------------------- src/modules/module_29442.c | 45 +++++++++++++------------------------- src/modules/module_29443.c | 45 +++++++++++++------------------------- src/modules/module_29451.c | 45 +++++++++++++------------------------- src/modules/module_29452.c | 45 +++++++++++++------------------------- src/modules/module_29453.c | 45 +++++++++++++------------------------- src/modules/module_29461.c | 45 +++++++++++++------------------------- src/modules/module_29462.c | 45 +++++++++++++------------------------- src/modules/module_29463.c | 45 +++++++++++++------------------------- src/modules/module_29471.c | 45 +++++++++++++------------------------- src/modules/module_29472.c | 45 +++++++++++++------------------------- src/modules/module_29473.c | 45 +++++++++++++------------------------- src/modules/module_29481.c | 45 +++++++++++++------------------------- src/modules/module_29482.c | 45 +++++++++++++------------------------- src/modules/module_29483.c | 45 +++++++++++++------------------------- 63 files changed, 623 insertions(+), 1143 deletions(-) diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl index 36ae740a7..e562ab14d 100644 --- a/OpenCL/m13711-pure.cl +++ b/OpenCL/m13711-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -43,6 +45,8 @@ typedef struct vc #include M2S(INCLUDE_PATH/inc_veracrypt_keyfile.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc_tmp { u32 ipad[16]; diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl index 11acc1753..042e6a4fd 100644 --- a/OpenCL/m13712-pure.cl +++ b/OpenCL/m13712-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl index e03a1e86a..d7135e284 100644 --- a/OpenCL/m13713-pure.cl +++ b/OpenCL/m13713-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 978497b58..209c1d62e 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index 12590f2fb..52b18f9ee 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index 8d67e7c7a..3a49cc1b4 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl index bf6109688..06951a7d8 100644 --- a/OpenCL/m13731-pure.cl +++ b/OpenCL/m13731-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl index 5cebed18e..41263e8a4 100644 --- a/OpenCL/m13732-pure.cl +++ b/OpenCL/m13732-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl index a16ee5740..1d15ed3d2 100644 --- a/OpenCL/m13733-pure.cl +++ b/OpenCL/m13733-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index cd7a2dbd8..fbd04283c 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index a7a977e31..ec02b0d8e 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 7df35f839..4781af53f 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index e212dfacb..a9ab042b9 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index c4b870208..a44a0dab6 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 55f14890c..701c1b0f9 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -19,9 +19,11 @@ #include M2S(INCLUDE_PATH/inc_cipher_kuznyechik.cl) #endif +#define VC_DATA_LEN (448) + typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index 05ab89ecc..a5b61345f 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -148,20 +149,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -283,7 +275,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index 6f62b2b33..1d8ebbe40 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -148,20 +149,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -283,7 +275,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index ba414a5a0..6ad3be07e 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -148,20 +149,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -283,7 +275,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index f6f335eb6..af7eeb093 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_tmp { @@ -71,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -161,20 +162,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -296,7 +288,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index 6ce7258e3..be5066039 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_tmp { @@ -71,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -161,20 +162,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -296,7 +288,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index ca2a70316..c6b0cd97b 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_tmp { @@ -71,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -161,20 +162,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -296,7 +288,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 428c33ffa..422cb828e 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index 742b68d39..e9bbc8873 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index 1e9007315..f0cb9378d 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index e4811633c..8da895024 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -150,20 +151,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -285,7 +277,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index 45f9cfc51..85871f24d 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -150,20 +151,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -285,7 +277,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index 2824e93f9..c6bcab003 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -150,20 +151,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -285,7 +277,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index 5530305f0..6e71c8921 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index d5485047f..575227bba 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index 5b6d7297d..157bb5150 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -49,9 +49,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -69,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,20 +168,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -302,7 +294,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index 7212b8f96..65fde53e1 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -169,20 +170,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -304,7 +296,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index 113e71460..6eaf94745 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -169,20 +170,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -304,7 +296,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index 89f900e62..d8da70d29 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -50,9 +50,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc_tmp { @@ -70,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -169,20 +170,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -304,7 +296,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index e6283a499..ee36f7422 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -74,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -153,20 +154,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -288,7 +280,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index 7ae4bed75..7697346fa 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -74,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -153,20 +154,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -288,7 +280,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index df1e35ba0..eb0069d37 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -51,9 +51,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -74,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -153,20 +154,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -288,7 +280,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13781.c b/src/modules/module_13781.c index 191a64c80..ee8017e35 100644 --- a/src/modules/module_13781.c +++ b/src/modules/module_13781.c @@ -52,9 +52,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -75,7 +76,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -155,20 +156,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -290,7 +282,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13782.c b/src/modules/module_13782.c index 16c5cc9b6..e5c495193 100644 --- a/src/modules/module_13782.c +++ b/src/modules/module_13782.c @@ -52,9 +52,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -75,7 +76,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -155,20 +156,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -290,7 +282,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_13783.c b/src/modules/module_13783.c index ad4a2e4cc..ec3379402 100644 --- a/src/modules/module_13783.c +++ b/src/modules/module_13783.c @@ -52,9 +52,10 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 -#define VC_HEADER_LEN 512 +#define VC_SALT_LEN ( 64) +#define VC_DATA_LEN ( 448) +#define VC_HEADER_LEN ( 512) +#define VC_HEADER_HEX_LEN (VC_HEADER_LEN * 2) typedef struct vc64_sbog_tmp { @@ -75,7 +76,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -155,20 +156,11 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { - const size_t st_hash_len = strlen (hashconfig->st_hash); + char header[VC_HEADER_LEN + 1] = { 0 }; - char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + hex_decode ((const u8 *) hashconfig->st_hash, VC_HEADER_HEX_LEN, (u8 *) header); - for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) - { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); - - tmpdata[i] = c; - } - - const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, header, VC_HEADER_LEN); return parser_status; } @@ -290,7 +282,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } diff --git a/src/modules/module_29411.c b/src/modules/module_29411.c index 434ebd06d..90731dd85 100644 --- a/src/modules/module_29411.c +++ b/src/modules/module_29411.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -165,12 +168,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -182,12 +185,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -197,10 +195,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -220,7 +215,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -284,25 +279,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29412.c b/src/modules/module_29412.c index ecb9e4706..2d624b3b6 100644 --- a/src/modules/module_29412.c +++ b/src/modules/module_29412.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -165,12 +168,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -182,12 +185,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -197,10 +195,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -220,7 +215,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -284,25 +279,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29413.c b/src/modules/module_29413.c index 295807e18..5291607d7 100644 --- a/src/modules/module_29413.c +++ b/src/modules/module_29413.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -165,12 +168,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -182,12 +185,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -197,10 +195,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -220,7 +215,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -284,25 +279,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29421.c b/src/modules/module_29421.c index c75184e77..a318b2132 100644 --- a/src/modules/module_29421.c +++ b/src/modules/module_29421.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_tmp { @@ -69,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -176,12 +179,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -193,12 +196,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -208,10 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -231,7 +226,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -295,25 +290,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29422.c b/src/modules/module_29422.c index 1e307a2fd..1c70430fd 100644 --- a/src/modules/module_29422.c +++ b/src/modules/module_29422.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_tmp { @@ -69,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -176,12 +179,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -193,12 +196,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -208,10 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -231,7 +226,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -295,25 +290,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29423.c b/src/modules/module_29423.c index fce68cc36..660c44b7e 100644 --- a/src/modules/module_29423.c +++ b/src/modules/module_29423.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_tmp { @@ -69,7 +72,7 @@ typedef struct vc64_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -176,12 +179,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -193,12 +196,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -208,10 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -231,7 +226,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -295,25 +290,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29431.c b/src/modules/module_29431.c index d98fce4dd..35b56f695 100644 --- a/src/modules/module_29431.c +++ b/src/modules/module_29431.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -152,12 +155,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -169,12 +172,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -184,10 +182,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -207,7 +202,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -271,25 +266,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29432.c b/src/modules/module_29432.c index 8bdb26a99..e9afdc4da 100644 --- a/src/modules/module_29432.c +++ b/src/modules/module_29432.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -152,12 +155,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -169,12 +172,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -184,10 +182,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -207,7 +202,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -271,25 +266,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29433.c b/src/modules/module_29433.c index 16d39fa1c..b528d21d4 100644 --- a/src/modules/module_29433.c +++ b/src/modules/module_29433.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -166,12 +169,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -183,12 +186,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -198,10 +196,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -221,7 +216,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -285,25 +280,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29441.c b/src/modules/module_29441.c index 44db4ff81..241f3f4f4 100644 --- a/src/modules/module_29441.c +++ b/src/modules/module_29441.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,12 +170,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -184,12 +187,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -199,10 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -222,7 +217,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -286,25 +281,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29442.c b/src/modules/module_29442.c index d47c16b3f..79cf96c9c 100644 --- a/src/modules/module_29442.c +++ b/src/modules/module_29442.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,12 +170,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -184,12 +187,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -199,10 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -222,7 +217,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -286,25 +281,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29443.c b/src/modules/module_29443.c index bc09e12f0..629c1577a 100644 --- a/src/modules/module_29443.c +++ b/src/modules/module_29443.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -167,12 +170,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -184,12 +187,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -199,10 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -222,7 +217,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -286,25 +281,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29451.c b/src/modules/module_29451.c index 01a955fa4..3e2971bad 100644 --- a/src/modules/module_29451.c +++ b/src/modules/module_29451.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -184,12 +187,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -201,12 +204,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -216,10 +214,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -239,7 +234,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -303,25 +298,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29452.c b/src/modules/module_29452.c index b77ff6145..b0f42745c 100644 --- a/src/modules/module_29452.c +++ b/src/modules/module_29452.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -184,12 +187,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -201,12 +204,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -216,10 +214,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -239,7 +234,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -303,25 +298,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29453.c b/src/modules/module_29453.c index 171c61373..092e0d381 100644 --- a/src/modules/module_29453.c +++ b/src/modules/module_29453.c @@ -48,8 +48,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -67,7 +70,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -184,12 +187,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -201,12 +204,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -216,10 +214,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -239,7 +234,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -303,25 +298,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29461.c b/src/modules/module_29461.c index 301d2dada..779385274 100644 --- a/src/modules/module_29461.c +++ b/src/modules/module_29461.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -186,12 +189,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -203,12 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -218,10 +216,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -241,7 +236,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -305,25 +300,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29462.c b/src/modules/module_29462.c index 409384d8e..e7ee40834 100644 --- a/src/modules/module_29462.c +++ b/src/modules/module_29462.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -186,12 +189,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -203,12 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -218,10 +216,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -241,7 +236,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -305,25 +300,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29463.c b/src/modules/module_29463.c index d1dcd3d80..f0d5851e4 100644 --- a/src/modules/module_29463.c +++ b/src/modules/module_29463.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc_tmp { @@ -68,7 +71,7 @@ typedef struct vc_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -186,12 +189,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -203,12 +206,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -218,10 +216,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -241,7 +236,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -305,25 +300,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29471.c b/src/modules/module_29471.c index 4b1852559..cb4ccf298 100644 --- a/src/modules/module_29471.c +++ b/src/modules/module_29471.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -71,7 +74,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -175,12 +178,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -192,12 +195,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -207,10 +205,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -230,7 +225,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -294,25 +289,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29472.c b/src/modules/module_29472.c index 8a7a20d15..d71a641b7 100644 --- a/src/modules/module_29472.c +++ b/src/modules/module_29472.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -71,7 +74,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -175,12 +178,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -192,12 +195,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -207,10 +205,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -230,7 +225,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -294,25 +289,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29473.c b/src/modules/module_29473.c index 4e2345011..c64f58762 100644 --- a/src/modules/module_29473.c +++ b/src/modules/module_29473.c @@ -49,8 +49,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -71,7 +74,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -181,12 +184,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -198,12 +201,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -213,10 +211,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -236,7 +231,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -300,25 +295,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29481.c b/src/modules/module_29481.c index 55d0b84c6..ca63d6503 100644 --- a/src/modules/module_29481.c +++ b/src/modules/module_29481.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -72,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -177,12 +180,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -194,12 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -209,10 +207,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -232,7 +227,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -296,25 +291,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29482.c b/src/modules/module_29482.c index 6e784d9a6..64b5697d6 100644 --- a/src/modules/module_29482.c +++ b/src/modules/module_29482.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -72,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -177,12 +180,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -194,12 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -209,10 +207,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -232,7 +227,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -296,25 +291,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output diff --git a/src/modules/module_29483.c b/src/modules/module_29483.c index c6162d306..2d8e1f06e 100644 --- a/src/modules/module_29483.c +++ b/src/modules/module_29483.c @@ -50,8 +50,11 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -#define VC_SALT_LEN 64 -#define VC_DATA_LEN 448 +#define VC_SALT_LEN ( 64) +#define VC_SALT_HEX_LEN (VC_SALT_LEN * 2) + +#define VC_DATA_LEN ( 448) +#define VC_DATA_HEX_LEN (VC_DATA_LEN * 2) typedef struct vc64_sbog_tmp { @@ -72,7 +75,7 @@ typedef struct vc64_sbog_tmp typedef struct vc { - u32 data_buf[112]; + u32 data_buf[VC_DATA_LEN / 4]; u32 keyfile_buf16[16]; u32 keyfile_buf32[32]; u32 keyfile_enabled; @@ -177,12 +180,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 128; + token.len[1] = VC_SALT_HEX_LEN; token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len[2] = 896; + token.len[2] = VC_DATA_HEX_LEN; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -194,12 +197,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - } - - salt->salt_len = VC_SALT_LEN; + salt->salt_len = hex_decode (salt_pos, VC_SALT_HEX_LEN, (u8 *) salt->salt_buf); // iter @@ -209,10 +207,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[2]; - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - vc->data_buf[i] = hex_to_u32 (data_pos + j); - } + hex_decode (data_pos, VC_DATA_HEX_LEN, (u8 *) vc->data_buf); // entropy @@ -232,7 +227,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // fake digest - memcpy (digest, vc->data_buf, 112); + memcpy (digest, vc->data_buf, VC_DATA_LEN / 4); return (PARSER_OK); } @@ -296,25 +291,15 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_HEX_LEN VC_SALT_LEN * 2 + 1 + char salt_buf[VC_SALT_HEX_LEN + 1] = { 0 }; - char salt_buf[SALT_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_SALT_LEN / 4; i += 1, j += 8) - { - snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", byte_swap_32 (salt->salt_buf[i])); - } + hex_encode ((const u8 *) salt->salt_buf, VC_SALT_LEN, (u8 *) salt_buf); // data - #define DATA_HEX_LEN VC_DATA_LEN * 2 + 1 + char data_buf[VC_DATA_HEX_LEN + 1] = { 0 }; - char data_buf[DATA_HEX_LEN] = { 0 }; - - for (u32 i = 0, j = 0; i < VC_DATA_LEN / 4; i += 1, j += 8) - { - snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", byte_swap_32 (vc->data_buf[i])); - } + hex_encode ((const u8 *) vc->data_buf, VC_DATA_LEN, (u8 *) data_buf); // output