From a0de388bb92cf832ee513a207991379805d9bab6 Mon Sep 17 00:00:00 2001 From: Flaggx1 Date: Sun, 21 May 2023 00:05:08 -0400 Subject: [PATCH 001/357] Increase number of user-defined charsets from 4 to 9 This feature change increases the number of user-defined charsets from a maximum of 4 to 9. This enables more advanced and efficient attacks in certain cases. --- include/types.h | 12 ++++++- src/brain.c | 71 +++++++++++++++++++++++++++++++++++++++++ src/mpsp.c | 78 ++++++++++++++++++++++++++++++++++++++++++++-- src/status.c | 19 +++++++++-- src/usage.c | 5 +++ src/user_options.c | 58 +++++++++++++++++++++++++++++++--- 6 files changed, 234 insertions(+), 9 deletions(-) diff --git a/include/types.h b/include/types.h index 6fd4c4553..d059ab416 100644 --- a/include/types.h +++ b/include/types.h @@ -757,6 +757,11 @@ typedef enum user_options_map IDX_CUSTOM_CHARSET_2 = '2', IDX_CUSTOM_CHARSET_3 = '3', IDX_CUSTOM_CHARSET_4 = '4', + IDX_CUSTOM_CHARSET_5 = '5', + IDX_CUSTOM_CHARSET_6 = '6', + IDX_CUSTOM_CHARSET_7 = '7', + IDX_CUSTOM_CHARSET_8 = '8', + IDX_CUSTOM_CHARSET_9 = '9', IDX_DEBUG_FILE = 0xff12, IDX_DEBUG_MODE = 0xff13, IDX_DEPRECATED_CHECK_DISABLE = 0xff14, @@ -2377,7 +2382,7 @@ typedef struct user_options char *brain_session_whitelist; #endif char *cpu_affinity; - char *custom_charset_4; + char *custom_charset_9; char *debug_file; char *induction_dir; char *keyboard_layout_mapping; @@ -2396,6 +2401,11 @@ typedef struct user_options const char *custom_charset_1; const char *custom_charset_2; const char *custom_charset_3; + const char *custom_charset_4; + const char *custom_charset_5; + const char *custom_charset_6; + const char *custom_charset_7; + const char *custom_charset_8; const char *encoding_from; const char *encoding_to; const char *rule_buf_l; diff --git a/src/brain.c b/src/brain.c index bd97d9695..480170bb1 100644 --- a/src/brain.c +++ b/src/brain.c @@ -345,7 +345,43 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, custom_charset_4, strlen (custom_charset_4)); } + + if (user_options->custom_charset_5) + { + const char *custom_charset_5 = user_options->custom_charset_5; + + XXH64_update (state, custom_charset_5, strlen (custom_charset_5)); + } + + if (user_options->custom_charset_6) + { + const char *custom_charset_6 = user_options->custom_charset_6; + + XXH64_update (state, custom_charset_6, strlen (custom_charset_6)); + } + + if (user_options->custom_charset_7) + { + const char *custom_charset_7 = user_options->custom_charset_7; + + XXH64_update (state, custom_charset_7, strlen (custom_charset_7)); + } + + if (user_options->custom_charset_8) + { + const char *custom_charset_8 = user_options->custom_charset_8; + + XXH64_update (state, custom_charset_8, strlen (custom_charset_8)); + } + + if (user_options->custom_charset_9) + { + const char *custom_charset_9 = user_options->custom_charset_9; + + XXH64_update (state, custom_charset_9, strlen (custom_charset_9)); + } } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { const u64 wordlist_hash = brain_compute_attack_wordlist (straight_ctx->dict); @@ -405,6 +441,41 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, custom_charset_4, strlen (custom_charset_4)); } + if (user_options->custom_charset_5) + { + const char *custom_charset_5 = user_options->custom_charset_5; + + XXH64_update (state, custom_charset_5, strlen (custom_charset_5)); + } + + if (user_options->custom_charset_6) + { + const char *custom_charset_6 = user_options->custom_charset_6; + + XXH64_update (state, custom_charset_6, strlen (custom_charset_6)); + } + + if (user_options->custom_charset_7) + { + const char *custom_charset_7 = user_options->custom_charset_7; + + XXH64_update (state, custom_charset_7, strlen (custom_charset_7)); + } + + if (user_options->custom_charset_8) + { + const char *custom_charset_8 = user_options->custom_charset_8; + + XXH64_update (state, custom_charset_8, strlen (custom_charset_8)); + } + + if (user_options->custom_charset_9) + { + const char *custom_charset_9 = user_options->custom_charset_9; + + XXH64_update (state, custom_charset_9, strlen (custom_charset_9)); + } + const int hex_wordlist = user_options->hex_wordlist; XXH64_update (state, &hex_wordlist, sizeof (hex_wordlist)); diff --git a/src/mpsp.c b/src/mpsp.c index ba5511616..8e84cdba0 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -18,7 +18,7 @@ static const char *const DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; -#define MAX_MFS 5 // 4*charset, 1*mask +#define MAX_MFS 10 // 9*charset, 1*mask static int sp_comp_val (const void *p1, const void *p2) { @@ -314,6 +314,21 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_ case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; } rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset); break; + case '5': if (mp_usr[4].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 5 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[4].cs_buf, mp_usr[4].cs_len, mp_usr, mp_usr_offset); + break; + case '6': if (mp_usr[5].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 6 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[5].cs_buf, mp_usr[5].cs_len, mp_usr, mp_usr_offset); + break; + case '7': if (mp_usr[6].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 7 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[6].cs_buf, mp_usr[6].cs_len, mp_usr, mp_usr_offset); + break; + case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, mp_usr, mp_usr_offset); + break; + case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, mp_usr, mp_usr_offset); + break; case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); break; default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", in_buf); @@ -427,6 +442,21 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; } rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css_buf, css_pos); break; + case '5': if (mp_usr[4].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 5 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[4].cs_buf, mp_usr[4].cs_len, css_buf, css_pos); + break; + case '6': if (mp_usr[5].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 6 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[5].cs_buf, mp_usr[5].cs_len, css_buf, css_pos); + break; + case '7': if (mp_usr[6].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 7 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[6].cs_buf, mp_usr[6].cs_len, css_buf, css_pos); + break; + case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, css_buf, css_pos); + break; + case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, css_buf, css_pos); + break; case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos); break; default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", mask_buf); @@ -1416,7 +1446,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; mask_ctx->mp_sys = (cs_t *) hccalloc (8, sizeof (cs_t)); - mask_ctx->mp_usr = (cs_t *) hccalloc (4, sizeof (cs_t)); + mask_ctx->mp_usr = (cs_t *) hccalloc (9, sizeof (cs_t)); mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t)); mask_ctx->css_cnt = 0; @@ -1443,6 +1473,11 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->custom_charset_2) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1) == -1) return -1; } if (user_options->custom_charset_3) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2) == -1) return -1; } if (user_options->custom_charset_4) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3) == -1) return -1; } + if (user_options->custom_charset_5) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_5, 4) == -1) return -1; } + if (user_options->custom_charset_6) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_6, 5) == -1) return -1; } + if (user_options->custom_charset_7) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_7, 6) == -1) return -1; } + if (user_options->custom_charset_8) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7) == -1) return -1; } + if (user_options->custom_charset_9) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8) == -1) return -1; } if (user_options->benchmark == true) { @@ -1739,6 +1774,10 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) mfs_buf[2].mf_len = 0; mfs_buf[3].mf_len = 0; mfs_buf[4].mf_len = 0; + mfs_buf[5].mf_len = 0; + mfs_buf[6].mf_len = 0; + mfs_buf[7].mf_len = 0; + mfs_buf[8].mf_len = 0; size_t mfs_cnt = 0; @@ -1796,11 +1835,21 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_2 = NULL; user_options->custom_charset_3 = NULL; user_options->custom_charset_4 = NULL; + user_options->custom_charset_5 = NULL; + user_options->custom_charset_6 = NULL; + user_options->custom_charset_7 = NULL; + user_options->custom_charset_8 = NULL; + user_options->custom_charset_9 = NULL; mp_reset_usr (mask_ctx->mp_usr, 0); mp_reset_usr (mask_ctx->mp_usr, 1); mp_reset_usr (mask_ctx->mp_usr, 2); mp_reset_usr (mask_ctx->mp_usr, 3); + mp_reset_usr (mask_ctx->mp_usr, 4); + mp_reset_usr (mask_ctx->mp_usr, 5); + mp_reset_usr (mask_ctx->mp_usr, 6); + mp_reset_usr (mask_ctx->mp_usr, 7); + mp_reset_usr (mask_ctx->mp_usr, 8); for (size_t i = 0; i < mfs_cnt; i++) { @@ -1825,6 +1874,31 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_4 = mfs_buf[3].mf_buf; mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3); break; + + case 4: + user_options->custom_charset_5 = mfs_buf[4].mf_buf; + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_5, 4); + break; + + case 5: + user_options->custom_charset_6 = mfs_buf[5].mf_buf; + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_6, 5); + break; + + case 6: + user_options->custom_charset_7 = mfs_buf[6].mf_buf; + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_7, 6); + break; + + case 7: + user_options->custom_charset_8 = mfs_buf[7].mf_buf; + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7); + break; + + case 8: + user_options->custom_charset_9 = mfs_buf[8].mf_buf; + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8); + break; } } diff --git a/src/status.c b/src/status.c index 4e964fd3b..ccdf520f2 100644 --- a/src/status.c +++ b/src/status.c @@ -394,6 +394,11 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx) if (user_options->custom_charset_2) has_mask_cs = true; if (user_options->custom_charset_3) has_mask_cs = true; if (user_options->custom_charset_4) has_mask_cs = true; + if (user_options->custom_charset_5) has_mask_cs = true; + if (user_options->custom_charset_6) has_mask_cs = true; + if (user_options->custom_charset_7) has_mask_cs = true; + if (user_options->custom_charset_8) has_mask_cs = true; + if (user_options->custom_charset_9) has_mask_cs = true; if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)) { @@ -778,8 +783,13 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) const char *custom_charset_2 = user_options->custom_charset_2; const char *custom_charset_3 = user_options->custom_charset_3; const char *custom_charset_4 = user_options->custom_charset_4; + const char *custom_charset_5 = user_options->custom_charset_5; + const char *custom_charset_6 = user_options->custom_charset_6; + const char *custom_charset_7 = user_options->custom_charset_7; + const char *custom_charset_8 = user_options->custom_charset_8; + const char *custom_charset_9 = user_options->custom_charset_9; - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) + if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL) || (custom_charset_9 != NULL)) { char *tmp_buf; @@ -787,8 +797,13 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; + if (custom_charset_5 == NULL) custom_charset_5 = "Undefined"; + if (custom_charset_6 == NULL) custom_charset_6 = "Undefined"; + if (custom_charset_7 == NULL) custom_charset_7 = "Undefined"; + if (custom_charset_8 == NULL) custom_charset_8 = "Undefined"; + if (custom_charset_9 == NULL) custom_charset_9 = "Undefined"; - hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s, -9 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8, custom_charset_9); return tmp_buf; } diff --git a/src/usage.c b/src/usage.c index c79a8c6ac..6de2fab85 100644 --- a/src/usage.c +++ b/src/usage.c @@ -128,6 +128,11 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -2, --custom-charset2 | CS | User-defined charset ?2 | -2 ?l?d?s", " -3, --custom-charset3 | CS | User-defined charset ?3 |", " -4, --custom-charset4 | CS | User-defined charset ?4 |", + " -5, --custom-charset5 | CS | User-defined charset ?5 |", + " -6, --custom-charset6 | CS | User-defined charset ?6 |", + " -7, --custom-charset7 | CS | User-defined charset ?7 |", + " -8, --custom-charset8 | CS | User-defined charset ?8 |", + " -9, --custom-charset9 | CS | User-defined charset ?9 |", " --identify | | Shows all supported algorithms for input hashes | --identify my.hash", " -i, --increment | | Enable mask increment mode |", " --increment-min | Num | Start mask incrementing at X | --increment-min=4", diff --git a/src/user_options.c b/src/user_options.c index a510c1d69..de84bd017 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -21,9 +21,9 @@ #endif #ifdef WITH_BRAIN -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:z"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:z"; #else -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:"; #endif static char *const SEPARATOR = ":"; @@ -51,6 +51,11 @@ static const struct option long_options[] = {"custom-charset2", required_argument, NULL, IDX_CUSTOM_CHARSET_2}, {"custom-charset3", required_argument, NULL, IDX_CUSTOM_CHARSET_3}, {"custom-charset4", required_argument, NULL, IDX_CUSTOM_CHARSET_4}, + {"custom-charset5", required_argument, NULL, IDX_CUSTOM_CHARSET_5}, + {"custom-charset6", required_argument, NULL, IDX_CUSTOM_CHARSET_6}, + {"custom-charset7", required_argument, NULL, IDX_CUSTOM_CHARSET_7}, + {"custom-charset8", required_argument, NULL, IDX_CUSTOM_CHARSET_8}, + {"custom-charset9", required_argument, NULL, IDX_CUSTOM_CHARSET_9}, {"debug-file", required_argument, NULL, IDX_DEBUG_FILE}, {"debug-mode", required_argument, NULL, IDX_DEBUG_MODE}, {"deprecated-check-disable", no_argument, NULL, IDX_DEPRECATED_CHECK_DISABLE}, @@ -164,6 +169,11 @@ static const char *const RULE_BUF_L = ":"; static const char *const DEF_MASK_CS_1 = "?l?d?u"; static const char *const DEF_MASK_CS_2 = "?l?d"; static const char *const DEF_MASK_CS_3 = "?l?d*!$@_"; +static const char *const DEF_MASK_CS_4 = "a"; +static const char *const DEF_MASK_CS_5 = "b"; +static const char *const DEF_MASK_CS_6 = "c"; +static const char *const DEF_MASK_CS_7 = "d"; +static const char *const DEF_MASK_CS_8 = "e"; int user_options_init (hashcat_ctx_t *hashcat_ctx) { @@ -201,6 +211,11 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_2 = NULL; user_options->custom_charset_3 = NULL; user_options->custom_charset_4 = NULL; + user_options->custom_charset_5 = NULL; + user_options->custom_charset_6 = NULL; + user_options->custom_charset_7 = NULL; + user_options->custom_charset_8 = NULL; + user_options->custom_charset_9 = NULL; user_options->debug_file = NULL; user_options->debug_mode = DEBUG_MODE; user_options->deprecated_check_disable = DEPRECATED_CHECK_DISABLE; @@ -523,6 +538,11 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_CUSTOM_CHARSET_2: user_options->custom_charset_2 = optarg; break; case IDX_CUSTOM_CHARSET_3: user_options->custom_charset_3 = optarg; break; case IDX_CUSTOM_CHARSET_4: user_options->custom_charset_4 = optarg; break; + case IDX_CUSTOM_CHARSET_5: user_options->custom_charset_5 = optarg; break; + case IDX_CUSTOM_CHARSET_6: user_options->custom_charset_6 = optarg; break; + case IDX_CUSTOM_CHARSET_7: user_options->custom_charset_7 = optarg; break; + case IDX_CUSTOM_CHARSET_8: user_options->custom_charset_8 = optarg; break; + case IDX_CUSTOM_CHARSET_9: user_options->custom_charset_9 = optarg; break; case IDX_SLOW_CANDIDATES: user_options->slow_candidates = true; break; #ifdef WITH_BRAIN case IDX_BRAIN_CLIENT: user_options->brain_client = true; break; @@ -1313,7 +1333,12 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if ((user_options->custom_charset_1 != NULL) || (user_options->custom_charset_2 != NULL) || (user_options->custom_charset_3 != NULL) - || (user_options->custom_charset_4 != NULL)) + || (user_options->custom_charset_4 != NULL) + || (user_options->custom_charset_5 != NULL) + || (user_options->custom_charset_6 != NULL) + || (user_options->custom_charset_7 != NULL) + || (user_options->custom_charset_8 != NULL) + || (user_options->custom_charset_9 != NULL)) { if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)) { @@ -1465,7 +1490,12 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if ((user_options->custom_charset_1 != NULL) || (user_options->custom_charset_2 != NULL) || (user_options->custom_charset_3 != NULL) - || (user_options->custom_charset_4 != NULL)) + || (user_options->custom_charset_4 != NULL) + || (user_options->custom_charset_5 != NULL) + || (user_options->custom_charset_6 != NULL) + || (user_options->custom_charset_7 != NULL) + || (user_options->custom_charset_8 != NULL) + || (user_options->custom_charset_9 != NULL)) { if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { @@ -2009,6 +2039,11 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; + user_options->custom_charset_4 = DEF_MASK_CS_4; + user_options->custom_charset_5 = DEF_MASK_CS_5; + user_options->custom_charset_6 = DEF_MASK_CS_6; + user_options->custom_charset_7 = DEF_MASK_CS_7; + user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -2020,6 +2055,11 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; + user_options->custom_charset_4 = DEF_MASK_CS_4; + user_options->custom_charset_5 = DEF_MASK_CS_5; + user_options->custom_charset_6 = DEF_MASK_CS_6; + user_options->custom_charset_7 = DEF_MASK_CS_7; + user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -2031,6 +2071,11 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; + user_options->custom_charset_4 = DEF_MASK_CS_4; + user_options->custom_charset_5 = DEF_MASK_CS_5; + user_options->custom_charset_6 = DEF_MASK_CS_6; + user_options->custom_charset_7 = DEF_MASK_CS_7; + user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -3167,6 +3212,11 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_string (user_options->custom_charset_2); logfile_top_string (user_options->custom_charset_3); logfile_top_string (user_options->custom_charset_4); + logfile_top_string (user_options->custom_charset_5); + logfile_top_string (user_options->custom_charset_6); + logfile_top_string (user_options->custom_charset_7); + logfile_top_string (user_options->custom_charset_8); + logfile_top_string (user_options->custom_charset_9); logfile_top_string (user_options->debug_file); logfile_top_string (user_options->encoding_from); logfile_top_string (user_options->encoding_to); From b437459e5ba0e7d3428a59cd1460050e90f347af Mon Sep 17 00:00:00 2001 From: Flaggx1 Date: Sun, 21 May 2023 02:10:14 -0400 Subject: [PATCH 002/357] Rename "Undefined" to "Undef" in status output for unused user charsets --- src/status.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/status.c b/src/status.c index ccdf520f2..4c973bdab 100644 --- a/src/status.c +++ b/src/status.c @@ -793,15 +793,15 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) { char *tmp_buf; - if (custom_charset_1 == NULL) custom_charset_1 = "Undefined"; - if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; - if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; - if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - if (custom_charset_5 == NULL) custom_charset_5 = "Undefined"; - if (custom_charset_6 == NULL) custom_charset_6 = "Undefined"; - if (custom_charset_7 == NULL) custom_charset_7 = "Undefined"; - if (custom_charset_8 == NULL) custom_charset_8 = "Undefined"; - if (custom_charset_9 == NULL) custom_charset_9 = "Undefined"; + if (custom_charset_1 == NULL) custom_charset_1 = "Undef"; + if (custom_charset_2 == NULL) custom_charset_2 = "Undef"; + if (custom_charset_3 == NULL) custom_charset_3 = "Undef"; + if (custom_charset_4 == NULL) custom_charset_4 = "Undef"; + if (custom_charset_5 == NULL) custom_charset_5 = "Undef"; + if (custom_charset_6 == NULL) custom_charset_6 = "Undef"; + if (custom_charset_7 == NULL) custom_charset_7 = "Undef"; + if (custom_charset_8 == NULL) custom_charset_8 = "Undef"; + if (custom_charset_9 == NULL) custom_charset_9 = "Undef"; hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s, -9 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8, custom_charset_9); From 6e164ad9c53b707598f18043b5869efd89f58b25 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 <64717060+PenguinKeeper7@users.noreply.github.com> Date: Thu, 23 Nov 2023 20:14:25 +0000 Subject: [PATCH 003/357] Add faq link to potfile advice --- src/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.c b/src/main.c index 085ce38b4..183a2f249 100644 --- a/src/main.c +++ b/src/main.c @@ -466,6 +466,7 @@ static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (user_options->quiet == true) return; event_log_info (hashcat_ctx, "INFO: All hashes found as potfile and/or empty entries! Use --show to display them."); + event_log_info (hashcat_ctx, "For more information, see https://hashcat.net/faq/potfile"); event_log_info (hashcat_ctx, NULL); } From cd5dc9e3ce5834ef394a09641143add7f87d8a0f Mon Sep 17 00:00:00 2001 From: Royce Williams Date: Tue, 12 Dec 2023 23:00:20 -0900 Subject: [PATCH 004/357] summarize invalid rule chains --- src/rp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rp.c b/src/rp.c index 67ebd9322..ace86877b 100644 --- a/src/rp.c +++ b/src/rp.c @@ -906,6 +906,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 } u32 invalid_cnt = 0; + u32 valid_cnt = 0; for (u32 i = 0; i < kernel_rules_cnt; i++) { @@ -924,18 +925,27 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 { if (out_pos == RULES_MAX - 1) { - event_log_warning (hashcat_ctx, "Maximum functions per rule exceeded during chaining of rules, skipping..."); - invalid_cnt++; break; } + else + { + valid_cnt++; + } out->cmds[out_pos] = in->cmds[in_pos]; } } } + if (invalid_cnt > 0) + { + event_log_warning (hashcat_ctx, "Maximum functions per rule exceeded during chaining of rules."); + event_log_warning (hashcat_ctx, "Skipped %u rule chains, %u valid chains remain.", invalid_cnt, valid_cnt); + event_log_warning (hashcat_ctx, NULL); + } + hcfree (repeats); kernel_rules_cnt -= invalid_cnt; From 892bb5183cf2b377f5183bfde62c895f8eec352a Mon Sep 17 00:00:00 2001 From: philsmd Date: Sun, 7 Jan 2024 11:56:16 +0100 Subject: [PATCH 005/357] update license year to 2024 --- docs/license.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/license.txt b/docs/license.txt index 93d2971ae..88a5d2361 100644 --- a/docs/license.txt +++ b/docs/license.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2023 Jens Steube +Copyright (c) 2015-2024 Jens Steube Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From cf27ff42723ce6ae31e69dd1ed4895a7bced7270 Mon Sep 17 00:00:00 2001 From: Serge van den Boom Date: Thu, 18 Jan 2024 23:14:16 +0100 Subject: [PATCH 006/357] Improve error messages for module_ctx_t structure validation checks. --- src/interface.c | 196 ++++++++++++++++++++++++------------------------ 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/src/interface.c b/src/interface.c index 691e2931b..cf5afdb0b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -125,130 +125,130 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (module_ctx->module_context_size != MODULE_CONTEXT_SIZE_CURRENT) { - event_log_error (hashcat_ctx, "module context size is invalid. Old template?"); + event_log_error (hashcat_ctx, "Module context size in 'module_init()' for hash-mode '%d' is invalid. Old template?", user_options->hash_mode); return -1; } if (module_ctx->module_interface_version < MODULE_INTERFACE_VERSION_MINIMUM) { - event_log_error (hashcat_ctx, "module interface version is outdated, please compile"); + event_log_error (hashcat_ctx, "Interface version in module context in 'module_init()' for hash-mode '%d' is outdated. Please recompile.", user_options->hash_mode); return -1; } // check for missing pointer assignments - #define CHECK_DEFINED(func) \ - if ((func) == NULL) \ + #define CHECK_DEFINED(module_ctx, func) \ + if ((module_ctx)->func == NULL) \ { \ - event_log_error (hashcat_ctx, "Missing symbol definitions module for in hash-mode '%d'. Old template?", user_options->hash_mode); \ + event_log_error (hashcat_ctx, "Module context missing field '%s' in 'module_init()' for hash-mode '%d'. Old template?", #func, user_options->hash_mode); \ \ return -1; \ } - CHECK_DEFINED (module_ctx->module_attack_exec); - CHECK_DEFINED (module_ctx->module_benchmark_esalt); - CHECK_DEFINED (module_ctx->module_benchmark_hook_salt); - CHECK_DEFINED (module_ctx->module_benchmark_mask); - CHECK_DEFINED (module_ctx->module_benchmark_charset); - CHECK_DEFINED (module_ctx->module_benchmark_salt); - CHECK_DEFINED (module_ctx->module_build_plain_postprocess); - CHECK_DEFINED (module_ctx->module_deep_comp_kernel); - CHECK_DEFINED (module_ctx->module_deprecated_notice); - CHECK_DEFINED (module_ctx->module_dgst_pos0); - CHECK_DEFINED (module_ctx->module_dgst_pos1); - CHECK_DEFINED (module_ctx->module_dgst_pos2); - CHECK_DEFINED (module_ctx->module_dgst_pos3); - CHECK_DEFINED (module_ctx->module_dgst_size); - CHECK_DEFINED (module_ctx->module_dictstat_disable); - CHECK_DEFINED (module_ctx->module_esalt_size); - CHECK_DEFINED (module_ctx->module_extra_buffer_size); - CHECK_DEFINED (module_ctx->module_extra_tmp_size); - CHECK_DEFINED (module_ctx->module_extra_tuningdb_block); - CHECK_DEFINED (module_ctx->module_forced_outfile_format); - CHECK_DEFINED (module_ctx->module_hash_binary_count); - CHECK_DEFINED (module_ctx->module_hash_binary_parse); - CHECK_DEFINED (module_ctx->module_hash_binary_save); - CHECK_DEFINED (module_ctx->module_hash_category); - CHECK_DEFINED (module_ctx->module_hash_decode); - CHECK_DEFINED (module_ctx->module_hash_decode_postprocess); - CHECK_DEFINED (module_ctx->module_hash_decode_potfile); - CHECK_DEFINED (module_ctx->module_hash_decode_zero_hash); - CHECK_DEFINED (module_ctx->module_hash_encode); - CHECK_DEFINED (module_ctx->module_hash_encode_potfile); - CHECK_DEFINED (module_ctx->module_hash_encode_status); - CHECK_DEFINED (module_ctx->module_hash_init_selftest); - CHECK_DEFINED (module_ctx->module_hash_mode); - CHECK_DEFINED (module_ctx->module_hash_name); - CHECK_DEFINED (module_ctx->module_hashes_count_max); - CHECK_DEFINED (module_ctx->module_hashes_count_min); - CHECK_DEFINED (module_ctx->module_hlfmt_disable); - CHECK_DEFINED (module_ctx->module_hook_extra_param_size); - CHECK_DEFINED (module_ctx->module_hook_extra_param_init); - CHECK_DEFINED (module_ctx->module_hook_extra_param_term); - CHECK_DEFINED (module_ctx->module_hook12); - CHECK_DEFINED (module_ctx->module_hook23); - CHECK_DEFINED (module_ctx->module_hook_salt_size); - CHECK_DEFINED (module_ctx->module_hook_size); - CHECK_DEFINED (module_ctx->module_jit_build_options); - CHECK_DEFINED (module_ctx->module_jit_cache_disable); - CHECK_DEFINED (module_ctx->module_kern_type); - CHECK_DEFINED (module_ctx->module_kern_type_dynamic); - CHECK_DEFINED (module_ctx->module_kernel_accel_max); - CHECK_DEFINED (module_ctx->module_kernel_accel_min); - CHECK_DEFINED (module_ctx->module_kernel_loops_max); - CHECK_DEFINED (module_ctx->module_kernel_loops_min); - CHECK_DEFINED (module_ctx->module_kernel_threads_max); - CHECK_DEFINED (module_ctx->module_kernel_threads_min); - CHECK_DEFINED (module_ctx->module_opti_type); - CHECK_DEFINED (module_ctx->module_opts_type); - CHECK_DEFINED (module_ctx->module_outfile_check_disable); - CHECK_DEFINED (module_ctx->module_outfile_check_nocomp); - CHECK_DEFINED (module_ctx->module_potfile_custom_check); - CHECK_DEFINED (module_ctx->module_potfile_disable); - CHECK_DEFINED (module_ctx->module_potfile_keep_all_hashes); - CHECK_DEFINED (module_ctx->module_pw_max); - CHECK_DEFINED (module_ctx->module_pw_min); - CHECK_DEFINED (module_ctx->module_pwdump_column); - CHECK_DEFINED (module_ctx->module_salt_max); - CHECK_DEFINED (module_ctx->module_salt_min); - CHECK_DEFINED (module_ctx->module_salt_type); - CHECK_DEFINED (module_ctx->module_separator); - CHECK_DEFINED (module_ctx->module_st_hash); - CHECK_DEFINED (module_ctx->module_st_pass); - CHECK_DEFINED (module_ctx->module_tmp_size); - CHECK_DEFINED (module_ctx->module_unstable_warning); - CHECK_DEFINED (module_ctx->module_warmup_disable); + CHECK_DEFINED (module_ctx, module_attack_exec); + CHECK_DEFINED (module_ctx, module_benchmark_esalt); + CHECK_DEFINED (module_ctx, module_benchmark_hook_salt); + CHECK_DEFINED (module_ctx, module_benchmark_mask); + CHECK_DEFINED (module_ctx, module_benchmark_charset); + CHECK_DEFINED (module_ctx, module_benchmark_salt); + CHECK_DEFINED (module_ctx, module_build_plain_postprocess); + CHECK_DEFINED (module_ctx, module_deep_comp_kernel); + CHECK_DEFINED (module_ctx, module_deprecated_notice); + CHECK_DEFINED (module_ctx, module_dgst_pos0); + CHECK_DEFINED (module_ctx, module_dgst_pos1); + CHECK_DEFINED (module_ctx, module_dgst_pos2); + CHECK_DEFINED (module_ctx, module_dgst_pos3); + CHECK_DEFINED (module_ctx, module_dgst_size); + CHECK_DEFINED (module_ctx, module_dictstat_disable); + CHECK_DEFINED (module_ctx, module_esalt_size); + CHECK_DEFINED (module_ctx, module_extra_buffer_size); + CHECK_DEFINED (module_ctx, module_extra_tmp_size); + CHECK_DEFINED (module_ctx, module_extra_tuningdb_block); + CHECK_DEFINED (module_ctx, module_forced_outfile_format); + CHECK_DEFINED (module_ctx, module_hash_binary_count); + CHECK_DEFINED (module_ctx, module_hash_binary_parse); + CHECK_DEFINED (module_ctx, module_hash_binary_save); + CHECK_DEFINED (module_ctx, module_hash_category); + CHECK_DEFINED (module_ctx, module_hash_decode); + CHECK_DEFINED (module_ctx, module_hash_decode_postprocess); + CHECK_DEFINED (module_ctx, module_hash_decode_potfile); + CHECK_DEFINED (module_ctx, module_hash_decode_zero_hash); + CHECK_DEFINED (module_ctx, module_hash_encode); + CHECK_DEFINED (module_ctx, module_hash_encode_potfile); + CHECK_DEFINED (module_ctx, module_hash_encode_status); + CHECK_DEFINED (module_ctx, module_hash_init_selftest); + CHECK_DEFINED (module_ctx, module_hash_mode); + CHECK_DEFINED (module_ctx, module_hash_name); + CHECK_DEFINED (module_ctx, module_hashes_count_max); + CHECK_DEFINED (module_ctx, module_hashes_count_min); + CHECK_DEFINED (module_ctx, module_hlfmt_disable); + CHECK_DEFINED (module_ctx, module_hook_extra_param_size); + CHECK_DEFINED (module_ctx, module_hook_extra_param_init); + CHECK_DEFINED (module_ctx, module_hook_extra_param_term); + CHECK_DEFINED (module_ctx, module_hook12); + CHECK_DEFINED (module_ctx, module_hook23); + CHECK_DEFINED (module_ctx, module_hook_salt_size); + CHECK_DEFINED (module_ctx, module_hook_size); + CHECK_DEFINED (module_ctx, module_jit_build_options); + CHECK_DEFINED (module_ctx, module_jit_cache_disable); + CHECK_DEFINED (module_ctx, module_kern_type); + CHECK_DEFINED (module_ctx, module_kern_type_dynamic); + CHECK_DEFINED (module_ctx, module_kernel_accel_max); + CHECK_DEFINED (module_ctx, module_kernel_accel_min); + CHECK_DEFINED (module_ctx, module_kernel_loops_max); + CHECK_DEFINED (module_ctx, module_kernel_loops_min); + CHECK_DEFINED (module_ctx, module_kernel_threads_max); + CHECK_DEFINED (module_ctx, module_kernel_threads_min); + CHECK_DEFINED (module_ctx, module_opti_type); + CHECK_DEFINED (module_ctx, module_opts_type); + CHECK_DEFINED (module_ctx, module_outfile_check_disable); + CHECK_DEFINED (module_ctx, module_outfile_check_nocomp); + CHECK_DEFINED (module_ctx, module_potfile_custom_check); + CHECK_DEFINED (module_ctx, module_potfile_disable); + CHECK_DEFINED (module_ctx, module_potfile_keep_all_hashes); + CHECK_DEFINED (module_ctx, module_pw_max); + CHECK_DEFINED (module_ctx, module_pw_min); + CHECK_DEFINED (module_ctx, module_pwdump_column); + CHECK_DEFINED (module_ctx, module_salt_max); + CHECK_DEFINED (module_ctx, module_salt_min); + CHECK_DEFINED (module_ctx, module_salt_type); + CHECK_DEFINED (module_ctx, module_separator); + CHECK_DEFINED (module_ctx, module_st_hash); + CHECK_DEFINED (module_ctx, module_st_pass); + CHECK_DEFINED (module_ctx, module_tmp_size); + CHECK_DEFINED (module_ctx, module_unstable_warning); + CHECK_DEFINED (module_ctx, module_warmup_disable); #undef CHECK_DEFINED // mandatory functions check - #define CHECK_MANDATORY(func) \ - if ((func) == MODULE_DEFAULT) \ + #define CHECK_MANDATORY(module_ctx, func) \ + if ((module_ctx)->func == MODULE_DEFAULT) \ { \ - event_log_error (hashcat_ctx, "Missing mandatory symbol definitions"); \ + event_log_error (hashcat_ctx, "Module context field '%s' in 'module_init()' for hash-mode '%d' is set to MODULE_DEFAULT, but must be explicitly set.", #func, user_options->hash_mode); \ \ return -1; \ } - CHECK_MANDATORY (module_ctx->module_attack_exec); - CHECK_MANDATORY (module_ctx->module_dgst_pos0); - CHECK_MANDATORY (module_ctx->module_dgst_pos1); - CHECK_MANDATORY (module_ctx->module_dgst_pos2); - CHECK_MANDATORY (module_ctx->module_dgst_pos3); - CHECK_MANDATORY (module_ctx->module_dgst_size); - CHECK_MANDATORY (module_ctx->module_hash_decode); - // CHECK_MANDATORY (module_ctx->module_hash_encode); we do that one later - CHECK_MANDATORY (module_ctx->module_hash_category); - CHECK_MANDATORY (module_ctx->module_hash_name); - CHECK_MANDATORY (module_ctx->module_kern_type); - CHECK_MANDATORY (module_ctx->module_opti_type); - CHECK_MANDATORY (module_ctx->module_opts_type); - CHECK_MANDATORY (module_ctx->module_salt_type); - CHECK_MANDATORY (module_ctx->module_st_hash); - CHECK_MANDATORY (module_ctx->module_st_pass); + CHECK_MANDATORY (module_ctx, module_attack_exec); + CHECK_MANDATORY (module_ctx, module_dgst_pos0); + CHECK_MANDATORY (module_ctx, module_dgst_pos1); + CHECK_MANDATORY (module_ctx, module_dgst_pos2); + CHECK_MANDATORY (module_ctx, module_dgst_pos3); + CHECK_MANDATORY (module_ctx, module_dgst_size); + CHECK_MANDATORY (module_ctx, module_hash_decode); + // CHECK_MANDATORY (module_ctx, module_hash_encode); we do that one later + CHECK_MANDATORY (module_ctx, module_hash_category); + CHECK_MANDATORY (module_ctx, module_hash_name); + CHECK_MANDATORY (module_ctx, module_kern_type); + CHECK_MANDATORY (module_ctx, module_opti_type); + CHECK_MANDATORY (module_ctx, module_opts_type); + CHECK_MANDATORY (module_ctx, module_salt_type); + CHECK_MANDATORY (module_ctx, module_st_hash); + CHECK_MANDATORY (module_ctx, module_st_pass); hashconfig->attack_exec = module_ctx->module_attack_exec (hashconfig, user_options, user_options_extra); hashconfig->dgst_pos0 = module_ctx->module_dgst_pos0 (hashconfig, user_options, user_options_extra); @@ -267,7 +267,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if ((hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) == 0) { - CHECK_MANDATORY (module_ctx->module_hash_encode); + CHECK_MANDATORY (module_ctx, module_hash_encode); } #undef CHECK_MANDATORY From c5b81ab8ec4a4f709a1ed850728b4b6bc93fa35f Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Mon, 29 Jan 2024 00:18:32 +0000 Subject: [PATCH 007/357] Flush debug-file more often Instead of only flushing/unlocking the debug file at the end of the run, flush after each write, aligning it with the outfile and potfile's behaviour --- src/debugfile.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/debugfile.c b/src/debugfile.c index 20ee3ad1f..ea0d61365 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -76,6 +76,11 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con if ((debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) hc_fputc (':', &debugfile_ctx->fp); } + if (hc_lockfile (&debugfile_ctx->fp) == -1) + { + event_log_error (hashcat_ctx, "%s: Failed to lock file.", debugfile_ctx->filename); + } + hc_fwrite (rule_buf, rule_len, 1, &debugfile_ctx->fp); if ((debug_mode == 4) || (debug_mode == 5)) @@ -104,6 +109,13 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con } hc_fwrite (EOL, strlen (EOL), 1, &debugfile_ctx->fp); + + hc_fflush (&debugfile_ctx->fp); + + if (hc_unlockfile (&debugfile_ctx->fp)) + { + event_log_error (hashcat_ctx, "%s: Failed to unlock file.", debugfile_ctx->filename); + } } int debugfile_init (hashcat_ctx_t *hashcat_ctx) @@ -150,15 +162,6 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) return -1; } - if (hc_lockfile (&debugfile_ctx->fp) == -1) - { - hc_fclose (&debugfile_ctx->fp); - - event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno)); - - return -1; - } - return 0; } From cd74101a04dfb5c07c4b28192e6b3a9f65945611 Mon Sep 17 00:00:00 2001 From: c0rs <0xc0rs@gmail.com> Date: Tue, 30 Jan 2024 00:20:41 +0300 Subject: [PATCH 008/357] RACF KDFAES module --- OpenCL/m34000-pure.cl | 1135 ++++++++++++++++++++++++++++++++++ src/modules/module_34000.c | 378 +++++++++++ tools/test_modules/m34000.pm | 175 ++++++ 3 files changed, 1688 insertions(+) create mode 100644 OpenCL/m34000-pure.cl create mode 100644 src/modules/module_34000.c create mode 100644 tools/test_modules/m34000.pm diff --git a/OpenCL/m34000-pure.cl b/OpenCL/m34000-pure.cl new file mode 100644 index 000000000..e7f279a37 --- /dev/null +++ b/OpenCL/m34000-pure.cl @@ -0,0 +1,1135 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_cipher_des.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_tmpx +{ + u32x ipad[8]; + u32x opad[8]; + + u32x dgst[32]; + u32x out[32]; + +} pbkdf2_sha256_tmpx_t; + +typedef struct racf_kdfaes_tmp +{ + u32 key[16]; + u32 salt_buf[16]; + u32 salt_len; + + u32 out[256]; // change for mem_fact > 10 + u32 out_len; + + pbkdf2_sha256_tmp_t pbkdf2_tmps; +} racf_kdfaes_tmp_t; + +typedef struct racf_kdfaes +{ + u32 salt_buf[64]; + u32 mem_fac; + u32 rep_fac; + +} racf_kdfaes_t; + +CONSTANT_VK u32a c_ascii_to_ebcdic_pc[256] = +{ + // little hack, can't crack 0-bytes in password, but who cares + // 0xab, 0xa8, 0xae, 0xad, 0xc4, 0xf1, 0xf7, 0xf4, 0x86, 0xa1, 0xe0, 0xbc, 0xb3, 0xb0, 0xb6, 0xb5, + 0x2a, 0xa8, 0xae, 0xad, 0xc4, 0xf1, 0xf7, 0xf4, 0x86, 0xa1, 0xe0, 0xbc, 0xb3, 0xb0, 0xb6, 0xb5, + 0x8a, 0x89, 0x8f, 0x8c, 0xd3, 0xd0, 0xce, 0xe6, 0x9b, 0x98, 0xd5, 0xe5, 0x92, 0x91, 0x97, 0x94, + 0x2a, 0x34, 0x54, 0x5d, 0x1c, 0x73, 0x0b, 0x51, 0x31, 0x10, 0x13, 0x37, 0x7c, 0x6b, 0x3d, 0x68, + 0x4a, 0x49, 0x4f, 0x4c, 0x43, 0x40, 0x46, 0x45, 0x5b, 0x58, 0x5e, 0x16, 0x32, 0x57, 0x76, 0x75, + 0x52, 0x29, 0x2f, 0x2c, 0x23, 0x20, 0x26, 0x25, 0x3b, 0x38, 0x08, 0x0e, 0x0d, 0x02, 0x01, 0x07, + 0x04, 0x1a, 0x19, 0x6e, 0x6d, 0x62, 0x61, 0x67, 0x64, 0x7a, 0x79, 0x3e, 0x6b, 0x1f, 0x15, 0x70, + 0x58, 0xa8, 0xae, 0xad, 0xa2, 0xa1, 0xa7, 0xa4, 0xba, 0xb9, 0x89, 0x8f, 0x8c, 0x83, 0x80, 0x86, + 0x85, 0x9b, 0x98, 0xef, 0xec, 0xe3, 0xe0, 0xe6, 0xe5, 0xfb, 0xf8, 0x2a, 0x7f, 0x0b, 0xe9, 0xa4, + 0xea, 0xe9, 0xef, 0xec, 0xe3, 0x80, 0xa7, 0x85, 0xfb, 0xf8, 0xfe, 0xfd, 0xf2, 0xb9, 0xbf, 0x9d, + 0xcb, 0xc8, 0x9e, 0xcd, 0xc2, 0xc1, 0xc7, 0xba, 0xda, 0xd9, 0xdf, 0xdc, 0xa2, 0x83, 0xd6, 0x68, + 0x29, 0x2f, 0x2c, 0x23, 0x20, 0x26, 0x25, 0x3b, 0x38, 0x08, 0x0e, 0x0d, 0x02, 0x01, 0x07, 0x04, + 0x1a, 0x19, 0x6e, 0x6d, 0x62, 0x61, 0x67, 0x64, 0x7a, 0x79, 0x4a, 0x49, 0x4f, 0x4c, 0x43, 0x40, + 0x46, 0x45, 0x5b, 0xab, 0xbf, 0xbc, 0xb3, 0xb0, 0xb6, 0xb5, 0x8a, 0x9e, 0x9d, 0x92, 0x91, 0x97, + 0x94, 0xea, 0xfe, 0xfd, 0xf2, 0xf1, 0xf7, 0xf4, 0xcb, 0xc8, 0xce, 0xcd, 0xc2, 0xc1, 0xc7, 0xc4, + 0xda, 0xd9, 0xdf, 0xdc, 0xd3, 0xd0, 0xd6, 0xd5, 0x3e, 0x3d, 0x32, 0x31, 0x37, 0x34, 0x1f, 0x1c, + 0x13, 0x10, 0x16, 0x15, 0x7f, 0x7c, 0x73, 0x70, 0x76, 0x75, 0x5e, 0x5d, 0x52, 0x51, 0x57, 0x54, +}; + +#if VECT_SIZE == 1 +#define pbkdf2_sha256_packv(arr,var,idx) make_u32x ((arr)[0].var[(idx)]) +#elif VECT_SIZE == 2 +#define pbkdf2_sha256_packv(arr,var,idx) make_u32x ((arr)[0].var[(idx)], ((arr)[1].var[(idx)])) +#elif VECT_SIZE == 4 +#define pbkdf2_sha256_packv(arr,var,idx) make_u32x ((arr)[0].var[(idx)], ((arr)[1].var[(idx)]), (arr)[2].var[(idx)], ((arr)[3].var[(idx)])) +#elif VECT_SIZE == 8 +#define pbkdf2_sha256_packv(arr,var,idx) make_u32x ((arr)[0].var[(idx)], ((arr)[1].var[(idx)]), (arr)[2].var[(idx)], ((arr)[3].var[(idx)]), (arr)[4].var[(idx)], ((arr)[5].var[(idx)]), (arr)[6].var[(idx)], ((arr)[7].var[(idx)])) +#elif VECT_SIZE == 16 +#define pbkdf2_sha256_packv(arr,var,idx) make_u32x ((arr)[0].var[(idx)], ((arr)[1].var[(idx)]), (arr)[2].var[(idx)], ((arr)[3].var[(idx)]), (arr)[4].var[(idx)], ((arr)[5].var[(idx)]), (arr)[6].var[(idx)], ((arr)[7].var[(idx)]), (arr)[8].var[(idx)], ((arr)[9].var[(idx)]), (arr)[10].var[(idx)], ((arr)[11].var[(idx)]), (arr)[12].var[(idx)], ((arr)[13].var[(idx)]), (arr)[14].var[(idx)], ((arr)[15].var[(idx)])) +#endif + +#if VECT_SIZE == 1 +#define pbkdf2_sha256_unpackv(arr,var,idx,val) (arr)[0].var[(idx)] = val[(idx)]; +#elif VECT_SIZE == 2 +#define pbkdf2_sha256_unpackv(arr,var,idx,val) (arr)[0].var[(idx)] = val[(idx)].s0; (arr)[1].var[(idx)] = val[(idx)].s1; +#elif VECT_SIZE == 4 +#define pbkdf2_sha256_unpackv(arr,var,idx,val) (arr)[0].var[(idx)] = val[(idx)].s0; (arr)[1].var[(idx)] = val[(idx)].s1; (arr)[2].var[(idx)] = val[(idx)].s2; (arr)[3].var[(idx)] = val[(idx)].s3; +#elif VECT_SIZE == 8 +#define pbkdf2_sha256_unpackv(arr,var,idx,val) (arr)[0].var[(idx)] = val[(idx)].s0; (arr)[1].var[(idx)] = val[(idx)].s1; (arr)[2].var[(idx)] = val[(idx)].s2; (arr)[3].var[(idx)] = val[(idx)].s3; (arr)[4].var[(idx)] = val[(idx)].s4; (arr)[5].var[(idx)] = val[(idx)].s5; (arr)[6].var[(idx)] = val[(idx)].s6; (arr)[7].var[(idx)] = val[(idx)].s7; +#elif VECT_SIZE == 16 +#define pbkdf2_sha256_unpackv(arr,var,idx,val) (arr)[0].var[(idx)] = val[(idx)].s0; (arr)[1].var[(idx)] = val[(idx)].s1; (arr)[2].var[(idx)] = val[(idx)].s2; (arr)[3].var[(idx)] = val[(idx)].s3; (arr)[4].var[(idx)] = val[(idx)].s4; (arr)[5].var[(idx)] = val[(idx)].s5; (arr)[6].var[(idx)] = val[(idx)].s6; (arr)[7].var[(idx)] = val[(idx)].s7; (arr)[8].var[(idx)] = val[(idx)].s8; (arr)[9].var[(idx)] = val[(idx)].s9; (arr)[10].var[(idx)] = val[(idx)].sa; (arr)[11].var[(idx)] = val[(idx)].sb; (arr)[12].var[(idx)] = val[(idx)].sc; (arr)[13].var[(idx)] = val[(idx)].sd; (arr)[14].var[(idx)] = val[(idx)].se; (arr)[15].var[(idx)] = val[(idx)].sf; +#endif + +DECLSPEC void convert_pbkdf2_sha256_from_V(pbkdf2_sha256_tmpx_t *tmpx, pbkdf2_sha256_tmp_t *tmps) +{ + pbkdf2_sha256_unpackv (tmps, ipad, 0, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 1, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 2, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 3, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 4, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 5, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 6, tmpx->ipad); + pbkdf2_sha256_unpackv (tmps, ipad, 7, tmpx->ipad); + + pbkdf2_sha256_unpackv (tmps, opad, 0, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 1, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 2, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 3, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 4, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 5, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 6, tmpx->opad); + pbkdf2_sha256_unpackv (tmps, opad, 7, tmpx->opad); + + pbkdf2_sha256_unpackv (tmps, dgst, 0, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 1, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 2, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 3, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 4, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 5, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 6, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 7, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 8, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 9, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 10, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 11, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 12, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 13, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 14, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 15, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 16, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 17, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 18, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 19, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 20, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 21, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 22, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 23, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 24, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 25, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 26, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 27, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 28, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 29, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 30, tmpx->dgst); + pbkdf2_sha256_unpackv (tmps, dgst, 31, tmpx->dgst); + + pbkdf2_sha256_unpackv (tmps, out, 0, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 1, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 2, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 3, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 4, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 5, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 6, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 7, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 8, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 9, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 10, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 11, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 12, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 13, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 14, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 15, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 16, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 17, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 18, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 19, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 20, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 21, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 22, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 23, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 24, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 25, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 26, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 27, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 28, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 29, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 30, tmpx->out); + pbkdf2_sha256_unpackv (tmps, out, 31, tmpx->out); +} + +DECLSPEC void convert_pbkdf2_sha256_to_V(pbkdf2_sha256_tmp_t *tmps, pbkdf2_sha256_tmpx_t *tmpx) +{ + tmpx->ipad[0] = pbkdf2_sha256_packv (tmps, ipad, 0); + tmpx->ipad[1] = pbkdf2_sha256_packv (tmps, ipad, 1); + tmpx->ipad[2] = pbkdf2_sha256_packv (tmps, ipad, 2); + tmpx->ipad[3] = pbkdf2_sha256_packv (tmps, ipad, 3); + tmpx->ipad[4] = pbkdf2_sha256_packv (tmps, ipad, 4); + tmpx->ipad[5] = pbkdf2_sha256_packv (tmps, ipad, 5); + tmpx->ipad[6] = pbkdf2_sha256_packv (tmps, ipad, 6); + tmpx->ipad[7] = pbkdf2_sha256_packv (tmps, ipad, 7); + + tmpx->opad[0] = pbkdf2_sha256_packv (tmps, opad, 0); + tmpx->opad[1] = pbkdf2_sha256_packv (tmps, opad, 1); + tmpx->opad[2] = pbkdf2_sha256_packv (tmps, opad, 2); + tmpx->opad[3] = pbkdf2_sha256_packv (tmps, opad, 3); + tmpx->opad[4] = pbkdf2_sha256_packv (tmps, opad, 4); + tmpx->opad[5] = pbkdf2_sha256_packv (tmps, opad, 5); + tmpx->opad[6] = pbkdf2_sha256_packv (tmps, opad, 6); + tmpx->opad[7] = pbkdf2_sha256_packv (tmps, opad, 7); + + tmpx->dgst[0] = pbkdf2_sha256_packv (tmps, dgst, 0); + tmpx->dgst[1] = pbkdf2_sha256_packv (tmps, dgst, 1); + tmpx->dgst[2] = pbkdf2_sha256_packv (tmps, dgst, 2); + tmpx->dgst[3] = pbkdf2_sha256_packv (tmps, dgst, 3); + tmpx->dgst[4] = pbkdf2_sha256_packv (tmps, dgst, 4); + tmpx->dgst[5] = pbkdf2_sha256_packv (tmps, dgst, 5); + tmpx->dgst[6] = pbkdf2_sha256_packv (tmps, dgst, 6); + tmpx->dgst[7] = pbkdf2_sha256_packv (tmps, dgst, 7); + tmpx->dgst[8] = pbkdf2_sha256_packv (tmps, dgst, 8); + tmpx->dgst[9] = pbkdf2_sha256_packv (tmps, dgst, 9); + tmpx->dgst[10] = pbkdf2_sha256_packv (tmps, dgst, 10); + tmpx->dgst[11] = pbkdf2_sha256_packv (tmps, dgst, 11); + tmpx->dgst[12] = pbkdf2_sha256_packv (tmps, dgst, 12); + tmpx->dgst[13] = pbkdf2_sha256_packv (tmps, dgst, 13); + tmpx->dgst[14] = pbkdf2_sha256_packv (tmps, dgst, 14); + tmpx->dgst[15] = pbkdf2_sha256_packv (tmps, dgst, 15); + tmpx->dgst[16] = pbkdf2_sha256_packv (tmps, dgst, 16); + tmpx->dgst[17] = pbkdf2_sha256_packv (tmps, dgst, 17); + tmpx->dgst[18] = pbkdf2_sha256_packv (tmps, dgst, 18); + tmpx->dgst[19] = pbkdf2_sha256_packv (tmps, dgst, 19); + tmpx->dgst[20] = pbkdf2_sha256_packv (tmps, dgst, 20); + tmpx->dgst[21] = pbkdf2_sha256_packv (tmps, dgst, 21); + tmpx->dgst[22] = pbkdf2_sha256_packv (tmps, dgst, 22); + tmpx->dgst[23] = pbkdf2_sha256_packv (tmps, dgst, 23); + tmpx->dgst[24] = pbkdf2_sha256_packv (tmps, dgst, 24); + tmpx->dgst[25] = pbkdf2_sha256_packv (tmps, dgst, 25); + tmpx->dgst[26] = pbkdf2_sha256_packv (tmps, dgst, 26); + tmpx->dgst[27] = pbkdf2_sha256_packv (tmps, dgst, 27); + tmpx->dgst[28] = pbkdf2_sha256_packv (tmps, dgst, 28); + tmpx->dgst[29] = pbkdf2_sha256_packv (tmps, dgst, 29); + tmpx->dgst[30] = pbkdf2_sha256_packv (tmps, dgst, 30); + tmpx->dgst[31] = pbkdf2_sha256_packv (tmps, dgst, 31); + + tmpx->out[0] = pbkdf2_sha256_packv (tmps, out, 0); + tmpx->out[1] = pbkdf2_sha256_packv (tmps, out, 1); + tmpx->out[2] = pbkdf2_sha256_packv (tmps, out, 2); + tmpx->out[3] = pbkdf2_sha256_packv (tmps, out, 3); + tmpx->out[4] = pbkdf2_sha256_packv (tmps, out, 4); + tmpx->out[5] = pbkdf2_sha256_packv (tmps, out, 5); + tmpx->out[6] = pbkdf2_sha256_packv (tmps, out, 6); + tmpx->out[7] = pbkdf2_sha256_packv (tmps, out, 7); + tmpx->out[8] = pbkdf2_sha256_packv (tmps, out, 8); + tmpx->out[9] = pbkdf2_sha256_packv (tmps, out, 9); + tmpx->out[10] = pbkdf2_sha256_packv (tmps, out, 10); + tmpx->out[11] = pbkdf2_sha256_packv (tmps, out, 11); + tmpx->out[12] = pbkdf2_sha256_packv (tmps, out, 12); + tmpx->out[13] = pbkdf2_sha256_packv (tmps, out, 13); + tmpx->out[14] = pbkdf2_sha256_packv (tmps, out, 14); + tmpx->out[15] = pbkdf2_sha256_packv (tmps, out, 15); + tmpx->out[16] = pbkdf2_sha256_packv (tmps, out, 16); + tmpx->out[17] = pbkdf2_sha256_packv (tmps, out, 17); + tmpx->out[18] = pbkdf2_sha256_packv (tmps, out, 18); + tmpx->out[19] = pbkdf2_sha256_packv (tmps, out, 19); + tmpx->out[20] = pbkdf2_sha256_packv (tmps, out, 20); + tmpx->out[21] = pbkdf2_sha256_packv (tmps, out, 21); + tmpx->out[22] = pbkdf2_sha256_packv (tmps, out, 22); + tmpx->out[23] = pbkdf2_sha256_packv (tmps, out, 23); + tmpx->out[24] = pbkdf2_sha256_packv (tmps, out, 24); + tmpx->out[25] = pbkdf2_sha256_packv (tmps, out, 25); + tmpx->out[26] = pbkdf2_sha256_packv (tmps, out, 26); + tmpx->out[27] = pbkdf2_sha256_packv (tmps, out, 27); + tmpx->out[28] = pbkdf2_sha256_packv (tmps, out, 28); + tmpx->out[29] = pbkdf2_sha256_packv (tmps, out, 29); + tmpx->out[30] = pbkdf2_sha256_packv (tmps, out, 30); + tmpx->out[31] = pbkdf2_sha256_packv (tmps, out, 31); +} + +DECLSPEC void transform_racf_key (const u32 w0, const u32 w1, PRIVATE_AS u32 *key) +{ + key[0] = c_ascii_to_ebcdic_pc[((w0 >> 0) & 0xff)] << 0 + | c_ascii_to_ebcdic_pc[((w0 >> 8) & 0xff)] << 8 + | c_ascii_to_ebcdic_pc[((w0 >> 16) & 0xff)] << 16 + | c_ascii_to_ebcdic_pc[((w0 >> 24) & 0xff)] << 24; + + key[1] = c_ascii_to_ebcdic_pc[((w1 >> 0) & 0xff)] << 0 + | c_ascii_to_ebcdic_pc[((w1 >> 8) & 0xff)] << 8 + | c_ascii_to_ebcdic_pc[((w1 >> 16) & 0xff)] << 16 + | c_ascii_to_ebcdic_pc[((w1 >> 24) & 0xff)] << 24; +} + +KERNEL_FQ void m34000_init (KERN_ATTR_TMPS_ESALT (racf_kdfaes_tmp_t, racf_kdfaes_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * DES shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_SPtrans[8][64]; + LOCAL_VK u32 s_skb[8][64]; + + for (u32 i = lid; i < 64; i += lsz) + { + s_SPtrans[0][i] = c_SPtrans[0][i]; + s_SPtrans[1][i] = c_SPtrans[1][i]; + s_SPtrans[2][i] = c_SPtrans[2][i]; + s_SPtrans[3][i] = c_SPtrans[3][i]; + s_SPtrans[4][i] = c_SPtrans[4][i]; + s_SPtrans[5][i] = c_SPtrans[5][i]; + s_SPtrans[6][i] = c_SPtrans[6][i]; + s_SPtrans[7][i] = c_SPtrans[7][i]; + + s_skb[0][i] = c_skb[0][i]; + s_skb[1][i] = c_skb[1][i]; + s_skb[2][i] = c_skb[2][i]; + s_skb[3][i] = c_skb[3][i]; + s_skb[4][i] = c_skb[4][i]; + s_skb[5][i] = c_skb[5][i]; + s_skb[6][i] = c_skb[6][i]; + s_skb[7][i] = c_skb[7][i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + + if (gid >= GID_CNT) return; + + // DES + u32 key[2]; + + transform_racf_key (pws[gid].i[ 0], pws[gid].i[ 1], key); + + u32 Kc[16]; + u32 Kd[16]; + + _des_crypt_keysetup (key[0], key[1], Kc, Kd, s_skb); + + u32 data[2]; + + data[0] = salt_bufs[SALT_POS_HOST].salt_buf_pc[0]; + data[1] = salt_bufs[SALT_POS_HOST].salt_buf_pc[1]; + + u32 des_output[2]; + _des_crypt_encrypt (des_output, data, Kc, Kd, s_SPtrans); + + // set tmps->key + tmps[gid].key[0] = hc_swap32_S(des_output[0]); + tmps[gid].key[1] = hc_swap32_S(des_output[1]); + tmps[gid].key[2] = 0; + tmps[gid].key[3] = 0; + tmps[gid].key[4] = 0; + tmps[gid].key[5] = 0; + tmps[gid].key[6] = 0; + tmps[gid].key[7] = 0; + + // set tmps->salt_buf + tmps[gid].salt_buf[0] = hc_swap32_S(esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[0]); + tmps[gid].salt_buf[1] = hc_swap32_S(esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[1]); + tmps[gid].salt_buf[2] = hc_swap32_S(esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[2]); + tmps[gid].salt_buf[3] = hc_swap32_S(esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[3]); + tmps[gid].salt_buf[4] = esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac; // todo: WHY? just set 0. Need to try + tmps[gid].salt_buf[5] = 0; + tmps[gid].salt_buf[6] = 0; + tmps[gid].salt_buf[7] = 0; + tmps[gid].salt_buf[8] = 0; + tmps[gid].salt_buf[9] = 0; + tmps[gid].salt_buf[10] = 0; + tmps[gid].salt_buf[11] = 0; + tmps[gid].salt_buf[12] = 0; + tmps[gid].salt_buf[13] = 0; + tmps[gid].salt_buf[14] = 0; + tmps[gid].salt_buf[15] = 0; + tmps[gid].salt_len = 20; + + tmps[gid].out_len = 0; + +} + +DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); +} + + +DECLSPEC void racf_pbkdf_sha256_hmac_V(u32x *key, u32 key_len, u32x *salt, u32 salt_len, u32 iteration, pbkdf2_sha256_tmpx_t* tmpx) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + /** + * PBKDF2-SHA256-HMAC init + */ + + sha256_hmac_ctx_vector_t sha256_hmac_ctx; + + sha256_hmac_init_vector (&sha256_hmac_ctx, key, key_len); + + tmpx->ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmpx->ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmpx->ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmpx->ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmpx->ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmpx->ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmpx->ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmpx->ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmpx->opad[0] = sha256_hmac_ctx.opad.h[0]; + tmpx->opad[1] = sha256_hmac_ctx.opad.h[1]; + tmpx->opad[2] = sha256_hmac_ctx.opad.h[2]; + tmpx->opad[3] = sha256_hmac_ctx.opad.h[3]; + tmpx->opad[4] = sha256_hmac_ctx.opad.h[4]; + tmpx->opad[5] = sha256_hmac_ctx.opad.h[5]; + tmpx->opad[6] = sha256_hmac_ctx.opad.h[6]; + tmpx->opad[7] = sha256_hmac_ctx.opad.h[7]; + + sha256_hmac_update_vector (&sha256_hmac_ctx, salt, salt_len); + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = 1; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_vector_64 (&sha256_hmac_ctx, w0, w1, w2, w3, 4); + + sha256_hmac_final_vector (&sha256_hmac_ctx); + + tmpx->dgst[0] = sha256_hmac_ctx.opad.h[0]; + tmpx->dgst[1] = sha256_hmac_ctx.opad.h[1]; + tmpx->dgst[2] = sha256_hmac_ctx.opad.h[2]; + tmpx->dgst[3] = sha256_hmac_ctx.opad.h[3]; + tmpx->dgst[4] = sha256_hmac_ctx.opad.h[4]; + tmpx->dgst[5] = sha256_hmac_ctx.opad.h[5]; + tmpx->dgst[6] = sha256_hmac_ctx.opad.h[6]; + tmpx->dgst[7] = sha256_hmac_ctx.opad.h[7]; + + tmpx->out[0] = tmpx->dgst[0]; + tmpx->out[1] = tmpx->dgst[1]; + tmpx->out[2] = tmpx->dgst[2]; + tmpx->out[3] = tmpx->dgst[3]; + tmpx->out[4] = tmpx->dgst[4]; + tmpx->out[5] = tmpx->dgst[5]; + tmpx->out[6] = tmpx->dgst[6]; + tmpx->out[7] = tmpx->dgst[7]; + + /** + * PBKDF2-SHA256-HMAC loop + */ + + // convert tmpx to array sha256_tmps[VECT_SIZE] + + pbkdf2_sha256_tmp_t sha256_tmps[VECT_SIZE] = {0}; + convert_pbkdf2_sha256_from_V(tmpx, sha256_tmps); + + // main loop for PBKDF2-SHA256-HMAC + + u32x ipad[8]; + u32x opad[8]; + u32x dgst[8]; + u32x out[8]; + u32x last_dgst[8] = {0}; + + // extract data from sha256_tmps: ipad, opad, dgst, out + ipad[0] = packv (sha256_tmps, ipad, 0, 0); + ipad[1] = packv (sha256_tmps, ipad, 0, 1); + ipad[2] = packv (sha256_tmps, ipad, 0, 2); + ipad[3] = packv (sha256_tmps, ipad, 0, 3); + ipad[4] = packv (sha256_tmps, ipad, 0, 4); + ipad[5] = packv (sha256_tmps, ipad, 0, 5); + ipad[6] = packv (sha256_tmps, ipad, 0, 6); + ipad[7] = packv (sha256_tmps, ipad, 0, 7); + + opad[0] = packv (sha256_tmps, opad, 0, 0); + opad[1] = packv (sha256_tmps, opad, 0, 1); + opad[2] = packv (sha256_tmps, opad, 0, 2); + opad[3] = packv (sha256_tmps, opad, 0, 3); + opad[4] = packv (sha256_tmps, opad, 0, 4); + opad[5] = packv (sha256_tmps, opad, 0, 5); + opad[6] = packv (sha256_tmps, opad, 0, 6); + opad[7] = packv (sha256_tmps, opad, 0, 7); + + dgst[0] = packv (sha256_tmps, dgst, 0, 0); + dgst[1] = packv (sha256_tmps, dgst, 0, 1); + dgst[2] = packv (sha256_tmps, dgst, 0, 2); + dgst[3] = packv (sha256_tmps, dgst, 0, 3); + dgst[4] = packv (sha256_tmps, dgst, 0, 4); + dgst[5] = packv (sha256_tmps, dgst, 0, 5); + dgst[6] = packv (sha256_tmps, dgst, 0, 6); + dgst[7] = packv (sha256_tmps, dgst, 0, 7); + + out[0] = packv (sha256_tmps, out, 0, 0); + out[1] = packv (sha256_tmps, out, 0, 1); + out[2] = packv (sha256_tmps, out, 0, 2); + out[3] = packv (sha256_tmps, out, 0, 3); + out[4] = packv (sha256_tmps, out, 0, 4); + out[5] = packv (sha256_tmps, out, 0, 5); + out[6] = packv (sha256_tmps, out, 0, 6); + out[7] = packv (sha256_tmps, out, 0, 7); + + // PBKDF2-SHA256-HMAC iterations + for (u32 i = 0; i < iteration - 1; i += 1) + { + // save digest of pre-last iteration + if (i + 1 == iteration - 1) { + last_dgst[0] = dgst[0]; + last_dgst[1] = dgst[1]; + last_dgst[2] = dgst[2]; + last_dgst[3] = dgst[3]; + last_dgst[4] = dgst[4]; + last_dgst[5] = dgst[5]; + last_dgst[6] = dgst[6]; + last_dgst[7] = dgst[7]; + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + // save data (last_dgst, out) into sha256_tmps + unpackv (sha256_tmps, dgst, 0, 0, last_dgst[0]); + unpackv (sha256_tmps, dgst, 0, 1, last_dgst[1]); + unpackv (sha256_tmps, dgst, 0, 2, last_dgst[2]); + unpackv (sha256_tmps, dgst, 0, 3, last_dgst[3]); + unpackv (sha256_tmps, dgst, 0, 4, last_dgst[4]); + unpackv (sha256_tmps, dgst, 0, 5, last_dgst[5]); + unpackv (sha256_tmps, dgst, 0, 6, last_dgst[6]); + unpackv (sha256_tmps, dgst, 0, 7, last_dgst[7]); + + unpackv (sha256_tmps, out, 0, 0, out[0]); + unpackv (sha256_tmps, out, 0, 1, out[1]); + unpackv (sha256_tmps, out, 0, 2, out[2]); + unpackv (sha256_tmps, out, 0, 3, out[3]); + unpackv (sha256_tmps, out, 0, 4, out[4]); + unpackv (sha256_tmps, out, 0, 5, out[5]); + unpackv (sha256_tmps, out, 0, 6, out[6]); + unpackv (sha256_tmps, out, 0, 7, out[7]); + + // convert sha256_tmps[VECT_SIZE] to tmpx + convert_pbkdf2_sha256_to_V(sha256_tmps, tmpx); +} + +KERNEL_FQ void m34000_loop (KERN_ATTR_TMPS_ESALT (racf_kdfaes_tmp_t, racf_kdfaes_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + /* + * set key and salt + */ + + u32x key[16] = {0}; + u32x salt[16] = {0}; + u32 salt_len = tmps[gid].salt_len; + + key[0] = packv (tmps, key, gid, 0); + key[1] = packv (tmps, key, gid, 1); + + salt[0] = packv (tmps, salt_buf, gid, 0); + salt[1] = packv (tmps, salt_buf, gid, 1); + salt[2] = packv (tmps, salt_buf, gid, 2); + salt[3] = packv (tmps, salt_buf, gid, 3); + salt[4] = packv (tmps, salt_buf, gid, 4); + salt[5] = packv (tmps, salt_buf, gid, 5); + salt[6] = packv (tmps, salt_buf, gid, 6); + salt[7] = packv (tmps, salt_buf, gid, 7); + salt[8] = packv (tmps, salt_buf, gid, 8); + salt[9] = packv (tmps, salt_buf, gid, 9); + salt[10] = packv (tmps, salt_buf, gid, 10); + salt[11] = packv (tmps, salt_buf, gid, 11); + + pbkdf2_sha256_tmpx_t pbkdf2_tmpx = {0}; + + /* + * internal loop with PBKDF2-SHA256-HMAC + */ + + for (u32 i = 0; i < LOOP_CNT; i += 1) + { + racf_pbkdf_sha256_hmac_V(key, 8, salt, salt_len, esalt_bufs[DIGESTS_OFFSET_HOST].rep_fac * 100, &pbkdf2_tmpx); + + salt[0] = pbkdf2_tmpx.dgst[0]; + salt[1] = pbkdf2_tmpx.dgst[1]; + salt[2] = pbkdf2_tmpx.dgst[2]; + salt[3] = pbkdf2_tmpx.dgst[3]; + salt[4] = pbkdf2_tmpx.out[0]; + salt[5] = pbkdf2_tmpx.out[1]; + salt[6] = pbkdf2_tmpx.out[2]; + salt[7] = pbkdf2_tmpx.out[3]; + salt[8] = pbkdf2_tmpx.out[4]; + salt[9] = pbkdf2_tmpx.out[5]; + salt[10] = pbkdf2_tmpx.out[6]; + salt[11] = pbkdf2_tmpx.out[7]; + salt_len = 48; + + // fill mem_fact buffer (tmps->out) + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+0, pbkdf2_tmpx.out[0]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+1, pbkdf2_tmpx.out[1]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+2, pbkdf2_tmpx.out[2]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+3, pbkdf2_tmpx.out[3]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+4, pbkdf2_tmpx.out[4]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+5, pbkdf2_tmpx.out[5]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+6, pbkdf2_tmpx.out[6]); + unpackv (tmps, out, gid, 8*LOOP_POS+8*i+7, pbkdf2_tmpx.out[7]); + + } + + /* + * set salt_buf for the next mem_fact iteration + */ + + unpackv (tmps, salt_buf, gid, 0, pbkdf2_tmpx.dgst[0]); + unpackv (tmps, salt_buf, gid, 1, pbkdf2_tmpx.dgst[1]); + unpackv (tmps, salt_buf, gid, 2, pbkdf2_tmpx.dgst[2]); + unpackv (tmps, salt_buf, gid, 3, pbkdf2_tmpx.dgst[3]); + + unpackv (tmps, salt_buf, gid, 4, pbkdf2_tmpx.out[0]); + unpackv (tmps, salt_buf, gid, 5, pbkdf2_tmpx.out[1]); + unpackv (tmps, salt_buf, gid, 6, pbkdf2_tmpx.out[2]); + unpackv (tmps, salt_buf, gid, 7, pbkdf2_tmpx.out[3]); + unpackv (tmps, salt_buf, gid, 8, pbkdf2_tmpx.out[4]); + unpackv (tmps, salt_buf, gid, 9, pbkdf2_tmpx.out[5]); + unpackv (tmps, salt_buf, gid, 10, pbkdf2_tmpx.out[6]); + unpackv (tmps, salt_buf, gid, 11, pbkdf2_tmpx.out[7]); + + u32x salt_len_x = 48; + unpack (tmps, salt_len, gid, salt_len_x); +} + + +KERNEL_FQ void m34000_init2 (KERN_ATTR_TMPS_ESALT (racf_kdfaes_tmp_t, racf_kdfaes_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + /** + * memory buffer preparation (transposition + PBKDF2-SHA256-HMAC with iter=1) + */ + + // set key + tmps[gid].key[0] = tmps[gid].salt_buf[4]; + tmps[gid].key[1] = tmps[gid].salt_buf[5]; + tmps[gid].key[2] = tmps[gid].salt_buf[6]; + tmps[gid].key[3] = tmps[gid].salt_buf[7]; + tmps[gid].key[4] = tmps[gid].salt_buf[8]; + tmps[gid].key[5] = tmps[gid].salt_buf[9]; + tmps[gid].key[6] = tmps[gid].salt_buf[10]; + tmps[gid].key[7] = tmps[gid].salt_buf[11]; + + // zero filling salt_buf (only the first 8 bytes are needed) + tmps[gid].salt_buf[8] = 0; + tmps[gid].salt_buf[9] = 0; + tmps[gid].salt_buf[10] = 0; + tmps[gid].salt_buf[11] = 0; + + // PBKDF2-SHA256-HMAC with iter=1 for each 32-byte block in memory buffer + for (u32 i = 0; i < esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac; i += 1) + { + u32 n_key = tmps[gid].key[7] & (esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1); + + // set salt from memory buffer with offset n_key + tmps[gid].salt_buf[0] = tmps[gid].out[n_key*8+0]; + tmps[gid].salt_buf[1] = tmps[gid].out[n_key*8+1]; + tmps[gid].salt_buf[2] = tmps[gid].out[n_key*8+2]; + tmps[gid].salt_buf[3] = tmps[gid].out[n_key*8+3]; + tmps[gid].salt_buf[4] = tmps[gid].out[n_key*8+4]; + tmps[gid].salt_buf[5] = tmps[gid].out[n_key*8+5]; + tmps[gid].salt_buf[6] = tmps[gid].out[n_key*8+6]; + tmps[gid].salt_buf[7] = tmps[gid].out[n_key*8+7]; + + // do PBKDF2-SHA256-HMAC + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global (&sha256_hmac_ctx, tmps[gid].key, 32); + + sha256_hmac_update_global (&sha256_hmac_ctx, tmps[gid].salt_buf, 32); + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = 1; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx); + + // save digest to out buf + tmps[gid].out[i*8+0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].out[i*8+1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].out[i*8+2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].out[i*8+3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].out[i*8+4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].out[i*8+5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].out[i*8+6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].out[i*8+7] = sha256_hmac_ctx.opad.h[7]; + + // set key for next iteration + tmps[gid].key[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].key[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].key[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].key[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].key[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].key[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].key[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].key[7] = sha256_hmac_ctx.opad.h[7]; + } + + /** + * PBKDF2-SHA256-HMAC init + */ + + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global (&sha256_hmac_ctx, tmps[gid].key, 32); + + // set ipad and opad + tmps[gid].pbkdf2_tmps.ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmps[gid].pbkdf2_tmps.ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmps[gid].pbkdf2_tmps.ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmps[gid].pbkdf2_tmps.ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmps[gid].pbkdf2_tmps.ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmps[gid].pbkdf2_tmps.ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmps[gid].pbkdf2_tmps.ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmps[gid].pbkdf2_tmps.ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmps[gid].pbkdf2_tmps.opad[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].pbkdf2_tmps.opad[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].pbkdf2_tmps.opad[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].pbkdf2_tmps.opad[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].pbkdf2_tmps.opad[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].pbkdf2_tmps.opad[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].pbkdf2_tmps.opad[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].pbkdf2_tmps.opad[7] = sha256_hmac_ctx.opad.h[7]; + + // zero filling last 32-byte buf in tmps[gid].out. It's used as a key + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+0] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+1] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+2] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+3] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+4] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+5] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+6] = 0; + tmps[gid].out[8*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)+7] = 0; + + sha256_hmac_update_global (&sha256_hmac_ctx, tmps[gid].out, 32*(esalt_bufs[DIGESTS_OFFSET_HOST].mem_fac - 1)); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx2); + + tmps[gid].pbkdf2_tmps.dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; + tmps[gid].pbkdf2_tmps.dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; + tmps[gid].pbkdf2_tmps.dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; + tmps[gid].pbkdf2_tmps.dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; + tmps[gid].pbkdf2_tmps.dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; + tmps[gid].pbkdf2_tmps.dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; + tmps[gid].pbkdf2_tmps.dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; + tmps[gid].pbkdf2_tmps.dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; + + tmps[gid].pbkdf2_tmps.out[i + 0] = tmps[gid].pbkdf2_tmps.dgst[i + 0]; + tmps[gid].pbkdf2_tmps.out[i + 1] = tmps[gid].pbkdf2_tmps.dgst[i + 1]; + tmps[gid].pbkdf2_tmps.out[i + 2] = tmps[gid].pbkdf2_tmps.dgst[i + 2]; + tmps[gid].pbkdf2_tmps.out[i + 3] = tmps[gid].pbkdf2_tmps.dgst[i + 3]; + tmps[gid].pbkdf2_tmps.out[i + 4] = tmps[gid].pbkdf2_tmps.dgst[i + 4]; + tmps[gid].pbkdf2_tmps.out[i + 5] = tmps[gid].pbkdf2_tmps.dgst[i + 5]; + tmps[gid].pbkdf2_tmps.out[i + 6] = tmps[gid].pbkdf2_tmps.dgst[i + 6]; + tmps[gid].pbkdf2_tmps.out[i + 7] = tmps[gid].pbkdf2_tmps.dgst[i + 7]; + } + +} + + +KERNEL_FQ void m34000_loop2 (KERN_ATTR_TMPS_ESALT (racf_kdfaes_tmp_t, racf_kdfaes_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + u32x ipad[8]; + u32x opad[8]; + + ipad[0] = packv (tmps, pbkdf2_tmps.ipad, gid, 0); + ipad[1] = packv (tmps, pbkdf2_tmps.ipad, gid, 1); + ipad[2] = packv (tmps, pbkdf2_tmps.ipad, gid, 2); + ipad[3] = packv (tmps, pbkdf2_tmps.ipad, gid, 3); + ipad[4] = packv (tmps, pbkdf2_tmps.ipad, gid, 4); + ipad[5] = packv (tmps, pbkdf2_tmps.ipad, gid, 5); + ipad[6] = packv (tmps, pbkdf2_tmps.ipad, gid, 6); + ipad[7] = packv (tmps, pbkdf2_tmps.ipad, gid, 7); + + opad[0] = packv (tmps, pbkdf2_tmps.opad, gid, 0); + opad[1] = packv (tmps, pbkdf2_tmps.opad, gid, 1); + opad[2] = packv (tmps, pbkdf2_tmps.opad, gid, 2); + opad[3] = packv (tmps, pbkdf2_tmps.opad, gid, 3); + opad[4] = packv (tmps, pbkdf2_tmps.opad, gid, 4); + opad[5] = packv (tmps, pbkdf2_tmps.opad, gid, 5); + opad[6] = packv (tmps, pbkdf2_tmps.opad, gid, 6); + opad[7] = packv (tmps, pbkdf2_tmps.opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + u32x out[8]; + + dgst[0] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 0); + dgst[1] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 1); + dgst[2] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 2); + dgst[3] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 3); + dgst[4] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 4); + dgst[5] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 5); + dgst[6] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 6); + dgst[7] = packv (tmps, pbkdf2_tmps.dgst, gid, i + 7); + + out[0] = packv (tmps, pbkdf2_tmps.out, gid, i + 0); + out[1] = packv (tmps, pbkdf2_tmps.out, gid, i + 1); + out[2] = packv (tmps, pbkdf2_tmps.out, gid, i + 2); + out[3] = packv (tmps, pbkdf2_tmps.out, gid, i + 3); + out[4] = packv (tmps, pbkdf2_tmps.out, gid, i + 4); + out[5] = packv (tmps, pbkdf2_tmps.out, gid, i + 5); + out[6] = packv (tmps, pbkdf2_tmps.out, gid, i + 6); + out[7] = packv (tmps, pbkdf2_tmps.out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 0, dgst[0]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 1, dgst[1]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 2, dgst[2]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 3, dgst[3]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 4, dgst[4]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 5, dgst[5]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 6, dgst[6]); + unpackv (tmps, pbkdf2_tmps.dgst, gid, i + 7, dgst[7]); + + unpackv (tmps, pbkdf2_tmps.out, gid, i + 0, out[0]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 1, out[1]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 2, out[2]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 3, out[3]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 4, out[4]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 5, out[5]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 6, out[6]); + unpackv (tmps, pbkdf2_tmps.out, gid, i + 7, out[7]); + } + +} + +KERNEL_FQ void m34000_comp (KERN_ATTR_TMPS_ESALT (racf_kdfaes_tmp_t, racf_kdfaes_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * AES shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + // prepare key and plain text + u32 aes_key[8] = {0}; + + // AES key is output from PBKDB2-SHA256-HMAC (loop2) + aes_key[0] = tmps[gid].pbkdf2_tmps.out[0]; + aes_key[1] = tmps[gid].pbkdf2_tmps.out[1]; + aes_key[2] = tmps[gid].pbkdf2_tmps.out[2]; + aes_key[3] = tmps[gid].pbkdf2_tmps.out[3]; + aes_key[4] = tmps[gid].pbkdf2_tmps.out[4]; + aes_key[5] = tmps[gid].pbkdf2_tmps.out[5]; + aes_key[6] = tmps[gid].pbkdf2_tmps.out[6]; + aes_key[7] = tmps[gid].pbkdf2_tmps.out[7]; + + // Plain text is encoded username + u32 plain_text[4] = {0}; + plain_text[0] = salt_bufs[SALT_POS_HOST].salt_buf_pc[0]; + plain_text[1] = salt_bufs[SALT_POS_HOST].salt_buf_pc[1]; + plain_text[2] = salt_bufs[SALT_POS_HOST].salt_buf_pc[2]; + plain_text[3] = salt_bufs[SALT_POS_HOST].salt_buf_pc[3]; + + u32 cipher_text[4] = {0}; + + // AES + u32 aes_ks[60]; + + AES256_set_encrypt_key (aes_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + aes256_encrypt (aes_ks, plain_text, cipher_text, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32 r0 = cipher_text[DGST_R0]; + const u32 r1 = cipher_text[DGST_R1]; + const u32 r2 = cipher_text[DGST_R2]; + const u32 r3 = cipher_text[DGST_R3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} + + diff --git a/src/modules/module_34000.c b/src/modules/module_34000.c new file mode 100644 index 000000000..7ff722fd9 --- /dev/null +++ b/src/modules/module_34000.c @@ -0,0 +1,378 @@ +/** + * Author......: 0xc0rs + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_cipher_des.h" + + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; +static const char *HASH_NAME = "RACF KDFAES"; +static const u64 KERN_TYPE = 34000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_ST_UPPER + | OPTS_TYPE_HASH_COPY + | OPTS_TYPE_INIT2 + | OPTS_TYPE_LOOP2; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$racf-kdfaes$*USER*E7D7E66D000180000008003200100010*00112233445566778899AABBCCDDEEFF*5390653DEC0316FB5AD56053208056A6"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_tmpx +{ + u32x ipad[8]; + u32x opad[8]; + + u32x dgst[32]; + u32x out[32]; + +} pbkdf2_sha256_tmpx_t; + +typedef struct racf_kdfaes_tmp +{ + u32 key[16]; + u32 salt_buf[16]; + u32 salt_len; + + u32 out[256]; // change for mem_fact > 10 + u32 out_len; + + pbkdf2_sha256_tmp_t pbkdf2_tmp; +} racf_kdfaes_tmp_t; + +typedef struct racf_kdfaes +{ + u32 salt_buf[64]; + u32 mem_fac; + u32 rep_fac; + +} racf_kdfaes_t; + +static const char *SIGNATURE_RACF_KDFAES = "$racf-kdfaes$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (racf_kdfaes_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (racf_kdfaes_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = 8; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + const u8 ascii_to_ebcdic[] = + { + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, + 0x40, 0x4f, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, + 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, + 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0x4a, 0xe0, 0x5a, 0x5f, 0x6d, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x6a, 0xd0, 0xa1, 0x07, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b, + 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, + 0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb, + 0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + }; + + u32 *digest = (u32 *) digest_buf; + racf_kdfaes_t *racf_kdfaes = (racf_kdfaes_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 5; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_RACF_KDFAES; + + token.sep[0] = '*'; + token.len[0] = 13; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 0; + token.len_max[1] = 8; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '*'; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '*'; + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + u8 tmp_buf[512]; + int tmp_len; + + // username (save to salt->salt_buf_pc) + + const u8 *username_pos = token.buf[1]; + const int username_len = token.len[1]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + for (int i = 0; i < username_len; i++) + { + tmp_buf[i] = ascii_to_ebcdic[(int) username_pos[i]]; + } + for (int i = username_len; i < token.len_max[1]; i++) + { + tmp_buf[i] = 0x40; + } + + memcpy (salt->salt_buf_pc, tmp_buf, token.len_max[1]); + + + // header (save to racf_kdfaes->mem_fac and racf_kdfaes->rep_fac) + + const u8 *header_pos = token.buf[2]; + u32 mem_fac = 0, rep_fac = 0; + + mem_fac |= ((u32) hex_convert (header_pos[16+1]) << 8); + mem_fac |= ((u32) hex_convert (header_pos[16+0]) << 12); + mem_fac |= ((u32) hex_convert (header_pos[16+3]) << 0); + mem_fac |= ((u32) hex_convert (header_pos[16+2]) << 4); + rep_fac |= ((u32) hex_convert (header_pos[20+1]) << 8); + rep_fac |= ((u32) hex_convert (header_pos[20+0]) << 12); + rep_fac |= ((u32) hex_convert (header_pos[20+3]) << 0); + rep_fac |= ((u32) hex_convert (header_pos[20+2]) << 4); + + /** + * racf_kdfaes->mem_fac defines a size of memory buffer (racf_kdfaes_tmp->out): size = 8 * racf_kdfaes->mem_fac + * mem_fac = 8 => racf_kdfaes->mem_fac = 8 => u32 out[64] + * mem_fac = 9 => racf_kdfaes->mem_fac = 16 => u32 out[128] + * mem_fac = 10 => racf_kdfaes->mem_fac = 32 => u32 out[256] + * mem_fac = 11 => racf_kdfaes->mem_fac = 64 => u32 out[512] + * mem_fac = 12 => racf_kdfaes->mem_fac = 128 => u32 out[1024] + * due to the significant increase in bruteforce time with a high mem_fac the module is developed only for a mem_fac <= 10 + * If it's necessary to brute hash with mem_fac > 10 (not default option) then increase size for racf_kdfaes_tmp->out buffer + */ + racf_kdfaes->mem_fac = (2 << (mem_fac - 1)) / 32; + /** + * racf_kdfaes->rep_fac defines a number of iteration in PBKDF2-SHA256-HMAC + */ + racf_kdfaes->rep_fac = rep_fac; + + // salt (save to racf_kdfaes->salt_buf and salt->salt_buf) + + const u8 *salt_pos = token.buf[3]; + const int salt_len = token.len[3]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = hex_decode(salt_pos, salt_len, tmp_buf); + + + if (tmp_len != 16) return (PARSER_SALT_LENGTH); + + memcpy (racf_kdfaes->salt_buf, tmp_buf, tmp_len); + memcpy (salt->salt_buf, tmp_buf, tmp_len); + salt->salt_len = tmp_len; + + salt->salt_iter = racf_kdfaes->mem_fac; + salt->salt_iter2 = rep_fac*100 - 1; + + // hash + + const u8 *hash_pos = token.buf[4]; + const int hash_len = token.len[4]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = hex_decode(hash_pos, hash_len, tmp_buf); + + if (tmp_len != 16) return (PARSER_HASH_LENGTH); + + memcpy (digest, tmp_buf, 16); + return (PARSER_OK); + +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + return snprintf (line_buf, line_size, "%s", hash_info->orighash); +} + + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} \ No newline at end of file diff --git a/tools/test_modules/m34000.pm b/tools/test_modules/m34000.pm new file mode 100644 index 000000000..84ac3cc39 --- /dev/null +++ b/tools/test_modules/m34000.pm @@ -0,0 +1,175 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Convert::EBCDIC qw (ascii2ebcdic); +use Digest::HMAC qw (hmac); +use Digest::SHA qw(hmac_sha256); +use Crypt::PBKDF2; +use Crypt::DES; +use Crypt::Rijndael; + +sub module_constraints { [[0, 8], [1, 8], [-1, -1], [-1, -1], [-1, -1]] } + +sub prepare_hmac_key +{ + my ($username, $password) = @_; + + $username = substr ($username . " " x 8, 0, 8); + $password = substr ($password . " " x 8, 0, 8); + + my $username_ebc = ascii2ebcdic ($username); + my $password_ebc = ascii2ebcdic ($password); + + my @pw = split ("", $password_ebc); # split by char + + for (my $i = 0; $i < 8; $i++) + { + $pw[$i] = unpack ("C", $pw[$i]); + $pw[$i] ^= 0x55; + $pw[$i] <<= 1; + $pw[$i] = pack ("C", $pw[$i] & 0xff); + } + + my $key = join ("", @pw); + + my $cipher = new Crypt::DES $key; + + my $ciphertext = $cipher->encrypt ($username_ebc); + + return $ciphertext; +} + +sub prepare_aes_key +{ + my $mem_fac = (2 << (shift() - 1)) / 32; + my $rep_fac = shift; + my $hmac_key = shift; + my $data_hex = shift; + + my $msg = pack ("H32", $data_hex) . pack('N', $mem_fac) . pack('N', 1); + my $mem_buf = ""; + + # step 1: proprietary PBKDF2-HMAC-SHA256 (prepare $mem_buf) + + for my $n (0 .. $mem_fac - 1) { + + my $u_current = hmac_sha256($msg, $hmac_key); + my $f_res = $u_current; + my $h_prev = $u_current; + + # recalc hmac + for my $i (0 .. $rep_fac * 100 - 2) { + $h_prev = $u_current; + $u_current = hmac_sha256($u_current, $hmac_key); + my $f_res_tmp = ''; + for my $j (0 .. length($f_res) - 1) { + $f_res_tmp .= chr(ord(substr($f_res, $j, 1)) ^ ord(substr($u_current, $j, 1))); + } + $f_res = $f_res_tmp; + } + + $msg = substr ($h_prev, 0, 16) . $f_res . pack('N', 1); + $mem_buf .= $f_res + } + + + # step 2: mem_buf substitutions + + # Set new HMAC key (last block from mem_buf) + my $mem_buf_len = length ($mem_buf); + $hmac_key = substr ($mem_buf, $mem_buf_len - 32, 32); + + # Substitutions + for my $n (0 .. $mem_fac - 1) { + my $n_key = unpack ('N', substr ($hmac_key, 28, 4) ) & ($mem_fac - 1); + my $mem_buf_blk = substr ($mem_buf, $n_key * 32, 32) . pack('N', 1); + + $mem_buf_blk = hmac_sha256($mem_buf_blk, $hmac_key); + $mem_buf = substr ($mem_buf, 0, $n * 32) . $mem_buf_blk . substr ($mem_buf, ($n+1) * 32, $mem_buf_len - ($n+1) * 32); + $hmac_key = $mem_buf_blk; + } + + # step 3: PBKDF2-HMAC-SHA256(mem_buf, hmac_key, rep_fac) + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256), + iterations => $rep_fac*100, + output_len => 32 + ); + $msg = substr ($mem_buf, 0, ($mem_fac-1) * 32); + my $aes_key = $pbkdf2->PBKDF2 ($msg, $hmac_key); + + return $aes_key; +} + +sub module_generate_hash +{ + my $word = shift; + my $username = shift; + + my $mem_fac = shift // 0x08; + my $rep_fac = shift // 0x32; + my $salt_data = shift // uc random_hex_string (32); + + my $hmac_key = prepare_hmac_key (uc $username, $word); + + my $aes_key = prepare_aes_key ($mem_fac, $rep_fac, $hmac_key, $salt_data); + + my $plaint = ascii2ebcdic (substr (uc $username . " " x 8, 0, 8)) . "\x00" x 8; + my $rijndael = Crypt::Rijndael->new($aes_key, Crypt::Rijndael::MODE_ECB()); + my $ciphertext = $rijndael->encrypt($plaint); + + my $hash = sprintf ('$racf-kdfaes$*%s*E7D7E66D00018000%04X%04X00100010*%s*%s', uc $username, $mem_fac, $rep_fac, uc $salt_data, uc unpack("H32", $ciphertext)); + + return $hash; +} + + +sub module_verify_hash +{ + my $line = shift; + + my @line_elements = split (":", $line); + + return if scalar @line_elements < 2; + + my $hash_in = shift @line_elements; + + my $word = join (":", @line_elements); + + # check signature + + my @hash_elements = split ('\*', $hash_in); + + return unless ($hash_elements[0] eq '$racf-kdfaes$'); + + my $username = $hash_elements[1]; + my $mem_fac = hex (substr ($hash_elements[2], 16, 4)); + my $rep_fac = hex (substr ($hash_elements[2], 20, 4)); + my $salt = $hash_elements[3]; + + return unless defined $word; + return unless defined $username; + return unless defined $mem_fac; + return unless defined $rep_fac; + return unless defined $salt; + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $username, $mem_fac, $rep_fac, $salt); + + return ($new_hash, $word); +} + +1; + + + From 29dfcee3b5ec3664e2b707b0565307d124d4299c Mon Sep 17 00:00:00 2001 From: c0rs <0xc0rs@gmail.com> Date: Tue, 30 Jan 2024 00:40:02 +0300 Subject: [PATCH 009/357] RACF KDFAES module - fix author --- src/modules/module_34000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module_34000.c b/src/modules/module_34000.c index 7ff722fd9..12bb46e54 100644 --- a/src/modules/module_34000.c +++ b/src/modules/module_34000.c @@ -1,5 +1,5 @@ /** - * Author......: 0xc0rs + * Author......: See docs/credits.txt * License.....: MIT */ From f2f2456cd7b67d0e899db24d3f4067275287b2e1 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 30 Jan 2024 02:57:01 +0000 Subject: [PATCH 010/357] Performance warning adjustment Be more forgiving before displaying a performance warning --- src/monitor.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/monitor.c b/src/monitor.c index ce02a7a90..946b93110 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -55,9 +55,10 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) bool restore_check = false; bool hwmon_check = false; bool performance_check = false; + bool performance_warned = false; const int sleep_time = 1; - const double exec_low = 50.0; // in ms + const double exec_low = 25.0; // in ms const double util_low = 90.0; // in percent if (user_options->runtime) @@ -245,7 +246,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) } } - if (performance_check == true) + if (performance_check == true && status_ctx->devices_status == STATUS_RUNNING && performance_warned == false) { int exec_cnt = 0; int util_cnt = 0; @@ -285,18 +286,22 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (exec_cnt > 0) exec_avg = exec_total / exec_cnt; if (util_cnt > 0) util_avg = util_total / util_cnt; - if ((exec_avg > 0) && (exec_avg < exec_low)) + if (((exec_avg > 0) && (exec_avg < exec_low)) || ((util_avg > 0) && (util_avg < util_low))) { performance_warnings++; - - if (performance_warnings == 10) EVENT_DATA (EVENT_MONITOR_PERFORMANCE_HINT, NULL, 0); + } + else + { + if (performance_warnings > 0) + { + performance_warnings--; + } } - if ((util_avg > 0) && (util_avg < util_low)) + if (performance_warnings == 10) { - performance_warnings++; - - if (performance_warnings == 10) EVENT_DATA (EVENT_MONITOR_PERFORMANCE_HINT, NULL, 0); + performance_warned = true; + EVENT_DATA (EVENT_MONITOR_PERFORMANCE_HINT, NULL, 0); } } From 08f6cf7e0af48cfb1ec01e42f0f072cf8455a63c Mon Sep 17 00:00:00 2001 From: Mayank Date: Thu, 8 Feb 2024 10:16:25 +0530 Subject: [PATCH 011/357] Updated HIP SDK detection to use ENV variable on Windows --- src/ext_hiprtc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/ext_hiprtc.c b/src/ext_hiprtc.c index ad7d14be9..8ca343147 100644 --- a/src/ext_hiprtc.c +++ b/src/ext_hiprtc.c @@ -11,6 +11,42 @@ #include "dynloader.h" + +char* hiprtcDllPath(char* hipSDKPath) +{ + /* + AMD HIP RTC DLLs is stored at "C:\Program Files\ROCm\X.Y\bin\hiprtc0X0Y.dll" + Tried using regex to simplify, but had compilation issues on mingw64 (linker + had troubles with pcre.h) + + This function can return complete dll path based on major release version + X.Y parsed from the ENV variable HIP_PATH. + */ + + // Identifying major release version X.Y + char* majorVersion = malloc(strlen("X.Y")+1); + memcpy(majorVersion, hipSDKPath + (strlen(hipSDKPath) - 4), 3); + memcpy(majorVersion+0x3, "\0", 1); + + // Preparing DLL name "hiprtc0X0Y.dll" + char* hiprtcDllName = malloc(strlen("hiprtcXXXX.dll")+1); + memcpy(hiprtcDllName, "hiprtc0", strlen("hiprtc0")); + + memcpy(hiprtcDllName + 0x7, majorVersion, 1); + memcpy(hiprtcDllName + 0x8, "0", 1); + memcpy(hiprtcDllName + 0x9, majorVersion + 2, 1); + memcpy(hiprtcDllName + 0xa, ".dll\0", 5); + + // Preparing complete path as "C:\Program Files\ROCm\X.Y\bin\hiprtc0X0Y.dll" to + // return to the caller. + char* hiprtcDllPath = malloc(strlen(hipSDKPath) + strlen("bin/") + strlen("hiprtcXXXX.dll") + 1); + strcpy(hiprtcDllPath, hipSDKPath); + strcat(hiprtcDllPath, "bin\\"); + strcat(hiprtcDllPath, hiprtcDllName); + return(hiprtcDllPath); +} + + int hiprtc_make_options_array_from_string (char *string, char **options) { char *saveptr = NULL; @@ -41,14 +77,23 @@ int hiprtc_init (void *hashcat_ctx) #if defined (_WIN) hiprtc->lib = hc_dlopen ("hiprtc.dll"); - if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll"); + // Check for HIP SDK installation from ENV + const char* hipSDKPath = getenv("HIP_PATH"); + if (hipSDKPath != NULL && hiprtc->lib == NULL) + { + hiprtc->lib = hc_dlopen (hiprtcDllPath(hipSDKPath)); + } if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll"); #elif defined (__APPLE__) hiprtc->lib = hc_dlopen ("fixme.dylib"); #elif defined (__CYGWIN__) hiprtc->lib = hc_dlopen ("hiprtc.dll"); - - if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll"); + // Check for HIP SDK installation from ENV + const char* hipSDKPath = getenv("HIP_PATH"); + if (hipSDKPath != NULL && hiprtc->lib == NULL) + { + hiprtc->lib = hc_dlopen (hiprtcDllPath(hipSDKPath)); + } if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll"); #else hiprtc->lib = hc_dlopen ("libhiprtc.so"); 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 012/357] 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 From bd538bb755decd61f9465c3c65dd873cdc12b146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Go=C5=82awski?= Date: Thu, 8 Feb 2024 15:39:58 +0100 Subject: [PATCH 013/357] Tool veracrypt2hashcat.py code cleanup --- OpenCL/m13711-pure.cl | 4 +++- OpenCL/m13712-pure.cl | 3 ++- OpenCL/m13713-pure.cl | 3 ++- OpenCL/m13721-pure.cl | 3 ++- OpenCL/m13722-pure.cl | 3 ++- OpenCL/m13723-pure.cl | 3 ++- OpenCL/m13731-pure.cl | 3 ++- OpenCL/m13732-pure.cl | 3 ++- OpenCL/m13733-pure.cl | 3 ++- OpenCL/m13751-pure.cl | 3 ++- OpenCL/m13752-pure.cl | 3 ++- OpenCL/m13753-pure.cl | 3 ++- OpenCL/m13771-pure.cl | 3 ++- OpenCL/m13772-pure.cl | 3 ++- OpenCL/m13773-pure.cl | 3 ++- tools/veracrypt2hashcat.py | 30 ++++++++++++++++++++---------- 16 files changed, 51 insertions(+), 25 deletions(-) diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl index e562ab14d..745adc55c 100644 --- a/OpenCL/m13711-pure.cl +++ b/OpenCL/m13711-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -46,6 +47,7 @@ typedef struct vc #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc_tmp { @@ -212,7 +214,7 @@ KERNEL_FQ void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; - ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 16; i += 5, j += 1) { diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl index 042e6a4fd..95ff2190a 100644 --- a/OpenCL/m13712-pure.cl +++ b/OpenCL/m13712-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -261,7 +262,7 @@ KERNEL_FQ void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; - ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 32; i += 5, j += 1) { diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl index d7135e284..3f57e13ea 100644 --- a/OpenCL/m13713-pure.cl +++ b/OpenCL/m13713-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -326,7 +327,7 @@ KERNEL_FQ void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3]; tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4]; - ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 48; i += 5, j += 1) { diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 209c1d62e..75b6bd7d6 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -238,7 +239,7 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; - sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) { diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index 52b18f9ee..d7f2b9806 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -289,7 +290,7 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; - sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 16; i += 8, j += 1) { diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index 3a49cc1b4..bbf2d8919 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -354,7 +355,7 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; - sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 24; i += 8, j += 1) { diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl index 06951a7d8..03161dd63 100644 --- a/OpenCL/m13731-pure.cl +++ b/OpenCL/m13731-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -334,7 +335,7 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; - whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 16; i += 16, j += 1) { diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl index 41263e8a4..9451e0df5 100644 --- a/OpenCL/m13732-pure.cl +++ b/OpenCL/m13732-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -385,7 +386,7 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; - whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 32; i += 16, j += 1) { diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl index 1d15ed3d2..1691f2791 100644 --- a/OpenCL/m13733-pure.cl +++ b/OpenCL/m13733-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -450,7 +451,7 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14]; tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15]; - whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 48; i += 16, j += 1) { diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index fbd04283c..bdf7fde4c 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -222,7 +223,7 @@ KERNEL_FQ void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; - sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 16; i += 8, j += 1) { diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index ec02b0d8e..c903ed64b 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -273,7 +274,7 @@ KERNEL_FQ void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; - sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 32; i += 8, j += 1) { diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 4781af53f..baa0e9e2b 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -338,7 +339,7 @@ KERNEL_FQ void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; - sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 48; i += 8, j += 1) { diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index a9ab042b9..ee6f9adc9 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -306,7 +307,7 @@ KERNEL_FQ void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6]; tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7]; - streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) { diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index a44a0dab6..8c77189cc 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -357,7 +358,7 @@ KERNEL_FQ void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6]; tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7]; - streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); u32 i = 0; u32 j = 1; diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 701c1b0f9..3aa411572 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -20,6 +20,7 @@ #endif #define VC_DATA_LEN (448) +#define VC_SALT_LEN ( 64) typedef struct vc { @@ -422,7 +423,7 @@ KERNEL_FQ void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6]; tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7]; - streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); + streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN); u32 i = 0; u32 j = 1; diff --git a/tools/veracrypt2hashcat.py b/tools/veracrypt2hashcat.py index f29d01dfe..e08b2e175 100755 --- a/tools/veracrypt2hashcat.py +++ b/tools/veracrypt2hashcat.py @@ -1,5 +1,10 @@ #!/usr/bin/env python3 +# +# Author......: See docs/credits.txt +# License.....: MIT +# + from argparse import ArgumentParser, ArgumentTypeError @@ -23,9 +28,10 @@ def validate_offset(offset): offset = BOOTABLE_OFFSET + HIDDEN_OFFSET try: offset = int(offset) - assert offset >= 0 - except (AssertionError, ValueError): - raise ArgumentTypeError("offset is nether non-negative number nor bootable, hidden or bootable+hidden value") + except ValueError as e: + raise ArgumentTypeError("value is nether number nor allowed string") from e + if offset < 0: + raise ArgumentTypeError("value cannot be less than zero") return offset @@ -42,14 +48,18 @@ if __name__ == "__main__": args = parser.parse_args() - with open(args.path, "rb") as file: - file.seek(args.offset) + try: + with open(args.path, "rb") as file: + file.seek(args.offset) - header = file.read(HEADER_LENGTH) + header = file.read(HEADER_LENGTH) - assert len(header) == HEADER_LENGTH, "less data than needed" + if len(header) < HEADER_LENGTH: + parser.error("file contains less data than needed") - salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:] + salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:] - hash = SIGNATURE + salt.hex() + "$" + data.hex() - print(hash) + hash = SIGNATURE + salt.hex() + "$" + data.hex() + print(hash) + except IOError as e: + parser.error(e.strerror.lower()) From 992f1c13ba85c73fd4497b0c7cdeac85a7c01821 Mon Sep 17 00:00:00 2001 From: Mayank Date: Fri, 9 Feb 2024 23:15:54 +0530 Subject: [PATCH 014/357] Removed -nocudalib from hiprtc_options to fix LLVMBitcode compilation error when using HIP Backend --- src/backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..d4cf54be4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -8755,7 +8755,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p */ hiprtc_options[1] = "-nocudainc"; - hiprtc_options[2] = "-nocudalib"; + hiprtc_options[2] = ""; hiprtc_options[3] = ""; hiprtc_options[4] = ""; From c4bb788ad5cda4f656680f67e3caa0c84a57d175 Mon Sep 17 00:00:00 2001 From: its5Q Date: Thu, 22 Feb 2024 03:39:05 +1000 Subject: [PATCH 015/357] Add hashmodes 26620 and 26630 with dynamic iteration count --- OpenCL/m26620-pure.cl | 375 +++++++++++++++++++++++++++++++++ OpenCL/m26630-pure.cl | 413 ++++++++++++++++++++++++++++++++++++ src/modules/module_26620.c | 415 +++++++++++++++++++++++++++++++++++++ src/modules/module_26630.c | 395 +++++++++++++++++++++++++++++++++++ tools/metamask2hashcat.py | 16 +- 5 files changed, 1612 insertions(+), 2 deletions(-) create mode 100644 OpenCL/m26620-pure.cl create mode 100644 OpenCL/m26630-pure.cl create mode 100644 src/modules/module_26620.c create mode 100644 src/modules/module_26630.c mode change 100755 => 100644 tools/metamask2hashcat.py diff --git a/OpenCL/m26620-pure.cl b/OpenCL/m26620-pure.cl new file mode 100644 index 000000000..26ad55595 --- /dev/null +++ b/OpenCL/m26620-pure.cl @@ -0,0 +1,375 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes-gcm.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_aes_gcm +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[784]; + u32 ct_len; + +} pbkdf2_sha256_aes_gcm_t; + +DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m26620_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; + + sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +KERNEL_FQ void m26620_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[8]; + u32x opad[8]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + ipad[5] = packv (tmps, ipad, gid, 5); + ipad[6] = packv (tmps, ipad, gid, 6); + ipad[7] = packv (tmps, ipad, gid, 7); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + opad[5] = packv (tmps, opad, gid, 5); + opad[6] = packv (tmps, opad, gid, 6); + opad[7] = packv (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + u32x out[8]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + dgst[5] = packv (tmps, dgst, gid, i + 5); + dgst[6] = packv (tmps, dgst, gid, i + 6); + dgst[7] = packv (tmps, dgst, gid, i + 7); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + out[5] = packv (tmps, out, gid, i + 5); + out[6] = packv (tmps, out, gid, i + 6); + out[7] = packv (tmps, out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + unpackv (tmps, dgst, gid, i + 5, dgst[5]); + unpackv (tmps, dgst, gid, i + 6, dgst[6]); + unpackv (tmps, dgst, gid, i + 7, dgst[7]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + unpackv (tmps, out, gid, i + 5, out[5]); + unpackv (tmps, out, gid, i + 6, out[6]); + unpackv (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m26620_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + // keys + + u32 ukey[8]; + + ukey[0] = tmps[gid].out[0]; + ukey[1] = tmps[gid].out[1]; + ukey[2] = tmps[gid].out[2]; + ukey[3] = tmps[gid].out[3]; + ukey[4] = tmps[gid].out[4]; + ukey[5] = tmps[gid].out[5]; + ukey[6] = tmps[gid].out[6]; + ukey[7] = tmps[gid].out[7]; + + u32 key_len = 32 * 8; + + u32 key[60] = { 0 }; + u32 subKey[4] = { 0 }; + + AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); + + // iv + + u32 iv[4]; + + iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0]; + iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1]; + iv[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2]; + iv[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]; + + const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len; + + u32 J0[4] = { 0 }; + + AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0); + + // ct + + u32 T[4] = { 0 }; + u32 S[4] = { 0 }; + + u32 S_len = 16; + u32 aad_buf[4] = { 0 }; + u32 aad_len = 0; + + AES_GCM_GHASH_GLOBAL (subKey, aad_buf, aad_len, esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf, esalt_bufs[DIGESTS_OFFSET_HOST].ct_len, S); + + AES_GCM_GCTR (key, J0, S, S_len, T, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* compare tag */ + + const u32 r0 = T[0]; + const u32 r1 = T[1]; + const u32 r2 = T[2]; + const u32 r3 = T[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m26630-pure.cl b/OpenCL/m26630-pure.cl new file mode 100644 index 000000000..39727b730 --- /dev/null +++ b/OpenCL/m26630-pure.cl @@ -0,0 +1,413 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes-gcm.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_aes_gcm +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[16]; + u32 ct_len; + +} pbkdf2_sha256_aes_gcm_t; + +DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m26630_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; + + sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +KERNEL_FQ void m26630_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[8]; + u32x opad[8]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + ipad[5] = packv (tmps, ipad, gid, 5); + ipad[6] = packv (tmps, ipad, gid, 6); + ipad[7] = packv (tmps, ipad, gid, 7); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + opad[5] = packv (tmps, opad, gid, 5); + opad[6] = packv (tmps, opad, gid, 6); + opad[7] = packv (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + u32x out[8]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + dgst[5] = packv (tmps, dgst, gid, i + 5); + dgst[6] = packv (tmps, dgst, gid, i + 6); + dgst[7] = packv (tmps, dgst, gid, i + 7); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + out[5] = packv (tmps, out, gid, i + 5); + out[6] = packv (tmps, out, gid, i + 6); + out[7] = packv (tmps, out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + unpackv (tmps, dgst, gid, i + 5, dgst[5]); + unpackv (tmps, dgst, gid, i + 6, dgst[6]); + unpackv (tmps, dgst, gid, i + 7, dgst[7]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + unpackv (tmps, out, gid, i + 5, out[5]); + unpackv (tmps, out, gid, i + 6, out[6]); + unpackv (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m26630_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + const u32 digest_pos = LOOP_POS; + + const u32 digest_cur = DIGESTS_OFFSET_HOST + digest_pos; + + GLOBAL_AS const pbkdf2_sha256_aes_gcm_t *pbkdf2_sha256_aes_gcm = &esalt_bufs[digest_cur]; + + // keys + + u32 ukey[8]; + + ukey[0] = tmps[gid].out[0]; + ukey[1] = tmps[gid].out[1]; + ukey[2] = tmps[gid].out[2]; + ukey[3] = tmps[gid].out[3]; + ukey[4] = tmps[gid].out[4]; + ukey[5] = tmps[gid].out[5]; + ukey[6] = tmps[gid].out[6]; + ukey[7] = tmps[gid].out[7]; + + u32 key_len = 32 * 8; + + u32 key[60] = { 0 }; + u32 subKey[4] = { 0 }; + + AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); + + // iv + + u32 iv[4]; + + iv[0] = pbkdf2_sha256_aes_gcm->iv_buf[0]; + iv[1] = pbkdf2_sha256_aes_gcm->iv_buf[1]; + iv[2] = pbkdf2_sha256_aes_gcm->iv_buf[2]; + iv[3] = pbkdf2_sha256_aes_gcm->iv_buf[3]; + + const u32 iv_len = pbkdf2_sha256_aes_gcm->iv_len; + + u32 J0[4] = { 0 }; + + AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0); + + u32 ct[8]; + + ct[0] = pbkdf2_sha256_aes_gcm->ct_buf[0]; // first block of ciphertext + ct[1] = pbkdf2_sha256_aes_gcm->ct_buf[1]; + ct[2] = pbkdf2_sha256_aes_gcm->ct_buf[2]; + ct[3] = pbkdf2_sha256_aes_gcm->ct_buf[3]; + ct[4] = pbkdf2_sha256_aes_gcm->ct_buf[4]; // second block of ciphertext + ct[5] = pbkdf2_sha256_aes_gcm->ct_buf[5]; + ct[6] = pbkdf2_sha256_aes_gcm->ct_buf[6]; + ct[7] = pbkdf2_sha256_aes_gcm->ct_buf[7]; + + u32 pt[8] = { 0 }; + + AES_GCM_decrypt (key, J0, ct, 32, pt, s_te0, s_te1, s_te2, s_te3, s_te4); + + const int correct = is_valid_printable_32 (pt[0]) + + is_valid_printable_32 (pt[1]) + + is_valid_printable_32 (pt[2]) + + is_valid_printable_32 (pt[3]) + + is_valid_printable_32 (pt[4]) + + is_valid_printable_32 (pt[5]) + + is_valid_printable_32 (pt[6]) + + is_valid_printable_32 (pt[7]); + + if (correct != 8) return; + + /* + const int pt_len = 28; // not using 32 byte but 28 because our UTF8 allows up to 4 byte per character and since we decrypt 32 byte + // only we can't guarantee it is not in the middle of a UTF8 byte stream at that point + + if (hc_enc_scan (pt, pt_len)) + { + hc_enc_t hc_enc; + + hc_enc_init (&hc_enc); + + while (hc_enc_has_next (&hc_enc, pt_len)) + { + u32 enc_buf[16] = { 0 }; + + const int enc_len = hc_enc_next (&hc_enc, pt, pt_len, 32, enc_buf, sizeof (enc_buf)); + + if (enc_len == -1) return; + } + } + */ + + const u32 r0 = ct[0]; + const u32 r1 = ct[1]; + const u32 r2 = ct[2]; + const u32 r3 = ct[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/src/modules/module_26620.c b/src/modules/module_26620.c new file mode 100644 index 000000000..f3c4509ad --- /dev/null +++ b/src/modules/module_26620.c @@ -0,0 +1,415 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; +static const char *HASH_NAME = "MetaMask Wallet (needs all data, checks AES-GCM tag, dynamic iterations)"; +static const u64 KERN_TYPE = 26620; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat1"; +// hash generated using with python3 tools/metamask2hashcat.py --vault tools/2hashcat_tests/metamask2hashcat.json +static const char *ST_HASH = "$metamask$600000$MBdUsmTcBHGCASECYr3gmD8XaJROwjhOegSWweCFhco=$N1aDRjt2ZD5x15Q1X9zVUw==$G2Qsp8BtQNz9E1vFlSebykcGkps5iJ53fBjJV8GIE7eolAQpz5m25MTZv0b0t2tpqXvfgEYKYZKsoLvuWWRHqj2ommt+U0l6fEGPY6lTn5PYzDtMKNpPWHKCIS/QYhwEA9/X5RtyIwDL6VqcRp6owV+/icmRlQa+TI5buHWZ+99Z1kBbpTDVYLBwhMRsODM1vYizQDg0vFIo3cQDtpRWUqpAKXhFcpgRD+9grS3pP/zdlIUn//87DZ3ue6Sn6WFOe08EvuY8sYZqTiN3GxcfESOltNbZJGcedMubt/jGsk+qIwUWC/f456UgeX9DN7i2pQBBI+L7qkY5v1WT5Y0i8uho1c2M2G8M9miO8HSm/j4bpMN1J6lPtjFhfAzEPS1go1w2vTmOtr1y+2A4M6HEOcxIrPJ8lUUH9pcN7Xpd+u/tQv8BYFxd6RlNYKLyA6OChbF+TD5Zz6oFZQtkprXqzZUFOlxeWJ373kHMISZtXOx44YGaiT2178fXgHFXavw="; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_aes_gcm +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[784]; + u32 ct_len; + +} pbkdf2_sha256_aes_gcm_t; + +static const char *SIGNATURE_METAMASK_WALLET = "$metamask$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_aes_gcm_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); + + return tmp_size; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_min = 8; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha256_aes_gcm_t *metamask = (pbkdf2_sha256_aes_gcm_t *) esalt_buf; + + #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 5; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_METAMASK_WALLET; + + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 6; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '$'; + token.len[2] = 44; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[3] = '$'; + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[4] = '$'; + token.len_min[4] = 64; + token.len_max[4] = CT_MAX_LEN_BASE64; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + u8 tmp_buf[CT_MAX_LEN_BASE64] = { 0 }; + + size_t tmp_len = 0; + + // iter + + const u8 *iter_pos = token.buf[1]; + + const int iter = strtol ((const char *) iter_pos, NULL, 10); + + if (iter < 1) return (PARSER_SALT_ITERATION); + + salt->salt_iter = iter - 1; + + // salt + + const u8 *salt_pos = token.buf[2]; + const int salt_len = token.len[2]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); + + if (tmp_len != 32) return (PARSER_SALT_LENGTH); + + memcpy (salt->salt_buf, tmp_buf, tmp_len); + + salt->salt_len = tmp_len; + + metamask->salt_buf[0] = salt->salt_buf[0]; + metamask->salt_buf[1] = salt->salt_buf[1]; + metamask->salt_buf[2] = salt->salt_buf[2]; + metamask->salt_buf[3] = salt->salt_buf[3]; + metamask->salt_buf[4] = salt->salt_buf[4]; + metamask->salt_buf[5] = salt->salt_buf[5]; + metamask->salt_buf[6] = salt->salt_buf[6]; + metamask->salt_buf[7] = salt->salt_buf[7]; + + // iv + + const u8 *iv_pos = token.buf[3]; + const int iv_len = token.len[3]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, iv_pos, iv_len, tmp_buf); + + if (tmp_len != 16) return (PARSER_IV_LENGTH); + + memcpy ((u8 *) metamask->iv_buf, tmp_buf, tmp_len); + + metamask->iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); + metamask->iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); + metamask->iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); + metamask->iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); + + metamask->iv_len = tmp_len; + + // ciphertext + + const u8 *ct_pos = token.buf[4]; + const int ct_len = token.len[4]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); + + if (tmp_len <= 16) return (PARSER_CT_LENGTH); + + tmp_len -= 16; + + if (tmp_len < 30 || tmp_len > 3136) return (PARSER_CT_LENGTH); + + memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); + + u32 j = tmp_len / 4; + + if ((tmp_len % 4) > 0) j++; + + for (u32 i = 0; i < j; i++) metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + + metamask->ct_len = tmp_len; + + // tag + + u32 tag_buf[4] = { 0 }; + + memcpy ((u8 *) tag_buf, tmp_buf+metamask->ct_len, 16); + + digest[0] = byte_swap_32 (tag_buf[0]); + digest[1] = byte_swap_32 (tag_buf[1]); + digest[2] = byte_swap_32 (tag_buf[2]); + digest[3] = byte_swap_32 (tag_buf[3]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const pbkdf2_sha256_aes_gcm_t *metamask = (const pbkdf2_sha256_aes_gcm_t *) esalt_buf; + + // salt + + #define SALT_LEN_BASE64 ((32 * 8) / 6) + 3 + #define IV_LEN_BASE64 ((16 * 8) / 6) + 3 + #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 + + u8 salt_buf[SALT_LEN_BASE64] = { 0 }; + + base64_encode (int_to_base64, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); + + // iv + + u32 tmp_iv_buf[4] = { 0 }; + + tmp_iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); + tmp_iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); + tmp_iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); + tmp_iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); + + u8 iv_buf[IV_LEN_BASE64+1] = { 0 }; + + base64_encode (int_to_base64, (const u8 *) tmp_iv_buf, (const int) metamask->iv_len, iv_buf); + + // ct + + u32 ct_len = metamask->ct_len; + + u32 j = ct_len / 4; + + if ((ct_len % 4) > 0) j++; + + u32 tmp_buf[788] = { 0 }; + + for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + + u32 tmp_tag[4] = { 0 }; + + tmp_tag[0] = byte_swap_32 (digest[0]); + tmp_tag[1] = byte_swap_32 (digest[1]); + tmp_tag[2] = byte_swap_32 (digest[2]); + tmp_tag[3] = byte_swap_32 (digest[3]); + + u8 *tmp_buf_str = (u8 *) tmp_buf; + u8 *tmp_tag_str = (u8 *) tmp_tag; + + memcpy (tmp_buf_str+metamask->ct_len, tmp_tag_str, 16); + + u8 ct_buf[CT_MAX_LEN_BASE64] = { 0 }; + + base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len+16, ct_buf); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt_buf, + iv_buf, + ct_buf); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_26630.c b/src/modules/module_26630.c new file mode 100644 index 000000000..f6d6f596f --- /dev/null +++ b/src/modules/module_26630.c @@ -0,0 +1,395 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; +static const char *HASH_NAME = "MetaMask Wallet (short hash, plaintext check, dynamic iterations)"; +static const u64 KERN_TYPE = 26630; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_DEEP_COMP_KERNEL; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat1"; +static const char *ST_HASH = "$metamask-short$600000$MBdUsmTcBHGCASECYr3gmD8XaJROwjhOegSWweCFhco=$N1aDRjt2ZD5x15Q1X9zVUw==$G2Qsp8BtQNz9E1vFlSebykcGkps5iJ53fBjJV8GIE7eolAQpz5m25MTZv0b0t2tpqXvfgEYKYZKsoLvuWWRHqg=="; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256_aes_gcm +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[16]; + u32 ct_len; + +} pbkdf2_sha256_aes_gcm_t; + +static const char *SIGNATURE_METAMASK_WALLET = "$metamask-short$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + return KERN_RUN_3; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_aes_gcm_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); + + return tmp_size; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_min = 8; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha256_aes_gcm_t *metamask = (pbkdf2_sha256_aes_gcm_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 5; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_METAMASK_WALLET; + + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 6; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '$'; + token.len[2] = 44; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[3] = '$'; + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[4] = '$'; + token.len_min[4] = 88; + token.len_max[4] = 88; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + const u8 *iter_pos = token.buf[1]; + + const int iter = strtol ((const char *) iter_pos, NULL, 10); + + if (iter < 1) return (PARSER_SALT_ITERATION); + + salt->salt_iter = iter - 1; + + // salt + + const u8 *salt_pos = token.buf[2]; + const int salt_len = token.len[2]; + + u8 tmp_buf[88+1]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + size_t tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); + + if (tmp_len != 32) return (PARSER_SALT_LENGTH); + + memcpy (salt->salt_buf, tmp_buf, tmp_len); + + salt->salt_len = tmp_len; + + metamask->salt_buf[0] = salt->salt_buf[0]; + metamask->salt_buf[1] = salt->salt_buf[1]; + metamask->salt_buf[2] = salt->salt_buf[2]; + metamask->salt_buf[3] = salt->salt_buf[3]; + metamask->salt_buf[4] = salt->salt_buf[4]; + metamask->salt_buf[5] = salt->salt_buf[5]; + metamask->salt_buf[6] = salt->salt_buf[6]; + metamask->salt_buf[7] = salt->salt_buf[7]; + + // iv + + const u8 *iv_pos = token.buf[3]; + const int iv_len = token.len[3]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, iv_pos, iv_len, tmp_buf); + + if (tmp_len != 16) return (PARSER_IV_LENGTH); + + memcpy ((u8 *) metamask->iv_buf, tmp_buf, tmp_len); + + metamask->iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); + metamask->iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); + metamask->iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); + metamask->iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); + + metamask->iv_len = tmp_len; + + // ciphertext + + const u8 *ct_pos = token.buf[4]; + const int ct_len = token.len[4]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); + + if (tmp_len != 64) return (PARSER_CT_LENGTH); + + memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); + + u32 j = tmp_len / 4; + + for (u32 i = 0; i < j; i++) + { + metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + } + + metamask->ct_len = tmp_len; + + digest[0] = metamask->ct_buf[0]; + digest[1] = metamask->ct_buf[1]; + digest[2] = metamask->ct_buf[2]; + digest[3] = metamask->ct_buf[3]; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const pbkdf2_sha256_aes_gcm_t *metamask = (const pbkdf2_sha256_aes_gcm_t *) esalt_buf; + + // salt + + u8 salt_buf[44+1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + base64_encode (int_to_base64, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); + + // iv + + u32 tmp_iv_buf[4]; + + tmp_iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); + tmp_iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); + tmp_iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); + tmp_iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); + + u8 iv_buf[24+1]; + + memset (iv_buf, 0, sizeof (iv_buf)); + + base64_encode (int_to_base64, (const u8 *) tmp_iv_buf, (const int) metamask->iv_len, iv_buf); + + // ct + + u32 tmp_buf[16]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + u32 ct_len = metamask->ct_len; + + u32 j = ct_len / 4; + + for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + + u8 ct_buf[88+1]; + + memset (ct_buf, 0, sizeof (ct_buf)); + + base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len, ct_buf); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt_buf, + iv_buf, + ct_buf); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py old mode 100755 new mode 100644 index a2aa99774..6c32e82c7 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -51,8 +51,14 @@ def metamask_parser(file, shortdata): parser.print_help() exit(1) + if isMobile is False: + if 'keyMetadata' in j and 'params' in j['keyMetadata'] and 'iterations' in j['keyMetadata']['params']: + iter_count = j['keyMetadata']['params']['iterations'] + else: + iter_count = 10000 + if((len(j['data']) > 3000) or shortdata): data_bin = base64.b64decode(j['data']) # TODO limit data to 16 bytes, we only check the first block of data, so we don't need more data. @@ -60,9 +66,15 @@ def metamask_parser(file, shortdata): # Still the pbkdf 10k iter will be taking the most time by far probably. j['data'] = base64.b64encode(data_bin[0:64]).decode("ascii") - print('$metamask-short$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + if iter_count != 10000: + print('$metamask-short$' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + else: + print('$metamask-short$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: - print('$metamask$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + if iter_count != 10000: + print('$metamask$' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + else: + print('$metamask$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: From 205e7f6e71da6509005b06dde2833584f8b84dbf Mon Sep 17 00:00:00 2001 From: its5Q Date: Thu, 22 Feb 2024 03:40:36 +1000 Subject: [PATCH 016/357] Update metamask2hashcat help string --- tools/metamask2hashcat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py index 6c32e82c7..1e4de119c 100644 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -94,7 +94,7 @@ def metamask_parser(file, shortdata): if __name__ == "__main__": parser = argparse.ArgumentParser(description="metamask2hashcat.py extraction tool") parser.add_argument('--vault', required=True, help='set metamask vault (json) file from path', type=str) - parser.add_argument('--shortdata', help='force short data, can only be used with m26610, ', action='store_true') + parser.add_argument('--shortdata', help='force short data, can only be used with m26610/m26630, ', action='store_true') args = parser.parse_args() From 55406d8342732f6eafa86b92820ace5e4fe32912 Mon Sep 17 00:00:00 2001 From: its5Q Date: Thu, 22 Feb 2024 22:48:00 +1000 Subject: [PATCH 017/357] Cleaner JSON key handling in metamask2hashcat Co-authored-by: kgolawski --- tools/metamask2hashcat.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py index 1e4de119c..a31d600f8 100644 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -54,11 +54,10 @@ def metamask_parser(file, shortdata): if isMobile is False: - if 'keyMetadata' in j and 'params' in j['keyMetadata'] and 'iterations' in j['keyMetadata']['params']: + try: iter_count = j['keyMetadata']['params']['iterations'] - else: - iter_count = 10000 - + except KeyError: + iter_count = 10_000 if((len(j['data']) > 3000) or shortdata): data_bin = base64.b64decode(j['data']) # TODO limit data to 16 bytes, we only check the first block of data, so we don't need more data. From d725b4b928d5a0487a58c310235228e2b26ce0ab Mon Sep 17 00:00:00 2001 From: its5Q Date: Fri, 23 Feb 2024 06:22:27 +1000 Subject: [PATCH 018/357] Switch to using TOKEN_ATTR_OPTIONAL_ROUNDS for Metamask hashmodes --- src/modules/module_26600.c | 38 ++-- src/modules/module_26610.c | 36 +++- src/modules/module_26620.c | 415 ------------------------------------- src/modules/module_26630.c | 395 ----------------------------------- tools/metamask2hashcat.py | 2 +- 5 files changed, 52 insertions(+), 834 deletions(-) delete mode 100644 src/modules/module_26620.c delete mode 100644 src/modules/module_26630.c diff --git a/src/modules/module_26600.c b/src/modules/module_26600.c index 4f6d0de3b..1f211310d 100644 --- a/src/modules/module_26600.c +++ b/src/modules/module_26600.c @@ -29,6 +29,8 @@ static const char *ST_PASS = "hashcat1"; // hash generated using with python3 tools/metamask2hashcat.py --vault tools/2hashcat_tests/metamask2hashcat.json static const char *ST_HASH = "$metamask$jfGI3TXguhb8GPnKSXFrMzRk2NCEc131Gt5G3kZr5+s=$h+BoIf2CQ5BEjaIOShFE7g==$R95fzGt4UQ0uwrcrVYnIi4UcSlWn9wlmer+//526ZDwYAp50K82F1u1oacYcdjjhuEvbZnWk/uBG00UkgLLlO3WbINljqmu2QWdDEwjTgo/qWR6MU9d/82rxNiONHQE8UrZ8SV+htVr6XIB0ze3aCV0E+fwI93EeP79ZeDxuOEhuHoiYT0bHWMv5nA48AdluG4DbOo7SrDAWBVCBsEdXsOfYsS3/TIh0a/iFCMX4uhxY2824JwcWp4H36SFWyBYMZCJ3/U4DYFbbjWZtGRthoJlIik5BJq4FLu3Y1jEgza0AWlAvu4MKTEqrYSpUIghfxf1a1f+kPvxsHNq0as0kRwCXu09DObbdsiggbmeoBkxMZiFq0d9ar/3Gon0r3hfc3c124Wlivzbzu1JcZ3wURhLSsUS7b5cfG86aXHJkxmQDA5urBz6lw3bsIvlEUB2ErkQy/zD+cPwCG1Rs/WKt7KNh45lppCUkHccbf+xlpdc8OfUwj01Xp7BdH8LMR7Vx1C4hZCvSdtURVl0VaAMxHDX0MjRkwmqS"; +static const u32 ROUNDS_METAMASK = 10000; + u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } u32 module_dgst_pos1 (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 DGST_POS1; } @@ -144,9 +146,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 44; - token.attr[1] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; + token.len_min[1] = 0; + token.len_max[1] = 60; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_OPTIONAL_ROUNDS; token.sep[2] = '$'; token.len[2] = 24; @@ -169,7 +172,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // iter - salt->salt_iter = 10000 - 1; + salt->salt_iter = ROUNDS_METAMASK - 1; + + if (token.opt_len != -1) + { + salt->salt_iter = hc_strtoul ((const char *) token.opt_buf + 7, NULL, 10) - 1; // 7 = "rounds=" + } // salt @@ -312,14 +320,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len+16, ct_buf); u8 *out_buf = (u8 *) line_buf; - - int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", - SIGNATURE_METAMASK_WALLET, - salt_buf, - iv_buf, - ct_buf); - - return out_len; + + if (salt->salt_iter + 1 != ROUNDS_METAMASK) + return snprintf ((char *) out_buf, line_size, "%srounds=%d$%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt->salt_iter + 1, + salt_buf, + iv_buf, + ct_buf); + else + return snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt_buf, + iv_buf, + ct_buf); } void module_init (module_ctx_t *module_ctx) diff --git a/src/modules/module_26610.c b/src/modules/module_26610.c index 532246128..64cf20f4b 100644 --- a/src/modules/module_26610.c +++ b/src/modules/module_26610.c @@ -29,6 +29,8 @@ static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat1"; static const char *ST_HASH = "$metamask-short$jfGI3TXguhb8GPnKSXFrMzRk2NCEc131Gt5G3kZr5+s=$h+BoIf2CQ5BEjaIOShFE7g==$R95fzGt4UQ0uwrcrVYnIi4UcSlWn9wlmer+//526ZDwYAp50K82F1u1oacYcdjjhuEvbZnWk/uBG00UkgLLlOw=="; +static const u32 ROUNDS_METAMASK = 10000; + u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } u32 module_dgst_pos1 (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 DGST_POS1; } @@ -147,9 +149,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 44; - token.attr[1] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; + token.len_min[1] = 0; + token.len_max[1] = 60; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_OPTIONAL_ROUNDS; token.sep[2] = '$'; token.len[2] = 24; @@ -168,7 +171,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // iter - salt->salt_iter = 10000 - 1; + salt->salt_iter = ROUNDS_METAMASK - 1; + + if (token.opt_len != -1) + { + salt->salt_iter = hc_strtoul ((const char *) token.opt_buf + 7, NULL, 10) - 1; // 7 = "rounds=" + } // salt @@ -293,13 +301,19 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u8 *out_buf = (u8 *) line_buf; - int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", - SIGNATURE_METAMASK_WALLET, - salt_buf, - iv_buf, - ct_buf); - - return out_len; + if (salt->salt_iter + 1 != ROUNDS_METAMASK) + return snprintf ((char *) out_buf, line_size, "%srounds=%d$%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt->salt_iter + 1, + salt_buf, + iv_buf, + ct_buf); + else + return snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt_buf, + iv_buf, + ct_buf); } void module_init (module_ctx_t *module_ctx) diff --git a/src/modules/module_26620.c b/src/modules/module_26620.c deleted file mode 100644 index f3c4509ad..000000000 --- a/src/modules/module_26620.c +++ /dev/null @@ -1,415 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "modules.h" -#include "bitops.h" -#include "convert.h" -#include "shared.h" -#include "memory.h" - -static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; -static const u32 DGST_POS0 = 0; -static const u32 DGST_POS1 = 1; -static const u32 DGST_POS2 = 2; -static const u32 DGST_POS3 = 3; -static const u32 DGST_SIZE = DGST_SIZE_4_4; -static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; -static const char *HASH_NAME = "MetaMask Wallet (needs all data, checks AES-GCM tag, dynamic iterations)"; -static const u64 KERN_TYPE = 26620; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; -static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE - | OPTS_TYPE_PT_GENERATE_LE; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; -static const char *ST_PASS = "hashcat1"; -// hash generated using with python3 tools/metamask2hashcat.py --vault tools/2hashcat_tests/metamask2hashcat.json -static const char *ST_HASH = "$metamask$600000$MBdUsmTcBHGCASECYr3gmD8XaJROwjhOegSWweCFhco=$N1aDRjt2ZD5x15Q1X9zVUw==$G2Qsp8BtQNz9E1vFlSebykcGkps5iJ53fBjJV8GIE7eolAQpz5m25MTZv0b0t2tpqXvfgEYKYZKsoLvuWWRHqj2ommt+U0l6fEGPY6lTn5PYzDtMKNpPWHKCIS/QYhwEA9/X5RtyIwDL6VqcRp6owV+/icmRlQa+TI5buHWZ+99Z1kBbpTDVYLBwhMRsODM1vYizQDg0vFIo3cQDtpRWUqpAKXhFcpgRD+9grS3pP/zdlIUn//87DZ3ue6Sn6WFOe08EvuY8sYZqTiN3GxcfESOltNbZJGcedMubt/jGsk+qIwUWC/f456UgeX9DN7i2pQBBI+L7qkY5v1WT5Y0i8uho1c2M2G8M9miO8HSm/j4bpMN1J6lPtjFhfAzEPS1go1w2vTmOtr1y+2A4M6HEOcxIrPJ8lUUH9pcN7Xpd+u/tQv8BYFxd6RlNYKLyA6OChbF+TD5Zz6oFZQtkprXqzZUFOlxeWJ373kHMISZtXOx44YGaiT2178fXgHFXavw="; - -u32 module_attack_exec (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 ATTACK_EXEC; } -u32 module_dgst_pos0 (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 DGST_POS0; } -u32 module_dgst_pos1 (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 DGST_POS1; } -u32 module_dgst_pos2 (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 DGST_POS2; } -u32 module_dgst_pos3 (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 DGST_POS3; } -u32 module_dgst_size (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 DGST_SIZE; } -u32 module_hash_category (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 HASH_CATEGORY; } -const char *module_hash_name (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 HASH_NAME; } -u64 module_kern_type (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 KERN_TYPE; } -u32 module_opti_type (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 OPTI_TYPE; } -u64 module_opts_type (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 OPTS_TYPE; } -u32 module_salt_type (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 SALT_TYPE; } -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; } - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha256_aes_gcm -{ - u32 salt_buf[64]; - u32 iv_buf[4]; - u32 iv_len; - u32 ct_buf[784]; - u32 ct_len; - -} pbkdf2_sha256_aes_gcm_t; - -static const char *SIGNATURE_METAMASK_WALLET = "$metamask$"; - -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // Extra treatment for Apple systems - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - return jit_build_options; - } - - // HIP - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) - { - hc_asprintf (&jit_build_options, "-D _unroll"); - } - - // ROCM - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D _unroll"); - } - - return jit_build_options; -} - -u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_aes_gcm_t); - - return esalt_size; -} - -u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); - - return tmp_size; -} - -u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 pw_min = 8; - - return pw_min; -} - -u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - // this overrides the reductions of PW_MAX in case optimized kernel is selected - // IOW, even in optimized kernel mode it support length 256 - - const u32 pw_max = PW_MAX; - - return pw_max; -} - -int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) -{ - u32 *digest = (u32 *) digest_buf; - - pbkdf2_sha256_aes_gcm_t *metamask = (pbkdf2_sha256_aes_gcm_t *) esalt_buf; - - #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 - - hc_token_t token; - - memset (&token, 0, sizeof (hc_token_t)); - - token.token_cnt = 5; - - token.signatures_cnt = 1; - token.signatures_buf[0] = SIGNATURE_METAMASK_WALLET; - - token.len[0] = 10; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 6; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[2] = '$'; - token.len[2] = 44; - token.attr[2] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - token.sep[3] = '$'; - token.len[3] = 24; - token.attr[3] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - token.sep[4] = '$'; - token.len_min[4] = 64; - token.len_max[4] = CT_MAX_LEN_BASE64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - u8 tmp_buf[CT_MAX_LEN_BASE64] = { 0 }; - - size_t tmp_len = 0; - - // iter - - const u8 *iter_pos = token.buf[1]; - - const int iter = strtol ((const char *) iter_pos, NULL, 10); - - if (iter < 1) return (PARSER_SALT_ITERATION); - - salt->salt_iter = iter - 1; - - // salt - - const u8 *salt_pos = token.buf[2]; - const int salt_len = token.len[2]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); - - if (tmp_len != 32) return (PARSER_SALT_LENGTH); - - memcpy (salt->salt_buf, tmp_buf, tmp_len); - - salt->salt_len = tmp_len; - - metamask->salt_buf[0] = salt->salt_buf[0]; - metamask->salt_buf[1] = salt->salt_buf[1]; - metamask->salt_buf[2] = salt->salt_buf[2]; - metamask->salt_buf[3] = salt->salt_buf[3]; - metamask->salt_buf[4] = salt->salt_buf[4]; - metamask->salt_buf[5] = salt->salt_buf[5]; - metamask->salt_buf[6] = salt->salt_buf[6]; - metamask->salt_buf[7] = salt->salt_buf[7]; - - // iv - - const u8 *iv_pos = token.buf[3]; - const int iv_len = token.len[3]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - tmp_len = base64_decode (base64_to_int, iv_pos, iv_len, tmp_buf); - - if (tmp_len != 16) return (PARSER_IV_LENGTH); - - memcpy ((u8 *) metamask->iv_buf, tmp_buf, tmp_len); - - metamask->iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); - metamask->iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); - metamask->iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); - metamask->iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); - - metamask->iv_len = tmp_len; - - // ciphertext - - const u8 *ct_pos = token.buf[4]; - const int ct_len = token.len[4]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); - - if (tmp_len <= 16) return (PARSER_CT_LENGTH); - - tmp_len -= 16; - - if (tmp_len < 30 || tmp_len > 3136) return (PARSER_CT_LENGTH); - - memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); - - u32 j = tmp_len / 4; - - if ((tmp_len % 4) > 0) j++; - - for (u32 i = 0; i < j; i++) metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); - - metamask->ct_len = tmp_len; - - // tag - - u32 tag_buf[4] = { 0 }; - - memcpy ((u8 *) tag_buf, tmp_buf+metamask->ct_len, 16); - - digest[0] = byte_swap_32 (tag_buf[0]); - digest[1] = byte_swap_32 (tag_buf[1]); - digest[2] = byte_swap_32 (tag_buf[2]); - digest[3] = byte_swap_32 (tag_buf[3]); - - return (PARSER_OK); -} - -int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) -{ - const u32 *digest = (const u32 *) digest_buf; - - const pbkdf2_sha256_aes_gcm_t *metamask = (const pbkdf2_sha256_aes_gcm_t *) esalt_buf; - - // salt - - #define SALT_LEN_BASE64 ((32 * 8) / 6) + 3 - #define IV_LEN_BASE64 ((16 * 8) / 6) + 3 - #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 - - u8 salt_buf[SALT_LEN_BASE64] = { 0 }; - - base64_encode (int_to_base64, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); - - // iv - - u32 tmp_iv_buf[4] = { 0 }; - - tmp_iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); - tmp_iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); - tmp_iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); - tmp_iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); - - u8 iv_buf[IV_LEN_BASE64+1] = { 0 }; - - base64_encode (int_to_base64, (const u8 *) tmp_iv_buf, (const int) metamask->iv_len, iv_buf); - - // ct - - u32 ct_len = metamask->ct_len; - - u32 j = ct_len / 4; - - if ((ct_len % 4) > 0) j++; - - u32 tmp_buf[788] = { 0 }; - - for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); - - u32 tmp_tag[4] = { 0 }; - - tmp_tag[0] = byte_swap_32 (digest[0]); - tmp_tag[1] = byte_swap_32 (digest[1]); - tmp_tag[2] = byte_swap_32 (digest[2]); - tmp_tag[3] = byte_swap_32 (digest[3]); - - u8 *tmp_buf_str = (u8 *) tmp_buf; - u8 *tmp_tag_str = (u8 *) tmp_tag; - - memcpy (tmp_buf_str+metamask->ct_len, tmp_tag_str, 16); - - u8 ct_buf[CT_MAX_LEN_BASE64] = { 0 }; - - base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len+16, ct_buf); - - u8 *out_buf = (u8 *) line_buf; - - int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", - SIGNATURE_METAMASK_WALLET, - salt_buf, - iv_buf, - ct_buf); - - return out_len; -} - -void module_init (module_ctx_t *module_ctx) -{ - module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; - module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; - - module_ctx->module_attack_exec = module_attack_exec; - module_ctx->module_benchmark_esalt = MODULE_DEFAULT; - module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; - module_ctx->module_benchmark_mask = MODULE_DEFAULT; - module_ctx->module_benchmark_charset = MODULE_DEFAULT; - module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; - module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; - module_ctx->module_deprecated_notice = MODULE_DEFAULT; - module_ctx->module_dgst_pos0 = module_dgst_pos0; - module_ctx->module_dgst_pos1 = module_dgst_pos1; - module_ctx->module_dgst_pos2 = module_dgst_pos2; - module_ctx->module_dgst_pos3 = module_dgst_pos3; - module_ctx->module_dgst_size = module_dgst_size; - module_ctx->module_dictstat_disable = MODULE_DEFAULT; - module_ctx->module_esalt_size = module_esalt_size; - module_ctx->module_extra_buffer_size = MODULE_DEFAULT; - module_ctx->module_extra_tmp_size = MODULE_DEFAULT; - module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; - module_ctx->module_forced_outfile_format = MODULE_DEFAULT; - module_ctx->module_hash_binary_count = MODULE_DEFAULT; - module_ctx->module_hash_binary_parse = MODULE_DEFAULT; - module_ctx->module_hash_binary_save = MODULE_DEFAULT; - module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; - module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; - module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; - module_ctx->module_hash_decode = module_hash_decode; - module_ctx->module_hash_encode_status = MODULE_DEFAULT; - module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; - module_ctx->module_hash_encode = module_hash_encode; - module_ctx->module_hash_init_selftest = MODULE_DEFAULT; - module_ctx->module_hash_mode = MODULE_DEFAULT; - module_ctx->module_hash_category = module_hash_category; - module_ctx->module_hash_name = module_hash_name; - module_ctx->module_hashes_count_min = MODULE_DEFAULT; - module_ctx->module_hashes_count_max = MODULE_DEFAULT; - module_ctx->module_hlfmt_disable = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; - module_ctx->module_hook12 = MODULE_DEFAULT; - module_ctx->module_hook23 = MODULE_DEFAULT; - module_ctx->module_hook_salt_size = MODULE_DEFAULT; - module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = MODULE_DEFAULT; - module_ctx->module_kernel_accel_max = MODULE_DEFAULT; - module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; - module_ctx->module_kernel_loops_min = MODULE_DEFAULT; - module_ctx->module_kernel_threads_max = MODULE_DEFAULT; - module_ctx->module_kernel_threads_min = MODULE_DEFAULT; - module_ctx->module_kern_type = module_kern_type; - module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; - module_ctx->module_opti_type = module_opti_type; - module_ctx->module_opts_type = module_opts_type; - module_ctx->module_outfile_check_disable = MODULE_DEFAULT; - module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; - module_ctx->module_potfile_custom_check = MODULE_DEFAULT; - module_ctx->module_potfile_disable = MODULE_DEFAULT; - module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; - module_ctx->module_pwdump_column = MODULE_DEFAULT; - module_ctx->module_pw_max = module_pw_max; - module_ctx->module_pw_min = module_pw_min; - module_ctx->module_salt_max = MODULE_DEFAULT; - module_ctx->module_salt_min = MODULE_DEFAULT; - module_ctx->module_salt_type = module_salt_type; - module_ctx->module_separator = MODULE_DEFAULT; - module_ctx->module_st_hash = module_st_hash; - module_ctx->module_st_pass = module_st_pass; - module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; - module_ctx->module_warmup_disable = MODULE_DEFAULT; -} diff --git a/src/modules/module_26630.c b/src/modules/module_26630.c deleted file mode 100644 index f6d6f596f..000000000 --- a/src/modules/module_26630.c +++ /dev/null @@ -1,395 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "modules.h" -#include "bitops.h" -#include "convert.h" -#include "shared.h" -#include "memory.h" - -static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; -static const u32 DGST_POS0 = 0; -static const u32 DGST_POS1 = 1; -static const u32 DGST_POS2 = 2; -static const u32 DGST_POS3 = 3; -static const u32 DGST_SIZE = DGST_SIZE_4_4; -static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; -static const char *HASH_NAME = "MetaMask Wallet (short hash, plaintext check, dynamic iterations)"; -static const u64 KERN_TYPE = 26630; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; -static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE - | OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_DEEP_COMP_KERNEL; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; -static const char *ST_PASS = "hashcat1"; -static const char *ST_HASH = "$metamask-short$600000$MBdUsmTcBHGCASECYr3gmD8XaJROwjhOegSWweCFhco=$N1aDRjt2ZD5x15Q1X9zVUw==$G2Qsp8BtQNz9E1vFlSebykcGkps5iJ53fBjJV8GIE7eolAQpz5m25MTZv0b0t2tpqXvfgEYKYZKsoLvuWWRHqg=="; - -u32 module_attack_exec (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 ATTACK_EXEC; } -u32 module_dgst_pos0 (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 DGST_POS0; } -u32 module_dgst_pos1 (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 DGST_POS1; } -u32 module_dgst_pos2 (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 DGST_POS2; } -u32 module_dgst_pos3 (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 DGST_POS3; } -u32 module_dgst_size (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 DGST_SIZE; } -u32 module_hash_category (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 HASH_CATEGORY; } -const char *module_hash_name (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 HASH_NAME; } -u64 module_kern_type (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 KERN_TYPE; } -u32 module_opti_type (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 OPTI_TYPE; } -u64 module_opts_type (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 OPTS_TYPE; } -u32 module_salt_type (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 SALT_TYPE; } -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; } - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha256_aes_gcm -{ - u32 salt_buf[64]; - u32 iv_buf[4]; - u32 iv_len; - u32 ct_buf[16]; - u32 ct_len; - -} pbkdf2_sha256_aes_gcm_t; - -static const char *SIGNATURE_METAMASK_WALLET = "$metamask-short$"; - -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // Extra treatment for Apple systems - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - return jit_build_options; - } - - // HIP - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) - { - hc_asprintf (&jit_build_options, "-D _unroll"); - } - - // ROCM - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D _unroll"); - } - - return jit_build_options; -} - -u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) -{ - return KERN_RUN_3; -} - -u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_aes_gcm_t); - - return esalt_size; -} - -u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); - - return tmp_size; -} - -u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 pw_min = 8; - - return pw_min; -} - -u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - // this overrides the reductions of PW_MAX in case optimized kernel is selected - // IOW, even in optimized kernel mode it support length 256 - - const u32 pw_max = PW_MAX; - - return pw_max; -} - -int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) -{ - u32 *digest = (u32 *) digest_buf; - - pbkdf2_sha256_aes_gcm_t *metamask = (pbkdf2_sha256_aes_gcm_t *) esalt_buf; - - hc_token_t token; - - memset (&token, 0, sizeof (hc_token_t)); - - token.token_cnt = 5; - - token.signatures_cnt = 1; - token.signatures_buf[0] = SIGNATURE_METAMASK_WALLET; - - token.len[0] = 16; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 6; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[2] = '$'; - token.len[2] = 44; - token.attr[2] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - token.sep[3] = '$'; - token.len[3] = 24; - token.attr[3] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - token.sep[4] = '$'; - token.len_min[4] = 88; - token.len_max[4] = 88; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; - - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - // iter - - const u8 *iter_pos = token.buf[1]; - - const int iter = strtol ((const char *) iter_pos, NULL, 10); - - if (iter < 1) return (PARSER_SALT_ITERATION); - - salt->salt_iter = iter - 1; - - // salt - - const u8 *salt_pos = token.buf[2]; - const int salt_len = token.len[2]; - - u8 tmp_buf[88+1]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - size_t tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); - - if (tmp_len != 32) return (PARSER_SALT_LENGTH); - - memcpy (salt->salt_buf, tmp_buf, tmp_len); - - salt->salt_len = tmp_len; - - metamask->salt_buf[0] = salt->salt_buf[0]; - metamask->salt_buf[1] = salt->salt_buf[1]; - metamask->salt_buf[2] = salt->salt_buf[2]; - metamask->salt_buf[3] = salt->salt_buf[3]; - metamask->salt_buf[4] = salt->salt_buf[4]; - metamask->salt_buf[5] = salt->salt_buf[5]; - metamask->salt_buf[6] = salt->salt_buf[6]; - metamask->salt_buf[7] = salt->salt_buf[7]; - - // iv - - const u8 *iv_pos = token.buf[3]; - const int iv_len = token.len[3]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - tmp_len = base64_decode (base64_to_int, iv_pos, iv_len, tmp_buf); - - if (tmp_len != 16) return (PARSER_IV_LENGTH); - - memcpy ((u8 *) metamask->iv_buf, tmp_buf, tmp_len); - - metamask->iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); - metamask->iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); - metamask->iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); - metamask->iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); - - metamask->iv_len = tmp_len; - - // ciphertext - - const u8 *ct_pos = token.buf[4]; - const int ct_len = token.len[4]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); - - if (tmp_len != 64) return (PARSER_CT_LENGTH); - - memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); - - u32 j = tmp_len / 4; - - for (u32 i = 0; i < j; i++) - { - metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); - } - - metamask->ct_len = tmp_len; - - digest[0] = metamask->ct_buf[0]; - digest[1] = metamask->ct_buf[1]; - digest[2] = metamask->ct_buf[2]; - digest[3] = metamask->ct_buf[3]; - - return (PARSER_OK); -} - -int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) -{ - const pbkdf2_sha256_aes_gcm_t *metamask = (const pbkdf2_sha256_aes_gcm_t *) esalt_buf; - - // salt - - u8 salt_buf[44+1]; - - memset (salt_buf, 0, sizeof (salt_buf)); - - base64_encode (int_to_base64, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); - - // iv - - u32 tmp_iv_buf[4]; - - tmp_iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); - tmp_iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); - tmp_iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); - tmp_iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); - - u8 iv_buf[24+1]; - - memset (iv_buf, 0, sizeof (iv_buf)); - - base64_encode (int_to_base64, (const u8 *) tmp_iv_buf, (const int) metamask->iv_len, iv_buf); - - // ct - - u32 tmp_buf[16]; - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - u32 ct_len = metamask->ct_len; - - u32 j = ct_len / 4; - - for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); - - u8 ct_buf[88+1]; - - memset (ct_buf, 0, sizeof (ct_buf)); - - base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len, ct_buf); - - u8 *out_buf = (u8 *) line_buf; - - int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", - SIGNATURE_METAMASK_WALLET, - salt_buf, - iv_buf, - ct_buf); - - return out_len; -} - -void module_init (module_ctx_t *module_ctx) -{ - module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; - module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; - - module_ctx->module_attack_exec = module_attack_exec; - module_ctx->module_benchmark_esalt = MODULE_DEFAULT; - module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; - module_ctx->module_benchmark_mask = MODULE_DEFAULT; - module_ctx->module_benchmark_charset = MODULE_DEFAULT; - module_ctx->module_benchmark_salt = MODULE_DEFAULT; - module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; - module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; - module_ctx->module_deprecated_notice = MODULE_DEFAULT; - module_ctx->module_dgst_pos0 = module_dgst_pos0; - module_ctx->module_dgst_pos1 = module_dgst_pos1; - module_ctx->module_dgst_pos2 = module_dgst_pos2; - module_ctx->module_dgst_pos3 = module_dgst_pos3; - module_ctx->module_dgst_size = module_dgst_size; - module_ctx->module_dictstat_disable = MODULE_DEFAULT; - module_ctx->module_esalt_size = module_esalt_size; - module_ctx->module_extra_buffer_size = MODULE_DEFAULT; - module_ctx->module_extra_tmp_size = MODULE_DEFAULT; - module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; - module_ctx->module_forced_outfile_format = MODULE_DEFAULT; - module_ctx->module_hash_binary_count = MODULE_DEFAULT; - module_ctx->module_hash_binary_parse = MODULE_DEFAULT; - module_ctx->module_hash_binary_save = MODULE_DEFAULT; - module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; - module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; - module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; - module_ctx->module_hash_decode = module_hash_decode; - module_ctx->module_hash_encode_status = MODULE_DEFAULT; - module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; - module_ctx->module_hash_encode = module_hash_encode; - module_ctx->module_hash_init_selftest = MODULE_DEFAULT; - module_ctx->module_hash_mode = MODULE_DEFAULT; - module_ctx->module_hash_category = module_hash_category; - module_ctx->module_hash_name = module_hash_name; - module_ctx->module_hashes_count_min = MODULE_DEFAULT; - module_ctx->module_hashes_count_max = MODULE_DEFAULT; - module_ctx->module_hlfmt_disable = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; - module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; - module_ctx->module_hook12 = MODULE_DEFAULT; - module_ctx->module_hook23 = MODULE_DEFAULT; - module_ctx->module_hook_salt_size = MODULE_DEFAULT; - module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = MODULE_DEFAULT; - module_ctx->module_kernel_accel_max = MODULE_DEFAULT; - module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; - module_ctx->module_kernel_loops_min = MODULE_DEFAULT; - module_ctx->module_kernel_threads_max = MODULE_DEFAULT; - module_ctx->module_kernel_threads_min = MODULE_DEFAULT; - module_ctx->module_kern_type = module_kern_type; - module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; - module_ctx->module_opti_type = module_opti_type; - module_ctx->module_opts_type = module_opts_type; - module_ctx->module_outfile_check_disable = MODULE_DEFAULT; - module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; - module_ctx->module_potfile_custom_check = MODULE_DEFAULT; - module_ctx->module_potfile_disable = MODULE_DEFAULT; - module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; - module_ctx->module_pwdump_column = MODULE_DEFAULT; - module_ctx->module_pw_max = module_pw_max; - module_ctx->module_pw_min = module_pw_min; - module_ctx->module_salt_max = MODULE_DEFAULT; - module_ctx->module_salt_min = MODULE_DEFAULT; - module_ctx->module_salt_type = module_salt_type; - module_ctx->module_separator = MODULE_DEFAULT; - module_ctx->module_st_hash = module_st_hash; - module_ctx->module_st_pass = module_st_pass; - module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; - module_ctx->module_warmup_disable = MODULE_DEFAULT; -} diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py index 1e4de119c..6c32e82c7 100644 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -94,7 +94,7 @@ def metamask_parser(file, shortdata): if __name__ == "__main__": parser = argparse.ArgumentParser(description="metamask2hashcat.py extraction tool") parser.add_argument('--vault', required=True, help='set metamask vault (json) file from path', type=str) - parser.add_argument('--shortdata', help='force short data, can only be used with m26610/m26630, ', action='store_true') + parser.add_argument('--shortdata', help='force short data, can only be used with m26610, ', action='store_true') args = parser.parse_args() From 5f9caed13db94572a00e1ba7831ad6da05abf2ad Mon Sep 17 00:00:00 2001 From: its5Q Date: Fri, 23 Feb 2024 06:24:24 +1000 Subject: [PATCH 019/357] Remove unused Metamask OpenCL kernels --- OpenCL/m26620-pure.cl | 375 -------------------------------------- OpenCL/m26630-pure.cl | 413 ------------------------------------------ 2 files changed, 788 deletions(-) delete mode 100644 OpenCL/m26620-pure.cl delete mode 100644 OpenCL/m26630-pure.cl diff --git a/OpenCL/m26620-pure.cl b/OpenCL/m26620-pure.cl deleted file mode 100644 index 26ad55595..000000000 --- a/OpenCL/m26620-pure.cl +++ /dev/null @@ -1,375 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#define NEW_SIMD_CODE - -#ifdef KERNEL_STATIC -#include M2S(INCLUDE_PATH/inc_vendor.h) -#include M2S(INCLUDE_PATH/inc_types.h) -#include M2S(INCLUDE_PATH/inc_platform.cl) -#include M2S(INCLUDE_PATH/inc_common.cl) -#include M2S(INCLUDE_PATH/inc_simd.cl) -#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) -#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) -#include M2S(INCLUDE_PATH/inc_cipher_aes-gcm.cl) -#endif - -#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) -#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha256_aes_gcm -{ - u32 salt_buf[64]; - u32 iv_buf[4]; - u32 iv_len; - u32 ct_buf[784]; - u32 ct_len; - -} pbkdf2_sha256_aes_gcm_t; - -DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) -{ - digest[0] = ipad[0]; - digest[1] = ipad[1]; - digest[2] = ipad[2]; - digest[3] = ipad[3]; - digest[4] = ipad[4]; - digest[5] = ipad[5]; - digest[6] = ipad[6]; - digest[7] = ipad[7]; - - sha256_transform_vector (w0, w1, w2, w3, digest); - - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; - w1[1] = digest[5]; - w1[2] = digest[6]; - w1[3] = digest[7]; - w2[0] = 0x80000000; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = (64 + 32) * 8; - - digest[0] = opad[0]; - digest[1] = opad[1]; - digest[2] = opad[2]; - digest[3] = opad[3]; - digest[4] = opad[4]; - digest[5] = opad[5]; - digest[6] = opad[6]; - digest[7] = opad[7]; - - sha256_transform_vector (w0, w1, w2, w3, digest); -} - -KERNEL_FQ void m26620_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= GID_CNT) return; - - sha256_hmac_ctx_t sha256_hmac_ctx; - - sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); - - tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; - tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; - tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; - tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; - tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; - tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; - tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; - tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; - - tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; - tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; - tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; - tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; - tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; - tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; - tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; - tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; - - sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); - - for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) - { - sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; - - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - w0[0] = j; - w0[1] = 0; - w0[2] = 0; - w0[3] = 0; - w1[0] = 0; - w1[1] = 0; - w1[2] = 0; - w1[3] = 0; - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); - - sha256_hmac_final (&sha256_hmac_ctx2); - - tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; - tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; - tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; - tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; - tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; - tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; - tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; - tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; - - tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; - tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; - tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; - tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; - tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; - tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; - tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; - tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; - } -} - -KERNEL_FQ void m26620_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - const u64 gid = get_global_id (0); - - if ((gid * VECT_SIZE) >= GID_CNT) return; - - u32x ipad[8]; - u32x opad[8]; - - ipad[0] = packv (tmps, ipad, gid, 0); - ipad[1] = packv (tmps, ipad, gid, 1); - ipad[2] = packv (tmps, ipad, gid, 2); - ipad[3] = packv (tmps, ipad, gid, 3); - ipad[4] = packv (tmps, ipad, gid, 4); - ipad[5] = packv (tmps, ipad, gid, 5); - ipad[6] = packv (tmps, ipad, gid, 6); - ipad[7] = packv (tmps, ipad, gid, 7); - - opad[0] = packv (tmps, opad, gid, 0); - opad[1] = packv (tmps, opad, gid, 1); - opad[2] = packv (tmps, opad, gid, 2); - opad[3] = packv (tmps, opad, gid, 3); - opad[4] = packv (tmps, opad, gid, 4); - opad[5] = packv (tmps, opad, gid, 5); - opad[6] = packv (tmps, opad, gid, 6); - opad[7] = packv (tmps, opad, gid, 7); - - for (u32 i = 0; i < 8; i += 8) - { - u32x dgst[8]; - u32x out[8]; - - dgst[0] = packv (tmps, dgst, gid, i + 0); - dgst[1] = packv (tmps, dgst, gid, i + 1); - dgst[2] = packv (tmps, dgst, gid, i + 2); - dgst[3] = packv (tmps, dgst, gid, i + 3); - dgst[4] = packv (tmps, dgst, gid, i + 4); - dgst[5] = packv (tmps, dgst, gid, i + 5); - dgst[6] = packv (tmps, dgst, gid, i + 6); - dgst[7] = packv (tmps, dgst, gid, i + 7); - - out[0] = packv (tmps, out, gid, i + 0); - out[1] = packv (tmps, out, gid, i + 1); - out[2] = packv (tmps, out, gid, i + 2); - out[3] = packv (tmps, out, gid, i + 3); - out[4] = packv (tmps, out, gid, i + 4); - out[5] = packv (tmps, out, gid, i + 5); - out[6] = packv (tmps, out, gid, i + 6); - out[7] = packv (tmps, out, gid, i + 7); - - for (u32 j = 0; j < LOOP_CNT; j++) - { - u32x w0[4]; - u32x w1[4]; - u32x w2[4]; - u32x w3[4]; - - w0[0] = dgst[0]; - w0[1] = dgst[1]; - w0[2] = dgst[2]; - w0[3] = dgst[3]; - w1[0] = dgst[4]; - w1[1] = dgst[5]; - w1[2] = dgst[6]; - w1[3] = dgst[7]; - w2[0] = 0x80000000; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = (64 + 32) * 8; - - hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); - - out[0] ^= dgst[0]; - out[1] ^= dgst[1]; - out[2] ^= dgst[2]; - out[3] ^= dgst[3]; - out[4] ^= dgst[4]; - out[5] ^= dgst[5]; - out[6] ^= dgst[6]; - out[7] ^= dgst[7]; - } - - unpackv (tmps, dgst, gid, i + 0, dgst[0]); - unpackv (tmps, dgst, gid, i + 1, dgst[1]); - unpackv (tmps, dgst, gid, i + 2, dgst[2]); - unpackv (tmps, dgst, gid, i + 3, dgst[3]); - unpackv (tmps, dgst, gid, i + 4, dgst[4]); - unpackv (tmps, dgst, gid, i + 5, dgst[5]); - unpackv (tmps, dgst, gid, i + 6, dgst[6]); - unpackv (tmps, dgst, gid, i + 7, dgst[7]); - - unpackv (tmps, out, gid, i + 0, out[0]); - unpackv (tmps, out, gid, i + 1, out[1]); - unpackv (tmps, out, gid, i + 2, out[2]); - unpackv (tmps, out, gid, i + 3, out[3]); - unpackv (tmps, out, gid, i + 4, out[4]); - unpackv (tmps, out, gid, i + 5, out[5]); - unpackv (tmps, out, gid, i + 6, out[6]); - unpackv (tmps, out, gid, i + 7, out[7]); - } -} - -KERNEL_FQ void m26620_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= GID_CNT) return; - - // keys - - u32 ukey[8]; - - ukey[0] = tmps[gid].out[0]; - ukey[1] = tmps[gid].out[1]; - ukey[2] = tmps[gid].out[2]; - ukey[3] = tmps[gid].out[3]; - ukey[4] = tmps[gid].out[4]; - ukey[5] = tmps[gid].out[5]; - ukey[6] = tmps[gid].out[6]; - ukey[7] = tmps[gid].out[7]; - - u32 key_len = 32 * 8; - - u32 key[60] = { 0 }; - u32 subKey[4] = { 0 }; - - AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); - - // iv - - u32 iv[4]; - - iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0]; - iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1]; - iv[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2]; - iv[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]; - - const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len; - - u32 J0[4] = { 0 }; - - AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0); - - // ct - - u32 T[4] = { 0 }; - u32 S[4] = { 0 }; - - u32 S_len = 16; - u32 aad_buf[4] = { 0 }; - u32 aad_len = 0; - - AES_GCM_GHASH_GLOBAL (subKey, aad_buf, aad_len, esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf, esalt_bufs[DIGESTS_OFFSET_HOST].ct_len, S); - - AES_GCM_GCTR (key, J0, S, S_len, T, s_te0, s_te1, s_te2, s_te3, s_te4); - - /* compare tag */ - - const u32 r0 = T[0]; - const u32 r1 = T[1]; - const u32 r2 = T[2]; - const u32 r3 = T[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif -} diff --git a/OpenCL/m26630-pure.cl b/OpenCL/m26630-pure.cl deleted file mode 100644 index 39727b730..000000000 --- a/OpenCL/m26630-pure.cl +++ /dev/null @@ -1,413 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#define NEW_SIMD_CODE - -#ifdef KERNEL_STATIC -#include M2S(INCLUDE_PATH/inc_vendor.h) -#include M2S(INCLUDE_PATH/inc_types.h) -#include M2S(INCLUDE_PATH/inc_platform.cl) -#include M2S(INCLUDE_PATH/inc_common.cl) -#include M2S(INCLUDE_PATH/inc_simd.cl) -#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) -#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) -#include M2S(INCLUDE_PATH/inc_cipher_aes-gcm.cl) -#endif - -#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) -#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha256_aes_gcm -{ - u32 salt_buf[64]; - u32 iv_buf[4]; - u32 iv_len; - u32 ct_buf[16]; - u32 ct_len; - -} pbkdf2_sha256_aes_gcm_t; - -DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) -{ - digest[0] = ipad[0]; - digest[1] = ipad[1]; - digest[2] = ipad[2]; - digest[3] = ipad[3]; - digest[4] = ipad[4]; - digest[5] = ipad[5]; - digest[6] = ipad[6]; - digest[7] = ipad[7]; - - sha256_transform_vector (w0, w1, w2, w3, digest); - - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; - w1[1] = digest[5]; - w1[2] = digest[6]; - w1[3] = digest[7]; - w2[0] = 0x80000000; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = (64 + 32) * 8; - - digest[0] = opad[0]; - digest[1] = opad[1]; - digest[2] = opad[2]; - digest[3] = opad[3]; - digest[4] = opad[4]; - digest[5] = opad[5]; - digest[6] = opad[6]; - digest[7] = opad[7]; - - sha256_transform_vector (w0, w1, w2, w3, digest); -} - -KERNEL_FQ void m26630_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= GID_CNT) return; - - sha256_hmac_ctx_t sha256_hmac_ctx; - - sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); - - tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; - tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; - tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; - tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; - tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; - tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; - tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; - tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; - - tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; - tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; - tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; - tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; - tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; - tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; - tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; - tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; - - sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); - - for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) - { - sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; - - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - w0[0] = j; - w0[1] = 0; - w0[2] = 0; - w0[3] = 0; - w1[0] = 0; - w1[1] = 0; - w1[2] = 0; - w1[3] = 0; - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); - - sha256_hmac_final (&sha256_hmac_ctx2); - - tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; - tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; - tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; - tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; - tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; - tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; - tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; - tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; - - tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; - tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; - tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; - tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; - tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; - tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; - tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; - tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; - } -} - -KERNEL_FQ void m26630_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - const u64 gid = get_global_id (0); - - if ((gid * VECT_SIZE) >= GID_CNT) return; - - u32x ipad[8]; - u32x opad[8]; - - ipad[0] = packv (tmps, ipad, gid, 0); - ipad[1] = packv (tmps, ipad, gid, 1); - ipad[2] = packv (tmps, ipad, gid, 2); - ipad[3] = packv (tmps, ipad, gid, 3); - ipad[4] = packv (tmps, ipad, gid, 4); - ipad[5] = packv (tmps, ipad, gid, 5); - ipad[6] = packv (tmps, ipad, gid, 6); - ipad[7] = packv (tmps, ipad, gid, 7); - - opad[0] = packv (tmps, opad, gid, 0); - opad[1] = packv (tmps, opad, gid, 1); - opad[2] = packv (tmps, opad, gid, 2); - opad[3] = packv (tmps, opad, gid, 3); - opad[4] = packv (tmps, opad, gid, 4); - opad[5] = packv (tmps, opad, gid, 5); - opad[6] = packv (tmps, opad, gid, 6); - opad[7] = packv (tmps, opad, gid, 7); - - for (u32 i = 0; i < 8; i += 8) - { - u32x dgst[8]; - u32x out[8]; - - dgst[0] = packv (tmps, dgst, gid, i + 0); - dgst[1] = packv (tmps, dgst, gid, i + 1); - dgst[2] = packv (tmps, dgst, gid, i + 2); - dgst[3] = packv (tmps, dgst, gid, i + 3); - dgst[4] = packv (tmps, dgst, gid, i + 4); - dgst[5] = packv (tmps, dgst, gid, i + 5); - dgst[6] = packv (tmps, dgst, gid, i + 6); - dgst[7] = packv (tmps, dgst, gid, i + 7); - - out[0] = packv (tmps, out, gid, i + 0); - out[1] = packv (tmps, out, gid, i + 1); - out[2] = packv (tmps, out, gid, i + 2); - out[3] = packv (tmps, out, gid, i + 3); - out[4] = packv (tmps, out, gid, i + 4); - out[5] = packv (tmps, out, gid, i + 5); - out[6] = packv (tmps, out, gid, i + 6); - out[7] = packv (tmps, out, gid, i + 7); - - for (u32 j = 0; j < LOOP_CNT; j++) - { - u32x w0[4]; - u32x w1[4]; - u32x w2[4]; - u32x w3[4]; - - w0[0] = dgst[0]; - w0[1] = dgst[1]; - w0[2] = dgst[2]; - w0[3] = dgst[3]; - w1[0] = dgst[4]; - w1[1] = dgst[5]; - w1[2] = dgst[6]; - w1[3] = dgst[7]; - w2[0] = 0x80000000; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = (64 + 32) * 8; - - hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); - - out[0] ^= dgst[0]; - out[1] ^= dgst[1]; - out[2] ^= dgst[2]; - out[3] ^= dgst[3]; - out[4] ^= dgst[4]; - out[5] ^= dgst[5]; - out[6] ^= dgst[6]; - out[7] ^= dgst[7]; - } - - unpackv (tmps, dgst, gid, i + 0, dgst[0]); - unpackv (tmps, dgst, gid, i + 1, dgst[1]); - unpackv (tmps, dgst, gid, i + 2, dgst[2]); - unpackv (tmps, dgst, gid, i + 3, dgst[3]); - unpackv (tmps, dgst, gid, i + 4, dgst[4]); - unpackv (tmps, dgst, gid, i + 5, dgst[5]); - unpackv (tmps, dgst, gid, i + 6, dgst[6]); - unpackv (tmps, dgst, gid, i + 7, dgst[7]); - - unpackv (tmps, out, gid, i + 0, out[0]); - unpackv (tmps, out, gid, i + 1, out[1]); - unpackv (tmps, out, gid, i + 2, out[2]); - unpackv (tmps, out, gid, i + 3, out[3]); - unpackv (tmps, out, gid, i + 4, out[4]); - unpackv (tmps, out, gid, i + 5, out[5]); - unpackv (tmps, out, gid, i + 6, out[6]); - unpackv (tmps, out, gid, i + 7, out[7]); - } -} - -KERNEL_FQ void m26630_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) -{ - const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= GID_CNT) return; - - const u32 digest_pos = LOOP_POS; - - const u32 digest_cur = DIGESTS_OFFSET_HOST + digest_pos; - - GLOBAL_AS const pbkdf2_sha256_aes_gcm_t *pbkdf2_sha256_aes_gcm = &esalt_bufs[digest_cur]; - - // keys - - u32 ukey[8]; - - ukey[0] = tmps[gid].out[0]; - ukey[1] = tmps[gid].out[1]; - ukey[2] = tmps[gid].out[2]; - ukey[3] = tmps[gid].out[3]; - ukey[4] = tmps[gid].out[4]; - ukey[5] = tmps[gid].out[5]; - ukey[6] = tmps[gid].out[6]; - ukey[7] = tmps[gid].out[7]; - - u32 key_len = 32 * 8; - - u32 key[60] = { 0 }; - u32 subKey[4] = { 0 }; - - AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); - - // iv - - u32 iv[4]; - - iv[0] = pbkdf2_sha256_aes_gcm->iv_buf[0]; - iv[1] = pbkdf2_sha256_aes_gcm->iv_buf[1]; - iv[2] = pbkdf2_sha256_aes_gcm->iv_buf[2]; - iv[3] = pbkdf2_sha256_aes_gcm->iv_buf[3]; - - const u32 iv_len = pbkdf2_sha256_aes_gcm->iv_len; - - u32 J0[4] = { 0 }; - - AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0); - - u32 ct[8]; - - ct[0] = pbkdf2_sha256_aes_gcm->ct_buf[0]; // first block of ciphertext - ct[1] = pbkdf2_sha256_aes_gcm->ct_buf[1]; - ct[2] = pbkdf2_sha256_aes_gcm->ct_buf[2]; - ct[3] = pbkdf2_sha256_aes_gcm->ct_buf[3]; - ct[4] = pbkdf2_sha256_aes_gcm->ct_buf[4]; // second block of ciphertext - ct[5] = pbkdf2_sha256_aes_gcm->ct_buf[5]; - ct[6] = pbkdf2_sha256_aes_gcm->ct_buf[6]; - ct[7] = pbkdf2_sha256_aes_gcm->ct_buf[7]; - - u32 pt[8] = { 0 }; - - AES_GCM_decrypt (key, J0, ct, 32, pt, s_te0, s_te1, s_te2, s_te3, s_te4); - - const int correct = is_valid_printable_32 (pt[0]) - + is_valid_printable_32 (pt[1]) - + is_valid_printable_32 (pt[2]) - + is_valid_printable_32 (pt[3]) - + is_valid_printable_32 (pt[4]) - + is_valid_printable_32 (pt[5]) - + is_valid_printable_32 (pt[6]) - + is_valid_printable_32 (pt[7]); - - if (correct != 8) return; - - /* - const int pt_len = 28; // not using 32 byte but 28 because our UTF8 allows up to 4 byte per character and since we decrypt 32 byte - // only we can't guarantee it is not in the middle of a UTF8 byte stream at that point - - if (hc_enc_scan (pt, pt_len)) - { - hc_enc_t hc_enc; - - hc_enc_init (&hc_enc); - - while (hc_enc_has_next (&hc_enc, pt_len)) - { - u32 enc_buf[16] = { 0 }; - - const int enc_len = hc_enc_next (&hc_enc, pt, pt_len, 32, enc_buf, sizeof (enc_buf)); - - if (enc_len == -1) return; - } - } - */ - - const u32 r0 = ct[0]; - const u32 r1 = ct[1]; - const u32 r2 = ct[2]; - const u32 r3 = ct[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif -} From 9a14c99bb129fb6e67f4b5566b0d47a10c826499 Mon Sep 17 00:00:00 2001 From: its5Q Date: Sat, 24 Feb 2024 16:42:08 +1000 Subject: [PATCH 020/357] Update metamask2hashcat to use new format and add test vault JSON --- tools/2hashcat_tests/metamask2hashcat.withrounds.json | 1 + tools/metamask2hashcat.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 tools/2hashcat_tests/metamask2hashcat.withrounds.json diff --git a/tools/2hashcat_tests/metamask2hashcat.withrounds.json b/tools/2hashcat_tests/metamask2hashcat.withrounds.json new file mode 100644 index 000000000..b865647fd --- /dev/null +++ b/tools/2hashcat_tests/metamask2hashcat.withrounds.json @@ -0,0 +1 @@ +{"data":"G2Qsp8BtQNz9E1vFlSebykcGkps5iJ53fBjJV8GIE7eolAQpz5m25MTZv0b0t2tpqXvfgEYKYZKsoLvuWWRHqj2ommt+U0l6fEGPY6lTn5PYzDtMKNpPWHKCIS/QYhwEA9/X5RtyIwDL6VqcRp6owV+/icmRlQa+TI5buHWZ+99Z1kBbpTDVYLBwhMRsODM1vYizQDg0vFIo3cQDtpRWUqpAKXhFcpgRD+9grS3pP/zdlIUn//87DZ3ue6Sn6WFOe08EvuY8sYZqTiN3GxcfESOltNbZJGcedMubt/jGsk+qIwUWC/f456UgeX9DN7i2pQBBI+L7qkY5v1WT5Y0i8uho1c2M2G8M9miO8HSm/j4bpMN1J6lPtjFhfAzEPS1go1w2vTmOtr1y+2A4M6HEOcxIrPJ8lUUH9pcN7Xpd+u/tQv8BYFxd6RlNYKLyA6OChbF+TD5Zz6oFZQtkprXqzZUFOlxeWJ373kHMISZtXOx44YGaiT2178fXgHFXavw=","iv":"N1aDRjt2ZD5x15Q1X9zVUw==","keyMetadata":{"algorithm":"PBKDF2","params":{"iterations":600000}},"salt":"MBdUsmTcBHGCASECYr3gmD8XaJROwjhOegSWweCFhco="} diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py index 823f528b6..319889c60 100644 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -58,6 +58,7 @@ def metamask_parser(file, shortdata): iter_count = j['keyMetadata']['params']['iterations'] except KeyError: iter_count = 10_000 + if((len(j['data']) > 3000) or shortdata): data_bin = base64.b64decode(j['data']) # TODO limit data to 16 bytes, we only check the first block of data, so we don't need more data. @@ -66,12 +67,12 @@ def metamask_parser(file, shortdata): j['data'] = base64.b64encode(data_bin[0:64]).decode("ascii") if iter_count != 10000: - print('$metamask-short$' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + print('$metamask-short$rounds=' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: print('$metamask-short$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: if iter_count != 10000: - print('$metamask$' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + print('$metamask$rounds=' + str(iter_count) + '$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: print('$metamask$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) From 1685f11b87ec7454028fb2d0038a080aa95e9cff Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 20 Nov 2023 18:25:11 -0800 Subject: [PATCH 021/357] replace index with strchr The former is deprecated and unavailable if POSIX_C_SOUCE==200811L. Signed-off-by: Rosen Penev --- src/backend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..c2e3e0a21 100644 --- a/src/backend.c +++ b/src/backend.c @@ -7472,11 +7472,11 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #if defined (__APPLE__) - char *start130 = index (device_param->opencl_driver_version, '('); - char *stop130 = index (device_param->opencl_driver_version, ')'); + char *start130 = strchr (device_param->opencl_driver_version, '('); + char *stop130 = strchr (device_param->opencl_driver_version, ')'); - char *start131 = index (opencl_platform_version, '('); - char *stop131 = index (opencl_platform_version, ')'); + char *start131 = strchr (opencl_platform_version, '('); + char *stop131 = strchr (opencl_platform_version, ')'); // either none or one of these have a date string From 6aaf0f3ac424ec0037a45132393491f08010cf95 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 8 Dec 2023 16:47:24 -0800 Subject: [PATCH 022/357] Fix compilation on newer FreeBSD Apparently qsort_r is a macro now. Check for it. Signed-off-by: Rosen Penev --- include/sort_r.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sort_r.h b/include/sort_r.h index 79bd8ab65..f9fb31360 100644 --- a/include/sort_r.h +++ b/include/sort_r.h @@ -138,7 +138,7 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w, /* Declare structs and functions */ - #if defined _SORT_R_BSD + #if defined _SORT_R_BSD && !defined(qsort_r) /* Ensure qsort_r is defined */ extern void qsort_r(void *base, size_t nel, size_t width, void *thunk, From cdd92f6de6cf8a314b0d4bf8aefcde78251ef4e3 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 8 Dec 2023 17:16:07 -0800 Subject: [PATCH 023/357] Fix MinGW printf formats Based on various compilation flags, MinGW uses either gnu_printf or printf (really ms_printf) internally which confuses the compiler when encountering gnu formats. OTOH, clang under MinGW does not support gnu_printf. Just use the macro to handle this mess. Also remove macro that was originally used to work around this. It's wrong and should not be used. Signed-off-by: Rosen Penev --- include/event.h | 20 ++++++++++++-------- include/logfile.h | 6 +++++- include/shared.h | 7 ++++++- src/Makefile | 1 - src/event.c | 6 +++++- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/include/event.h b/include/event.h index fca7eec55..4f9cfa0a7 100644 --- a/include/event.h +++ b/include/event.h @@ -14,15 +14,19 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons #define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0) #define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len)) -__attribute__ ((format (printf, 2, 3))) size_t event_log_advice_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +#ifndef __MINGW_PRINTF_FORMAT +#define __MINGW_PRINTF_FORMAT printf +#endif -__attribute__ ((format (printf, 2, 3))) size_t event_log_advice (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_advice_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); + +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_advice (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); int event_ctx_init (hashcat_ctx_t *hashcat_ctx); void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/logfile.h b/include/logfile.h index b3f3fb8d1..f154f6bb5 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -34,9 +34,13 @@ #define logfile_top_string(var) logfile_top_var_string (#var, (var)) #define logfile_sub_string(var) logfile_sub_var_string (#var, (var)) +#ifndef __MINGW_PRINTF_FORMAT +#define __MINGW_PRINTF_FORMAT printf +#endif + void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx); void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx); -void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))); int logfile_init (hashcat_ctx_t *hashcat_ctx); void logfile_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/shared.h b/include/shared.h index f1660c58e..9bd47f18a 100644 --- a/include/shared.h +++ b/include/shared.h @@ -7,6 +7,7 @@ #define HC_SHARED_H #include +#include #include #include #include @@ -24,6 +25,10 @@ #include #endif +#ifndef __MINGW_PRINTF_FORMAT +#define __MINGW_PRINTF_FORMAT printf +#endif + int sort_by_string_sized (const void *p1, const void *p2); int sort_by_stringptr (const void *p1, const void *p2); @@ -44,7 +49,7 @@ char *filename_from_filepath (char *filepath); void naive_replace (char *s, const char key_char, const char replace_char); void naive_escape (char *s, size_t s_max, const char key_char, const char escape_char); -__attribute__ ((format (printf, 2, 3))) int hc_asprintf (char **strp, const char *fmt, ...); +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3))) int hc_asprintf (char **strp, const char *fmt, ...); void setup_environment_variables (const folder_config_t *folder_config); void setup_umask (void); diff --git a/src/Makefile b/src/Makefile index 1cd440645..a7eb7b985 100644 --- a/src/Makefile +++ b/src/Makefile @@ -750,7 +750,6 @@ CFLAGS_CROSS_WIN := $(CFLAGS) CFLAGS_CROSS_WIN += -fPIC CFLAGS_CROSS_WIN += -I$(WIN_ICONV)/include/ CFLAGS_CROSS_WIN += -DWITH_HWMON -CFLAGS_CROSS_WIN += -D__USE_MINGW_ANSI_STDIO=0 LFLAGS_CROSS_LINUX := $(LFLAGS) LFLAGS_CROSS_LINUX += -lpthread diff --git a/src/event.c b/src/event.c index ec3f3569f..d8ce7a44d 100644 --- a/src/event.c +++ b/src/event.c @@ -8,6 +8,10 @@ #include "thread.h" #include "event.h" +#ifndef __MINGW_PRINTF_FORMAT +#define __MINGW_PRINTF_FORMAT printf +#endif + void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { event_ctx_t *event_ctx = hashcat_ctx->event_ctx; @@ -62,7 +66,7 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons } } -__attribute__ ((format (printf, 1, 0))) +__attribute__ ((format (__MINGW_PRINTF_FORMAT, 1, 0))) static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) { size_t length; From 16b249c44f3eabe252f1fd159b14d5fc5ccd041e Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Thu, 29 Feb 2024 23:53:11 +0000 Subject: [PATCH 024/357] Make skipped device warning respect --quiet The other usual device information does not show when using --quiet, only the skipped warning does, making it a little out of place. Old: ``` > ./hashcat -m 99999 abcdef -a 3 abcdef --quiet The device #2 specifically listed was skipped because it is an alias of device #1 abcdef:abcdef > ``` New: ``` > ./hashcat -m 99999 abcdef -a 3 abcdef --quiet abcdef:abcdef ``` --- src/backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..9fe1e833f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -90,6 +90,7 @@ static bool is_same_device (const hc_device_param_t *src, const hc_device_param_ static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + user_options_t *user_options = hashcat_ctx->user_options; // first identify all aliases @@ -157,7 +158,7 @@ static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) // show a warning for specifically listed devices if they are an alias - if (backend_ctx->backend_devices_filter[alias_device->device_id]) + if (backend_ctx->backend_devices_filter[alias_device->device_id] && user_options->quiet == false) { event_log_warning (hashcat_ctx, "The device #%d specifically listed was skipped because it is an alias of device #%d", alias_device->device_id + 1, backend_device->device_id + 1); event_log_warning (hashcat_ctx, NULL); From 5a817a7fee5e6a1a20b4301dd50c979ead9c1f9c Mon Sep 17 00:00:00 2001 From: Xeonacid Date: Sat, 9 Mar 2024 20:32:26 +0800 Subject: [PATCH 025/357] Fix bash completion install - `^(HASHCAT_ROOT=)` instead of `^(ROOT=)` - single quotation instead of double quotation to avoid `bash: !\1\: event not found` error --- extra/tab_completion/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/tab_completion/install b/extra/tab_completion/install index e5f3fd85a..b415be157 100755 --- a/extra/tab_completion/install +++ b/extra/tab_completion/install @@ -141,7 +141,7 @@ if [ -d "${COMPGENFOLDER}" ]; then # adjust paths to the main binaries of hashcat - sed -ri "s!^(ROOT=).*!\1\"${ROOT_PARENT}\"!" "${COMPGENTARGET}" + sed -ri 's!^(HASHCAT_ROOT=).*!\1\"${ROOT_PARENT}\"!' "${COMPGENTARGET}" # add the compgen to bashrc if not already there From d76137d44b62e9af36daf58a926c36de3ba767cc Mon Sep 17 00:00:00 2001 From: elliot <116954050+e-lliot@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:05:07 -0400 Subject: [PATCH 026/357] Update module_20711.c --- src/modules/module_20711.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/module_20711.c b/src/modules/module_20711.c index 1103ddf7b..7a623788b 100644 --- a/src/modules/module_20711.c +++ b/src/modules/module_20711.c @@ -82,8 +82,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 16; - token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.len_min[1] = 16; + token.len_max[1] = 20; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_OPTIONAL_ROUNDS; token.sep[2] = '$'; token.len[2] = 64; From 4cb22387b3f76b10e3106571c88fbffcf13f59bc Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Fri, 29 Mar 2024 03:05:33 +0000 Subject: [PATCH 027/357] Added hash-mode: md5(sha1(md5($pass))) See: https://github.com/hashcat/hashcat/issues/3974 --- OpenCL/m32800_a0-optimized.cl | 870 +++++++++++++++++++++++ OpenCL/m32800_a0-pure.cl | 307 +++++++++ OpenCL/m32800_a1-optimized.cl | 978 ++++++++++++++++++++++++++ OpenCL/m32800_a1-pure.cl | 301 ++++++++ OpenCL/m32800_a3-optimized.cl | 1222 +++++++++++++++++++++++++++++++++ OpenCL/m32800_a3-pure.cl | 327 +++++++++ docs/changes.txt | 1 + docs/readme.txt | 1 + src/modules/module_32800.c | 199 ++++++ tools/test_modules/m32800.pm | 43 ++ 10 files changed, 4249 insertions(+) create mode 100644 OpenCL/m32800_a0-optimized.cl create mode 100644 OpenCL/m32800_a0-pure.cl create mode 100644 OpenCL/m32800_a1-optimized.cl create mode 100644 OpenCL/m32800_a1-pure.cl create mode 100644 OpenCL/m32800_a3-optimized.cl create mode 100644 OpenCL/m32800_a3-pure.cl create mode 100644 src/modules/module_32800.c create mode 100644 tools/test_modules/m32800.pm diff --git a/OpenCL/m32800_a0-optimized.cl b/OpenCL/m32800_a0-optimized.cl new file mode 100644 index 000000000..95d910e2e --- /dev/null +++ b/OpenCL/m32800_a0-optimized.cl @@ -0,0 +1,870 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32800_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + u32x w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + u32x w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + u32x w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + u32x w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + u32x w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + u32x w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + u32x w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + u32x w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + u32x w8_t = 0x80000000; + u32x w9_t = 0; + u32x wa_t = 0; + u32x wb_t = 0; + u32x wc_t = 0; + u32x wd_t = 0; + u32x we_t = 0; + u32x wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32800_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32800_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32800_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + u32x w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + u32x w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + u32x w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + u32x w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + u32x w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + u32x w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + u32x w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + u32x w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + u32x w8_t = 0x80000000; + u32x w9_t = 0; + u32x wa_t = 0; + u32x wb_t = 0; + u32x wc_t = 0; + u32x wd_t = 0; + u32x we_t = 0; + u32x wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32800_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32800_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m32800_a0-pure.cl b/OpenCL/m32800_a0-pure.cl new file mode 100644 index 000000000..df2c7bec0 --- /dev/null +++ b/OpenCL/m32800_a0-pure.cl @@ -0,0 +1,307 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32800_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32800_a1-optimized.cl b/OpenCL/m32800_a1-optimized.cl new file mode 100644 index 000000000..13df80a28 --- /dev/null +++ b/OpenCL/m32800_a1-optimized.cl @@ -0,0 +1,978 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32800_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + u32x w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + u32x w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + u32x w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + u32x w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + u32x w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + u32x w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + u32x w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + u32x w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + u32x w8_t = 0x80000000; + u32x w9_t = 0; + u32x wa_t = 0; + u32x wb_t = 0; + u32x wc_t = 0; + u32x wd_t = 0; + u32x we_t = 0; + u32x wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32800_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32800_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32800_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + u32x w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + u32x w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + u32x w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + u32x w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + u32x w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + u32x w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + u32x w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + u32x w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + u32x w8_t = 0x80000000; + u32x w9_t = 0; + u32x wa_t = 0; + u32x wb_t = 0; + u32x wc_t = 0; + u32x wd_t = 0; + u32x we_t = 0; + u32x wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32800_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32800_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m32800_a1-pure.cl b/OpenCL/m32800_a1-pure.cl new file mode 100644 index 000000000..685d6d895 --- /dev/null +++ b/OpenCL/m32800_a1-pure.cl @@ -0,0 +1,301 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32800_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { +md5_ctx_t ctx0 = ctx; + + md5_update_global (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx0 = ctx; + + md5_update_global (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32800_a3-optimized.cl b/OpenCL/m32800_a3-optimized.cl new file mode 100644 index 000000000..d2e6bf212 --- /dev/null +++ b/OpenCL/m32800_a3-optimized.cl @@ -0,0 +1,1222 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +DECLSPEC void m32800m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc, LOCAL_AS u32 *b_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = w3[2]; + u32x wf_t = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + w8_t = 0x80000000; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m32800s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc, LOCAL_AS u32 *b_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = w3[2]; + u32x wf_t = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + u32x e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /* + * sha1 + */ + + w0_t = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + w8_t = 0x80000000; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 32 * 8; + + a = SHA1M_A; + b = SHA1M_B; + c = SHA1M_C; + d = SHA1M_D; + e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + t = 0; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32800_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} + +KERNEL_FQ void m32800_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} + +KERNEL_FQ void m32800_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} + +KERNEL_FQ void m32800_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} + +KERNEL_FQ void m32800_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} + +KERNEL_FQ void m32800_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc, b_bin2asc); +} diff --git a/OpenCL/m32800_a3-pure.cl b/OpenCL/m32800_a3-pure.cl new file mode 100644 index 000000000..88788548b --- /dev/null +++ b/OpenCL/m32800_a3-pure.cl @@ -0,0 +1,327 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i)]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (b_bin2asc[(i).s0], b_bin2asc[(i).s1], b_bin2asc[(i).s2], b_bin2asc[(i).s3], b_bin2asc[(i).s4], b_bin2asc[(i).s5], b_bin2asc[(i).s6], b_bin2asc[(i).s7], b_bin2asc[(i).s8], b_bin2asc[(i).s9], b_bin2asc[(i).sa], b_bin2asc[(i).sb], b_bin2asc[(i).sc], b_bin2asc[(i).sd], b_bin2asc[(i).se], b_bin2asc[(i).sf]) +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32800_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_vector_t ctx1; + + sha1_init_vector (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final_vector (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_vector_t ctx2; + + md5_init_vector (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final_vector (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc tables + */ + + LOCAL_VK u32 l_bin2asc[256]; + LOCAL_VK u32 b_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + b_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + sha1_ctx_vector_t ctx1; + + sha1_init_vector (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8_le ((a >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 0) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8_le ((a >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((a >> 16) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8_le ((b >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 0) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8_le ((b >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((b >> 16) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8_le ((c >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 0) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8_le ((c >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((c >> 16) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8_le ((d >> 8) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 0) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8_le ((d >> 24) & 255) << 0 + | uint_to_hex_lower8_le ((d >> 16) & 255) << 16; + + ctx1.len = 32; + + sha1_final_vector (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_vector_t ctx2; + + md5_init_vector (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + ctx2.w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + ctx2.w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + ctx2.len = 40; + + md5_final_vector (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..238dff35b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -45,6 +45,7 @@ - Added hash-mode: HMAC-RIPEMD160 (key = $pass) - Added hash-mode: HMAC-RIPEMD160 (key = $salt) - Added hash-mode: md5($salt1.sha1($salt2.$pass)) +- Added hash-mode: md5(sha1(md5($pass))) - Added hash-mode: md5(md5($pass.$salt)) - Added hash-mode: md5(md5($salt).md5(md5($pass))) - Added hash-mode: Domain Cached Credentials 2 (DCC2), MS Cache 2, (NT) diff --git a/docs/readme.txt b/docs/readme.txt index e5fd69f25..41950ee0f 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -96,6 +96,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - md5(md5(md5($pass).$salt1).$salt2) - md5(sha1($pass)) - md5(sha1($pass).$salt) +- md5(sha1(md5($pass))) - md5(sha1($pass).md5($pass).sha1($pass)) - md5(sha1($pass.$salt)) - md5(sha1($salt).md5($pass)) diff --git a/src/modules/module_32800.c b/src/modules/module_32800.c new file mode 100644 index 000000000..daf1e1cb9 --- /dev/null +++ b/src/modules/module_32800.c @@ -0,0 +1,199 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; +static const char *HASH_NAME = "md5(sha1(md5($pass)))"; +static const u64 KERN_TYPE = 32800; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_NOT_SALTED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_NONE; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "7b4f60b54472980e922280e225150dfa"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 1; + + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/test_modules/m32800.pm b/tools/test_modules/m32800.pm new file mode 100644 index 000000000..681459854 --- /dev/null +++ b/tools/test_modules/m32800.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 256], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex (sha1_hex (md5_hex ($word))); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; From 29b39c5b832d7dab174d2589d4c06c3974eecc28 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 2 Apr 2024 22:34:29 +0100 Subject: [PATCH 028/357] Raise Bitwarden Iteration Limit Replace old 999,999 iteration cap with a larger cap to satisfy: https://hashcat.net/forum/thread-11885.html. Unknown if there is any Bitwarden-native cap on iterations. --- src/modules/module_23400.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index 7a0e5fb95..246b32c54 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -128,13 +128,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[2] = '*'; token.len_min[2] = 1; - token.len_max[2] = 7; + token.len_max[2] = 10; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; token.len_min[3] = 1; - token.len_max[3] = 7; + token.len_max[3] = 10; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; @@ -166,15 +166,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10); - if (iter1 < 1) return (PARSER_SALT_ITERATION); - if (iter1 > 999999) return (PARSER_SALT_ITERATION); + if (iter1 < 1) return (PARSER_SALT_ITERATION); + if (iter1 > 10^10) return (PARSER_SALT_ITERATION); salt->salt_iter = iter1 - 1; const u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10); - if (iter2 < 1) return (PARSER_SALT_ITERATION); - if (iter2 > 999999) return (PARSER_SALT_ITERATION); + if (iter2 < 1) return (PARSER_SALT_ITERATION); + if (iter2 > 10^10) return (PARSER_SALT_ITERATION); salt->salt_iter2 = iter2 - 1; From fcfbc328d350d5464cc5f49758b4d69a7f89d2b2 Mon Sep 17 00:00:00 2001 From: philsmd Date: Tue, 7 May 2024 12:15:54 +0200 Subject: [PATCH 029/357] fix whitespace/indentation --- OpenCL/inc_cipher_cast.cl | 1257 ++++++++++++++++++------------------ OpenCL/inc_cipher_cast.h | 54 +- OpenCL/m31900-pure.cl | 8 +- src/modules/module_31500.c | 2 +- src/modules/module_31600.c | 2 +- 5 files changed, 663 insertions(+), 660 deletions(-) diff --git a/OpenCL/inc_cipher_cast.cl b/OpenCL/inc_cipher_cast.cl index e2c5a6fb1..77758d057 100644 --- a/OpenCL/inc_cipher_cast.cl +++ b/OpenCL/inc_cipher_cast.cl @@ -24,660 +24,663 @@ /* CAST S-boxes */ CONSTANT_VK u32 S[8][256] = { - { - 0x30FB40D4UL, 0x9FA0FF0BUL, 0x6BECCD2FUL, 0x3F258C7AUL, - 0x1E213F2FUL, 0x9C004DD3UL, 0x6003E540UL, 0xCF9FC949UL, - 0xBFD4AF27UL, 0x88BBBDB5UL, 0xE2034090UL, 0x98D09675UL, - 0x6E63A0E0UL, 0x15C361D2UL, 0xC2E7661DUL, 0x22D4FF8EUL, - 0x28683B6FUL, 0xC07FD059UL, 0xFF2379C8UL, 0x775F50E2UL, - 0x43C340D3UL, 0xDF2F8656UL, 0x887CA41AUL, 0xA2D2BD2DUL, - 0xA1C9E0D6UL, 0x346C4819UL, 0x61B76D87UL, 0x22540F2FUL, - 0x2ABE32E1UL, 0xAA54166BUL, 0x22568E3AUL, 0xA2D341D0UL, - 0x66DB40C8UL, 0xA784392FUL, 0x004DFF2FUL, 0x2DB9D2DEUL, - 0x97943FACUL, 0x4A97C1D8UL, 0x527644B7UL, 0xB5F437A7UL, - 0xB82CBAEFUL, 0xD751D159UL, 0x6FF7F0EDUL, 0x5A097A1FUL, - 0x827B68D0UL, 0x90ECF52EUL, 0x22B0C054UL, 0xBC8E5935UL, - 0x4B6D2F7FUL, 0x50BB64A2UL, 0xD2664910UL, 0xBEE5812DUL, - 0xB7332290UL, 0xE93B159FUL, 0xB48EE411UL, 0x4BFF345DUL, - 0xFD45C240UL, 0xAD31973FUL, 0xC4F6D02EUL, 0x55FC8165UL, - 0xD5B1CAADUL, 0xA1AC2DAEUL, 0xA2D4B76DUL, 0xC19B0C50UL, - 0x882240F2UL, 0x0C6E4F38UL, 0xA4E4BFD7UL, 0x4F5BA272UL, - 0x564C1D2FUL, 0xC59C5319UL, 0xB949E354UL, 0xB04669FEUL, - 0xB1B6AB8AUL, 0xC71358DDUL, 0x6385C545UL, 0x110F935DUL, - 0x57538AD5UL, 0x6A390493UL, 0xE63D37E0UL, 0x2A54F6B3UL, - 0x3A787D5FUL, 0x6276A0B5UL, 0x19A6FCDFUL, 0x7A42206AUL, - 0x29F9D4D5UL, 0xF61B1891UL, 0xBB72275EUL, 0xAA508167UL, - 0x38901091UL, 0xC6B505EBUL, 0x84C7CB8CUL, 0x2AD75A0FUL, - 0x874A1427UL, 0xA2D1936BUL, 0x2AD286AFUL, 0xAA56D291UL, - 0xD7894360UL, 0x425C750DUL, 0x93B39E26UL, 0x187184C9UL, - 0x6C00B32DUL, 0x73E2BB14UL, 0xA0BEBC3CUL, 0x54623779UL, - 0x64459EABUL, 0x3F328B82UL, 0x7718CF82UL, 0x59A2CEA6UL, - 0x04EE002EUL, 0x89FE78E6UL, 0x3FAB0950UL, 0x325FF6C2UL, - 0x81383F05UL, 0x6963C5C8UL, 0x76CB5AD6UL, 0xD49974C9UL, - 0xCA180DCFUL, 0x380782D5UL, 0xC7FA5CF6UL, 0x8AC31511UL, - 0x35E79E13UL, 0x47DA91D0UL, 0xF40F9086UL, 0xA7E2419EUL, - 0x31366241UL, 0x051EF495UL, 0xAA573B04UL, 0x4A805D8DUL, - 0x548300D0UL, 0x00322A3CUL, 0xBF64CDDFUL, 0xBA57A68EUL, - 0x75C6372BUL, 0x50AFD341UL, 0xA7C13275UL, 0x915A0BF5UL, - 0x6B54BFABUL, 0x2B0B1426UL, 0xAB4CC9D7UL, 0x449CCD82UL, - 0xF7FBF265UL, 0xAB85C5F3UL, 0x1B55DB94UL, 0xAAD4E324UL, - 0xCFA4BD3FUL, 0x2DEAA3E2UL, 0x9E204D02UL, 0xC8BD25ACUL, - 0xEADF55B3UL, 0xD5BD9E98UL, 0xE31231B2UL, 0x2AD5AD6CUL, - 0x954329DEUL, 0xADBE4528UL, 0xD8710F69UL, 0xAA51C90FUL, - 0xAA786BF6UL, 0x22513F1EUL, 0xAA51A79BUL, 0x2AD344CCUL, - 0x7B5A41F0UL, 0xD37CFBADUL, 0x1B069505UL, 0x41ECE491UL, - 0xB4C332E6UL, 0x032268D4UL, 0xC9600ACCUL, 0xCE387E6DUL, - 0xBF6BB16CUL, 0x6A70FB78UL, 0x0D03D9C9UL, 0xD4DF39DEUL, - 0xE01063DAUL, 0x4736F464UL, 0x5AD328D8UL, 0xB347CC96UL, - 0x75BB0FC3UL, 0x98511BFBUL, 0x4FFBCC35UL, 0xB58BCF6AUL, - 0xE11F0ABCUL, 0xBFC5FE4AUL, 0xA70AEC10UL, 0xAC39570AUL, - 0x3F04442FUL, 0x6188B153UL, 0xE0397A2EUL, 0x5727CB79UL, - 0x9CEB418FUL, 0x1CACD68DUL, 0x2AD37C96UL, 0x0175CB9DUL, - 0xC69DFF09UL, 0xC75B65F0UL, 0xD9DB40D8UL, 0xEC0E7779UL, - 0x4744EAD4UL, 0xB11C3274UL, 0xDD24CB9EUL, 0x7E1C54BDUL, - 0xF01144F9UL, 0xD2240EB1UL, 0x9675B3FDUL, 0xA3AC3755UL, - 0xD47C27AFUL, 0x51C85F4DUL, 0x56907596UL, 0xA5BB15E6UL, - 0x580304F0UL, 0xCA042CF1UL, 0x011A37EAUL, 0x8DBFAADBUL, - 0x35BA3E4AUL, 0x3526FFA0UL, 0xC37B4D09UL, 0xBC306ED9UL, - 0x98A52666UL, 0x5648F725UL, 0xFF5E569DUL, 0x0CED63D0UL, - 0x7C63B2CFUL, 0x700B45E1UL, 0xD5EA50F1UL, 0x85A92872UL, - 0xAF1FBDA7UL, 0xD4234870UL, 0xA7870BF3UL, 0x2D3B4D79UL, - 0x42E04198UL, 0x0CD0EDE7UL, 0x26470DB8UL, 0xF881814CUL, - 0x474D6AD7UL, 0x7C0C5E5CUL, 0xD1231959UL, 0x381B7298UL, - 0xF5D2F4DBUL, 0xAB838653UL, 0x6E2F1E23UL, 0x83719C9EUL, - 0xBD91E046UL, 0x9A56456EUL, 0xDC39200CUL, 0x20C8C571UL, - 0x962BDA1CUL, 0xE1E696FFUL, 0xB141AB08UL, 0x7CCA89B9UL, - 0x1A69E783UL, 0x02CC4843UL, 0xA2F7C579UL, 0x429EF47DUL, - 0x427B169CUL, 0x5AC9F049UL, 0xDD8F0F00UL, 0x5C8165BFUL - }, + { + 0x30FB40D4UL, 0x9FA0FF0BUL, 0x6BECCD2FUL, 0x3F258C7AUL, + 0x1E213F2FUL, 0x9C004DD3UL, 0x6003E540UL, 0xCF9FC949UL, + 0xBFD4AF27UL, 0x88BBBDB5UL, 0xE2034090UL, 0x98D09675UL, + 0x6E63A0E0UL, 0x15C361D2UL, 0xC2E7661DUL, 0x22D4FF8EUL, + 0x28683B6FUL, 0xC07FD059UL, 0xFF2379C8UL, 0x775F50E2UL, + 0x43C340D3UL, 0xDF2F8656UL, 0x887CA41AUL, 0xA2D2BD2DUL, + 0xA1C9E0D6UL, 0x346C4819UL, 0x61B76D87UL, 0x22540F2FUL, + 0x2ABE32E1UL, 0xAA54166BUL, 0x22568E3AUL, 0xA2D341D0UL, + 0x66DB40C8UL, 0xA784392FUL, 0x004DFF2FUL, 0x2DB9D2DEUL, + 0x97943FACUL, 0x4A97C1D8UL, 0x527644B7UL, 0xB5F437A7UL, + 0xB82CBAEFUL, 0xD751D159UL, 0x6FF7F0EDUL, 0x5A097A1FUL, + 0x827B68D0UL, 0x90ECF52EUL, 0x22B0C054UL, 0xBC8E5935UL, + 0x4B6D2F7FUL, 0x50BB64A2UL, 0xD2664910UL, 0xBEE5812DUL, + 0xB7332290UL, 0xE93B159FUL, 0xB48EE411UL, 0x4BFF345DUL, + 0xFD45C240UL, 0xAD31973FUL, 0xC4F6D02EUL, 0x55FC8165UL, + 0xD5B1CAADUL, 0xA1AC2DAEUL, 0xA2D4B76DUL, 0xC19B0C50UL, + 0x882240F2UL, 0x0C6E4F38UL, 0xA4E4BFD7UL, 0x4F5BA272UL, + 0x564C1D2FUL, 0xC59C5319UL, 0xB949E354UL, 0xB04669FEUL, + 0xB1B6AB8AUL, 0xC71358DDUL, 0x6385C545UL, 0x110F935DUL, + 0x57538AD5UL, 0x6A390493UL, 0xE63D37E0UL, 0x2A54F6B3UL, + 0x3A787D5FUL, 0x6276A0B5UL, 0x19A6FCDFUL, 0x7A42206AUL, + 0x29F9D4D5UL, 0xF61B1891UL, 0xBB72275EUL, 0xAA508167UL, + 0x38901091UL, 0xC6B505EBUL, 0x84C7CB8CUL, 0x2AD75A0FUL, + 0x874A1427UL, 0xA2D1936BUL, 0x2AD286AFUL, 0xAA56D291UL, + 0xD7894360UL, 0x425C750DUL, 0x93B39E26UL, 0x187184C9UL, + 0x6C00B32DUL, 0x73E2BB14UL, 0xA0BEBC3CUL, 0x54623779UL, + 0x64459EABUL, 0x3F328B82UL, 0x7718CF82UL, 0x59A2CEA6UL, + 0x04EE002EUL, 0x89FE78E6UL, 0x3FAB0950UL, 0x325FF6C2UL, + 0x81383F05UL, 0x6963C5C8UL, 0x76CB5AD6UL, 0xD49974C9UL, + 0xCA180DCFUL, 0x380782D5UL, 0xC7FA5CF6UL, 0x8AC31511UL, + 0x35E79E13UL, 0x47DA91D0UL, 0xF40F9086UL, 0xA7E2419EUL, + 0x31366241UL, 0x051EF495UL, 0xAA573B04UL, 0x4A805D8DUL, + 0x548300D0UL, 0x00322A3CUL, 0xBF64CDDFUL, 0xBA57A68EUL, + 0x75C6372BUL, 0x50AFD341UL, 0xA7C13275UL, 0x915A0BF5UL, + 0x6B54BFABUL, 0x2B0B1426UL, 0xAB4CC9D7UL, 0x449CCD82UL, + 0xF7FBF265UL, 0xAB85C5F3UL, 0x1B55DB94UL, 0xAAD4E324UL, + 0xCFA4BD3FUL, 0x2DEAA3E2UL, 0x9E204D02UL, 0xC8BD25ACUL, + 0xEADF55B3UL, 0xD5BD9E98UL, 0xE31231B2UL, 0x2AD5AD6CUL, + 0x954329DEUL, 0xADBE4528UL, 0xD8710F69UL, 0xAA51C90FUL, + 0xAA786BF6UL, 0x22513F1EUL, 0xAA51A79BUL, 0x2AD344CCUL, + 0x7B5A41F0UL, 0xD37CFBADUL, 0x1B069505UL, 0x41ECE491UL, + 0xB4C332E6UL, 0x032268D4UL, 0xC9600ACCUL, 0xCE387E6DUL, + 0xBF6BB16CUL, 0x6A70FB78UL, 0x0D03D9C9UL, 0xD4DF39DEUL, + 0xE01063DAUL, 0x4736F464UL, 0x5AD328D8UL, 0xB347CC96UL, + 0x75BB0FC3UL, 0x98511BFBUL, 0x4FFBCC35UL, 0xB58BCF6AUL, + 0xE11F0ABCUL, 0xBFC5FE4AUL, 0xA70AEC10UL, 0xAC39570AUL, + 0x3F04442FUL, 0x6188B153UL, 0xE0397A2EUL, 0x5727CB79UL, + 0x9CEB418FUL, 0x1CACD68DUL, 0x2AD37C96UL, 0x0175CB9DUL, + 0xC69DFF09UL, 0xC75B65F0UL, 0xD9DB40D8UL, 0xEC0E7779UL, + 0x4744EAD4UL, 0xB11C3274UL, 0xDD24CB9EUL, 0x7E1C54BDUL, + 0xF01144F9UL, 0xD2240EB1UL, 0x9675B3FDUL, 0xA3AC3755UL, + 0xD47C27AFUL, 0x51C85F4DUL, 0x56907596UL, 0xA5BB15E6UL, + 0x580304F0UL, 0xCA042CF1UL, 0x011A37EAUL, 0x8DBFAADBUL, + 0x35BA3E4AUL, 0x3526FFA0UL, 0xC37B4D09UL, 0xBC306ED9UL, + 0x98A52666UL, 0x5648F725UL, 0xFF5E569DUL, 0x0CED63D0UL, + 0x7C63B2CFUL, 0x700B45E1UL, 0xD5EA50F1UL, 0x85A92872UL, + 0xAF1FBDA7UL, 0xD4234870UL, 0xA7870BF3UL, 0x2D3B4D79UL, + 0x42E04198UL, 0x0CD0EDE7UL, 0x26470DB8UL, 0xF881814CUL, + 0x474D6AD7UL, 0x7C0C5E5CUL, 0xD1231959UL, 0x381B7298UL, + 0xF5D2F4DBUL, 0xAB838653UL, 0x6E2F1E23UL, 0x83719C9EUL, + 0xBD91E046UL, 0x9A56456EUL, 0xDC39200CUL, 0x20C8C571UL, + 0x962BDA1CUL, 0xE1E696FFUL, 0xB141AB08UL, 0x7CCA89B9UL, + 0x1A69E783UL, 0x02CC4843UL, 0xA2F7C579UL, 0x429EF47DUL, + 0x427B169CUL, 0x5AC9F049UL, 0xDD8F0F00UL, 0x5C8165BFUL + }, - { - 0x1F201094UL, 0xEF0BA75BUL, 0x69E3CF7EUL, 0x393F4380UL, - 0xFE61CF7AUL, 0xEEC5207AUL, 0x55889C94UL, 0x72FC0651UL, - 0xADA7EF79UL, 0x4E1D7235UL, 0xD55A63CEUL, 0xDE0436BAUL, - 0x99C430EFUL, 0x5F0C0794UL, 0x18DCDB7DUL, 0xA1D6EFF3UL, - 0xA0B52F7BUL, 0x59E83605UL, 0xEE15B094UL, 0xE9FFD909UL, - 0xDC440086UL, 0xEF944459UL, 0xBA83CCB3UL, 0xE0C3CDFBUL, - 0xD1DA4181UL, 0x3B092AB1UL, 0xF997F1C1UL, 0xA5E6CF7BUL, - 0x01420DDBUL, 0xE4E7EF5BUL, 0x25A1FF41UL, 0xE180F806UL, - 0x1FC41080UL, 0x179BEE7AUL, 0xD37AC6A9UL, 0xFE5830A4UL, - 0x98DE8B7FUL, 0x77E83F4EUL, 0x79929269UL, 0x24FA9F7BUL, - 0xE113C85BUL, 0xACC40083UL, 0xD7503525UL, 0xF7EA615FUL, - 0x62143154UL, 0x0D554B63UL, 0x5D681121UL, 0xC866C359UL, - 0x3D63CF73UL, 0xCEE234C0UL, 0xD4D87E87UL, 0x5C672B21UL, - 0x071F6181UL, 0x39F7627FUL, 0x361E3084UL, 0xE4EB573BUL, - 0x602F64A4UL, 0xD63ACD9CUL, 0x1BBC4635UL, 0x9E81032DUL, - 0x2701F50CUL, 0x99847AB4UL, 0xA0E3DF79UL, 0xBA6CF38CUL, - 0x10843094UL, 0x2537A95EUL, 0xF46F6FFEUL, 0xA1FF3B1FUL, - 0x208CFB6AUL, 0x8F458C74UL, 0xD9E0A227UL, 0x4EC73A34UL, - 0xFC884F69UL, 0x3E4DE8DFUL, 0xEF0E0088UL, 0x3559648DUL, - 0x8A45388CUL, 0x1D804366UL, 0x721D9BFDUL, 0xA58684BBUL, - 0xE8256333UL, 0x844E8212UL, 0x128D8098UL, 0xFED33FB4UL, - 0xCE280AE1UL, 0x27E19BA5UL, 0xD5A6C252UL, 0xE49754BDUL, - 0xC5D655DDUL, 0xEB667064UL, 0x77840B4DUL, 0xA1B6A801UL, - 0x84DB26A9UL, 0xE0B56714UL, 0x21F043B7UL, 0xE5D05860UL, - 0x54F03084UL, 0x066FF472UL, 0xA31AA153UL, 0xDADC4755UL, - 0xB5625DBFUL, 0x68561BE6UL, 0x83CA6B94UL, 0x2D6ED23BUL, - 0xECCF01DBUL, 0xA6D3D0BAUL, 0xB6803D5CUL, 0xAF77A709UL, - 0x33B4A34CUL, 0x397BC8D6UL, 0x5EE22B95UL, 0x5F0E5304UL, - 0x81ED6F61UL, 0x20E74364UL, 0xB45E1378UL, 0xDE18639BUL, - 0x881CA122UL, 0xB96726D1UL, 0x8049A7E8UL, 0x22B7DA7BUL, - 0x5E552D25UL, 0x5272D237UL, 0x79D2951CUL, 0xC60D894CUL, - 0x488CB402UL, 0x1BA4FE5BUL, 0xA4B09F6BUL, 0x1CA815CFUL, - 0xA20C3005UL, 0x8871DF63UL, 0xB9DE2FCBUL, 0x0CC6C9E9UL, - 0x0BEEFF53UL, 0xE3214517UL, 0xB4542835UL, 0x9F63293CUL, - 0xEE41E729UL, 0x6E1D2D7CUL, 0x50045286UL, 0x1E6685F3UL, - 0xF33401C6UL, 0x30A22C95UL, 0x31A70850UL, 0x60930F13UL, - 0x73F98417UL, 0xA1269859UL, 0xEC645C44UL, 0x52C877A9UL, - 0xCDFF33A6UL, 0xA02B1741UL, 0x7CBAD9A2UL, 0x2180036FUL, - 0x50D99C08UL, 0xCB3F4861UL, 0xC26BD765UL, 0x64A3F6ABUL, - 0x80342676UL, 0x25A75E7BUL, 0xE4E6D1FCUL, 0x20C710E6UL, - 0xCDF0B680UL, 0x17844D3BUL, 0x31EEF84DUL, 0x7E0824E4UL, - 0x2CCB49EBUL, 0x846A3BAEUL, 0x8FF77888UL, 0xEE5D60F6UL, - 0x7AF75673UL, 0x2FDD5CDBUL, 0xA11631C1UL, 0x30F66F43UL, - 0xB3FAEC54UL, 0x157FD7FAUL, 0xEF8579CCUL, 0xD152DE58UL, - 0xDB2FFD5EUL, 0x8F32CE19UL, 0x306AF97AUL, 0x02F03EF8UL, - 0x99319AD5UL, 0xC242FA0FUL, 0xA7E3EBB0UL, 0xC68E4906UL, - 0xB8DA230CUL, 0x80823028UL, 0xDCDEF3C8UL, 0xD35FB171UL, - 0x088A1BC8UL, 0xBEC0C560UL, 0x61A3C9E8UL, 0xBCA8F54DUL, - 0xC72FEFFAUL, 0x22822E99UL, 0x82C570B4UL, 0xD8D94E89UL, - 0x8B1C34BCUL, 0x301E16E6UL, 0x273BE979UL, 0xB0FFEAA6UL, - 0x61D9B8C6UL, 0x00B24869UL, 0xB7FFCE3FUL, 0x08DC283BUL, - 0x43DAF65AUL, 0xF7E19798UL, 0x7619B72FUL, 0x8F1C9BA4UL, - 0xDC8637A0UL, 0x16A7D3B1UL, 0x9FC393B7UL, 0xA7136EEBUL, - 0xC6BCC63EUL, 0x1A513742UL, 0xEF6828BCUL, 0x520365D6UL, - 0x2D6A77ABUL, 0x3527ED4BUL, 0x821FD216UL, 0x095C6E2EUL, - 0xDB92F2FBUL, 0x5EEA29CBUL, 0x145892F5UL, 0x91584F7FUL, - 0x5483697BUL, 0x2667A8CCUL, 0x85196048UL, 0x8C4BACEAUL, - 0x833860D4UL, 0x0D23E0F9UL, 0x6C387E8AUL, 0x0AE6D249UL, - 0xB284600CUL, 0xD835731DUL, 0xDCB1C647UL, 0xAC4C56EAUL, - 0x3EBD81B3UL, 0x230EABB0UL, 0x6438BC87UL, 0xF0B5B1FAUL, - 0x8F5EA2B3UL, 0xFC184642UL, 0x0A036B7AUL, 0x4FB089BDUL, - 0x649DA589UL, 0xA345415EUL, 0x5C038323UL, 0x3E5D3BB9UL, - 0x43D79572UL, 0x7E6DD07CUL, 0x06DFDF1EUL, 0x6C6CC4EFUL, - 0x7160A539UL, 0x73BFBE70UL, 0x83877605UL, 0x4523ECF1UL - }, + { + 0x1F201094UL, 0xEF0BA75BUL, 0x69E3CF7EUL, 0x393F4380UL, + 0xFE61CF7AUL, 0xEEC5207AUL, 0x55889C94UL, 0x72FC0651UL, + 0xADA7EF79UL, 0x4E1D7235UL, 0xD55A63CEUL, 0xDE0436BAUL, + 0x99C430EFUL, 0x5F0C0794UL, 0x18DCDB7DUL, 0xA1D6EFF3UL, + 0xA0B52F7BUL, 0x59E83605UL, 0xEE15B094UL, 0xE9FFD909UL, + 0xDC440086UL, 0xEF944459UL, 0xBA83CCB3UL, 0xE0C3CDFBUL, + 0xD1DA4181UL, 0x3B092AB1UL, 0xF997F1C1UL, 0xA5E6CF7BUL, + 0x01420DDBUL, 0xE4E7EF5BUL, 0x25A1FF41UL, 0xE180F806UL, + 0x1FC41080UL, 0x179BEE7AUL, 0xD37AC6A9UL, 0xFE5830A4UL, + 0x98DE8B7FUL, 0x77E83F4EUL, 0x79929269UL, 0x24FA9F7BUL, + 0xE113C85BUL, 0xACC40083UL, 0xD7503525UL, 0xF7EA615FUL, + 0x62143154UL, 0x0D554B63UL, 0x5D681121UL, 0xC866C359UL, + 0x3D63CF73UL, 0xCEE234C0UL, 0xD4D87E87UL, 0x5C672B21UL, + 0x071F6181UL, 0x39F7627FUL, 0x361E3084UL, 0xE4EB573BUL, + 0x602F64A4UL, 0xD63ACD9CUL, 0x1BBC4635UL, 0x9E81032DUL, + 0x2701F50CUL, 0x99847AB4UL, 0xA0E3DF79UL, 0xBA6CF38CUL, + 0x10843094UL, 0x2537A95EUL, 0xF46F6FFEUL, 0xA1FF3B1FUL, + 0x208CFB6AUL, 0x8F458C74UL, 0xD9E0A227UL, 0x4EC73A34UL, + 0xFC884F69UL, 0x3E4DE8DFUL, 0xEF0E0088UL, 0x3559648DUL, + 0x8A45388CUL, 0x1D804366UL, 0x721D9BFDUL, 0xA58684BBUL, + 0xE8256333UL, 0x844E8212UL, 0x128D8098UL, 0xFED33FB4UL, + 0xCE280AE1UL, 0x27E19BA5UL, 0xD5A6C252UL, 0xE49754BDUL, + 0xC5D655DDUL, 0xEB667064UL, 0x77840B4DUL, 0xA1B6A801UL, + 0x84DB26A9UL, 0xE0B56714UL, 0x21F043B7UL, 0xE5D05860UL, + 0x54F03084UL, 0x066FF472UL, 0xA31AA153UL, 0xDADC4755UL, + 0xB5625DBFUL, 0x68561BE6UL, 0x83CA6B94UL, 0x2D6ED23BUL, + 0xECCF01DBUL, 0xA6D3D0BAUL, 0xB6803D5CUL, 0xAF77A709UL, + 0x33B4A34CUL, 0x397BC8D6UL, 0x5EE22B95UL, 0x5F0E5304UL, + 0x81ED6F61UL, 0x20E74364UL, 0xB45E1378UL, 0xDE18639BUL, + 0x881CA122UL, 0xB96726D1UL, 0x8049A7E8UL, 0x22B7DA7BUL, + 0x5E552D25UL, 0x5272D237UL, 0x79D2951CUL, 0xC60D894CUL, + 0x488CB402UL, 0x1BA4FE5BUL, 0xA4B09F6BUL, 0x1CA815CFUL, + 0xA20C3005UL, 0x8871DF63UL, 0xB9DE2FCBUL, 0x0CC6C9E9UL, + 0x0BEEFF53UL, 0xE3214517UL, 0xB4542835UL, 0x9F63293CUL, + 0xEE41E729UL, 0x6E1D2D7CUL, 0x50045286UL, 0x1E6685F3UL, + 0xF33401C6UL, 0x30A22C95UL, 0x31A70850UL, 0x60930F13UL, + 0x73F98417UL, 0xA1269859UL, 0xEC645C44UL, 0x52C877A9UL, + 0xCDFF33A6UL, 0xA02B1741UL, 0x7CBAD9A2UL, 0x2180036FUL, + 0x50D99C08UL, 0xCB3F4861UL, 0xC26BD765UL, 0x64A3F6ABUL, + 0x80342676UL, 0x25A75E7BUL, 0xE4E6D1FCUL, 0x20C710E6UL, + 0xCDF0B680UL, 0x17844D3BUL, 0x31EEF84DUL, 0x7E0824E4UL, + 0x2CCB49EBUL, 0x846A3BAEUL, 0x8FF77888UL, 0xEE5D60F6UL, + 0x7AF75673UL, 0x2FDD5CDBUL, 0xA11631C1UL, 0x30F66F43UL, + 0xB3FAEC54UL, 0x157FD7FAUL, 0xEF8579CCUL, 0xD152DE58UL, + 0xDB2FFD5EUL, 0x8F32CE19UL, 0x306AF97AUL, 0x02F03EF8UL, + 0x99319AD5UL, 0xC242FA0FUL, 0xA7E3EBB0UL, 0xC68E4906UL, + 0xB8DA230CUL, 0x80823028UL, 0xDCDEF3C8UL, 0xD35FB171UL, + 0x088A1BC8UL, 0xBEC0C560UL, 0x61A3C9E8UL, 0xBCA8F54DUL, + 0xC72FEFFAUL, 0x22822E99UL, 0x82C570B4UL, 0xD8D94E89UL, + 0x8B1C34BCUL, 0x301E16E6UL, 0x273BE979UL, 0xB0FFEAA6UL, + 0x61D9B8C6UL, 0x00B24869UL, 0xB7FFCE3FUL, 0x08DC283BUL, + 0x43DAF65AUL, 0xF7E19798UL, 0x7619B72FUL, 0x8F1C9BA4UL, + 0xDC8637A0UL, 0x16A7D3B1UL, 0x9FC393B7UL, 0xA7136EEBUL, + 0xC6BCC63EUL, 0x1A513742UL, 0xEF6828BCUL, 0x520365D6UL, + 0x2D6A77ABUL, 0x3527ED4BUL, 0x821FD216UL, 0x095C6E2EUL, + 0xDB92F2FBUL, 0x5EEA29CBUL, 0x145892F5UL, 0x91584F7FUL, + 0x5483697BUL, 0x2667A8CCUL, 0x85196048UL, 0x8C4BACEAUL, + 0x833860D4UL, 0x0D23E0F9UL, 0x6C387E8AUL, 0x0AE6D249UL, + 0xB284600CUL, 0xD835731DUL, 0xDCB1C647UL, 0xAC4C56EAUL, + 0x3EBD81B3UL, 0x230EABB0UL, 0x6438BC87UL, 0xF0B5B1FAUL, + 0x8F5EA2B3UL, 0xFC184642UL, 0x0A036B7AUL, 0x4FB089BDUL, + 0x649DA589UL, 0xA345415EUL, 0x5C038323UL, 0x3E5D3BB9UL, + 0x43D79572UL, 0x7E6DD07CUL, 0x06DFDF1EUL, 0x6C6CC4EFUL, + 0x7160A539UL, 0x73BFBE70UL, 0x83877605UL, 0x4523ECF1UL + }, - { - 0x8DEFC240UL, 0x25FA5D9FUL, 0xEB903DBFUL, 0xE810C907UL, - 0x47607FFFUL, 0x369FE44BUL, 0x8C1FC644UL, 0xAECECA90UL, - 0xBEB1F9BFUL, 0xEEFBCAEAUL, 0xE8CF1950UL, 0x51DF07AEUL, - 0x920E8806UL, 0xF0AD0548UL, 0xE13C8D83UL, 0x927010D5UL, - 0x11107D9FUL, 0x07647DB9UL, 0xB2E3E4D4UL, 0x3D4F285EUL, - 0xB9AFA820UL, 0xFADE82E0UL, 0xA067268BUL, 0x8272792EUL, - 0x553FB2C0UL, 0x489AE22BUL, 0xD4EF9794UL, 0x125E3FBCUL, - 0x21FFFCEEUL, 0x825B1BFDUL, 0x9255C5EDUL, 0x1257A240UL, - 0x4E1A8302UL, 0xBAE07FFFUL, 0x528246E7UL, 0x8E57140EUL, - 0x3373F7BFUL, 0x8C9F8188UL, 0xA6FC4EE8UL, 0xC982B5A5UL, - 0xA8C01DB7UL, 0x579FC264UL, 0x67094F31UL, 0xF2BD3F5FUL, - 0x40FFF7C1UL, 0x1FB78DFCUL, 0x8E6BD2C1UL, 0x437BE59BUL, - 0x99B03DBFUL, 0xB5DBC64BUL, 0x638DC0E6UL, 0x55819D99UL, - 0xA197C81CUL, 0x4A012D6EUL, 0xC5884A28UL, 0xCCC36F71UL, - 0xB843C213UL, 0x6C0743F1UL, 0x8309893CUL, 0x0FEDDD5FUL, - 0x2F7FE850UL, 0xD7C07F7EUL, 0x02507FBFUL, 0x5AFB9A04UL, - 0xA747D2D0UL, 0x1651192EUL, 0xAF70BF3EUL, 0x58C31380UL, - 0x5F98302EUL, 0x727CC3C4UL, 0x0A0FB402UL, 0x0F7FEF82UL, - 0x8C96FDADUL, 0x5D2C2AAEUL, 0x8EE99A49UL, 0x50DA88B8UL, - 0x8427F4A0UL, 0x1EAC5790UL, 0x796FB449UL, 0x8252DC15UL, - 0xEFBD7D9BUL, 0xA672597DUL, 0xADA840D8UL, 0x45F54504UL, - 0xFA5D7403UL, 0xE83EC305UL, 0x4F91751AUL, 0x925669C2UL, - 0x23EFE941UL, 0xA903F12EUL, 0x60270DF2UL, 0x0276E4B6UL, - 0x94FD6574UL, 0x927985B2UL, 0x8276DBCBUL, 0x02778176UL, - 0xF8AF918DUL, 0x4E48F79EUL, 0x8F616DDFUL, 0xE29D840EUL, - 0x842F7D83UL, 0x340CE5C8UL, 0x96BBB682UL, 0x93B4B148UL, - 0xEF303CABUL, 0x984FAF28UL, 0x779FAF9BUL, 0x92DC560DUL, - 0x224D1E20UL, 0x8437AA88UL, 0x7D29DC96UL, 0x2756D3DCUL, - 0x8B907CEEUL, 0xB51FD240UL, 0xE7C07CE3UL, 0xE566B4A1UL, - 0xC3E9615EUL, 0x3CF8209DUL, 0x6094D1E3UL, 0xCD9CA341UL, - 0x5C76460EUL, 0x00EA983BUL, 0xD4D67881UL, 0xFD47572CUL, - 0xF76CEDD9UL, 0xBDA8229CUL, 0x127DADAAUL, 0x438A074EUL, - 0x1F97C090UL, 0x081BDB8AUL, 0x93A07EBEUL, 0xB938CA15UL, - 0x97B03CFFUL, 0x3DC2C0F8UL, 0x8D1AB2ECUL, 0x64380E51UL, - 0x68CC7BFBUL, 0xD90F2788UL, 0x12490181UL, 0x5DE5FFD4UL, - 0xDD7EF86AUL, 0x76A2E214UL, 0xB9A40368UL, 0x925D958FUL, - 0x4B39FFFAUL, 0xBA39AEE9UL, 0xA4FFD30BUL, 0xFAF7933BUL, - 0x6D498623UL, 0x193CBCFAUL, 0x27627545UL, 0x825CF47AUL, - 0x61BD8BA0UL, 0xD11E42D1UL, 0xCEAD04F4UL, 0x127EA392UL, - 0x10428DB7UL, 0x8272A972UL, 0x9270C4A8UL, 0x127DE50BUL, - 0x285BA1C8UL, 0x3C62F44FUL, 0x35C0EAA5UL, 0xE805D231UL, - 0x428929FBUL, 0xB4FCDF82UL, 0x4FB66A53UL, 0x0E7DC15BUL, - 0x1F081FABUL, 0x108618AEUL, 0xFCFD086DUL, 0xF9FF2889UL, - 0x694BCC11UL, 0x236A5CAEUL, 0x12DECA4DUL, 0x2C3F8CC5UL, - 0xD2D02DFEUL, 0xF8EF5896UL, 0xE4CF52DAUL, 0x95155B67UL, - 0x494A488CUL, 0xB9B6A80CUL, 0x5C8F82BCUL, 0x89D36B45UL, - 0x3A609437UL, 0xEC00C9A9UL, 0x44715253UL, 0x0A874B49UL, - 0xD773BC40UL, 0x7C34671CUL, 0x02717EF6UL, 0x4FEB5536UL, - 0xA2D02FFFUL, 0xD2BF60C4UL, 0xD43F03C0UL, 0x50B4EF6DUL, - 0x07478CD1UL, 0x006E1888UL, 0xA2E53F55UL, 0xB9E6D4BCUL, - 0xA2048016UL, 0x97573833UL, 0xD7207D67UL, 0xDE0F8F3DUL, - 0x72F87B33UL, 0xABCC4F33UL, 0x7688C55DUL, 0x7B00A6B0UL, - 0x947B0001UL, 0x570075D2UL, 0xF9BB88F8UL, 0x8942019EUL, - 0x4264A5FFUL, 0x856302E0UL, 0x72DBD92BUL, 0xEE971B69UL, - 0x6EA22FDEUL, 0x5F08AE2BUL, 0xAF7A616DUL, 0xE5C98767UL, - 0xCF1FEBD2UL, 0x61EFC8C2UL, 0xF1AC2571UL, 0xCC8239C2UL, - 0x67214CB8UL, 0xB1E583D1UL, 0xB7DC3E62UL, 0x7F10BDCEUL, - 0xF90A5C38UL, 0x0FF0443DUL, 0x606E6DC6UL, 0x60543A49UL, - 0x5727C148UL, 0x2BE98A1DUL, 0x8AB41738UL, 0x20E1BE24UL, - 0xAF96DA0FUL, 0x68458425UL, 0x99833BE5UL, 0x600D457DUL, - 0x282F9350UL, 0x8334B362UL, 0xD91D1120UL, 0x2B6D8DA0UL, - 0x642B1E31UL, 0x9C305A00UL, 0x52BCE688UL, 0x1B03588AUL, - 0xF7BAEFD5UL, 0x4142ED9CUL, 0xA4315C11UL, 0x83323EC5UL, - 0xDFEF4636UL, 0xA133C501UL, 0xE9D3531CUL, 0xEE353783UL - }, + { + 0x8DEFC240UL, 0x25FA5D9FUL, 0xEB903DBFUL, 0xE810C907UL, + 0x47607FFFUL, 0x369FE44BUL, 0x8C1FC644UL, 0xAECECA90UL, + 0xBEB1F9BFUL, 0xEEFBCAEAUL, 0xE8CF1950UL, 0x51DF07AEUL, + 0x920E8806UL, 0xF0AD0548UL, 0xE13C8D83UL, 0x927010D5UL, + 0x11107D9FUL, 0x07647DB9UL, 0xB2E3E4D4UL, 0x3D4F285EUL, + 0xB9AFA820UL, 0xFADE82E0UL, 0xA067268BUL, 0x8272792EUL, + 0x553FB2C0UL, 0x489AE22BUL, 0xD4EF9794UL, 0x125E3FBCUL, + 0x21FFFCEEUL, 0x825B1BFDUL, 0x9255C5EDUL, 0x1257A240UL, + 0x4E1A8302UL, 0xBAE07FFFUL, 0x528246E7UL, 0x8E57140EUL, + 0x3373F7BFUL, 0x8C9F8188UL, 0xA6FC4EE8UL, 0xC982B5A5UL, + 0xA8C01DB7UL, 0x579FC264UL, 0x67094F31UL, 0xF2BD3F5FUL, + 0x40FFF7C1UL, 0x1FB78DFCUL, 0x8E6BD2C1UL, 0x437BE59BUL, + 0x99B03DBFUL, 0xB5DBC64BUL, 0x638DC0E6UL, 0x55819D99UL, + 0xA197C81CUL, 0x4A012D6EUL, 0xC5884A28UL, 0xCCC36F71UL, + 0xB843C213UL, 0x6C0743F1UL, 0x8309893CUL, 0x0FEDDD5FUL, + 0x2F7FE850UL, 0xD7C07F7EUL, 0x02507FBFUL, 0x5AFB9A04UL, + 0xA747D2D0UL, 0x1651192EUL, 0xAF70BF3EUL, 0x58C31380UL, + 0x5F98302EUL, 0x727CC3C4UL, 0x0A0FB402UL, 0x0F7FEF82UL, + 0x8C96FDADUL, 0x5D2C2AAEUL, 0x8EE99A49UL, 0x50DA88B8UL, + 0x8427F4A0UL, 0x1EAC5790UL, 0x796FB449UL, 0x8252DC15UL, + 0xEFBD7D9BUL, 0xA672597DUL, 0xADA840D8UL, 0x45F54504UL, + 0xFA5D7403UL, 0xE83EC305UL, 0x4F91751AUL, 0x925669C2UL, + 0x23EFE941UL, 0xA903F12EUL, 0x60270DF2UL, 0x0276E4B6UL, + 0x94FD6574UL, 0x927985B2UL, 0x8276DBCBUL, 0x02778176UL, + 0xF8AF918DUL, 0x4E48F79EUL, 0x8F616DDFUL, 0xE29D840EUL, + 0x842F7D83UL, 0x340CE5C8UL, 0x96BBB682UL, 0x93B4B148UL, + 0xEF303CABUL, 0x984FAF28UL, 0x779FAF9BUL, 0x92DC560DUL, + 0x224D1E20UL, 0x8437AA88UL, 0x7D29DC96UL, 0x2756D3DCUL, + 0x8B907CEEUL, 0xB51FD240UL, 0xE7C07CE3UL, 0xE566B4A1UL, + 0xC3E9615EUL, 0x3CF8209DUL, 0x6094D1E3UL, 0xCD9CA341UL, + 0x5C76460EUL, 0x00EA983BUL, 0xD4D67881UL, 0xFD47572CUL, + 0xF76CEDD9UL, 0xBDA8229CUL, 0x127DADAAUL, 0x438A074EUL, + 0x1F97C090UL, 0x081BDB8AUL, 0x93A07EBEUL, 0xB938CA15UL, + 0x97B03CFFUL, 0x3DC2C0F8UL, 0x8D1AB2ECUL, 0x64380E51UL, + 0x68CC7BFBUL, 0xD90F2788UL, 0x12490181UL, 0x5DE5FFD4UL, + 0xDD7EF86AUL, 0x76A2E214UL, 0xB9A40368UL, 0x925D958FUL, + 0x4B39FFFAUL, 0xBA39AEE9UL, 0xA4FFD30BUL, 0xFAF7933BUL, + 0x6D498623UL, 0x193CBCFAUL, 0x27627545UL, 0x825CF47AUL, + 0x61BD8BA0UL, 0xD11E42D1UL, 0xCEAD04F4UL, 0x127EA392UL, + 0x10428DB7UL, 0x8272A972UL, 0x9270C4A8UL, 0x127DE50BUL, + 0x285BA1C8UL, 0x3C62F44FUL, 0x35C0EAA5UL, 0xE805D231UL, + 0x428929FBUL, 0xB4FCDF82UL, 0x4FB66A53UL, 0x0E7DC15BUL, + 0x1F081FABUL, 0x108618AEUL, 0xFCFD086DUL, 0xF9FF2889UL, + 0x694BCC11UL, 0x236A5CAEUL, 0x12DECA4DUL, 0x2C3F8CC5UL, + 0xD2D02DFEUL, 0xF8EF5896UL, 0xE4CF52DAUL, 0x95155B67UL, + 0x494A488CUL, 0xB9B6A80CUL, 0x5C8F82BCUL, 0x89D36B45UL, + 0x3A609437UL, 0xEC00C9A9UL, 0x44715253UL, 0x0A874B49UL, + 0xD773BC40UL, 0x7C34671CUL, 0x02717EF6UL, 0x4FEB5536UL, + 0xA2D02FFFUL, 0xD2BF60C4UL, 0xD43F03C0UL, 0x50B4EF6DUL, + 0x07478CD1UL, 0x006E1888UL, 0xA2E53F55UL, 0xB9E6D4BCUL, + 0xA2048016UL, 0x97573833UL, 0xD7207D67UL, 0xDE0F8F3DUL, + 0x72F87B33UL, 0xABCC4F33UL, 0x7688C55DUL, 0x7B00A6B0UL, + 0x947B0001UL, 0x570075D2UL, 0xF9BB88F8UL, 0x8942019EUL, + 0x4264A5FFUL, 0x856302E0UL, 0x72DBD92BUL, 0xEE971B69UL, + 0x6EA22FDEUL, 0x5F08AE2BUL, 0xAF7A616DUL, 0xE5C98767UL, + 0xCF1FEBD2UL, 0x61EFC8C2UL, 0xF1AC2571UL, 0xCC8239C2UL, + 0x67214CB8UL, 0xB1E583D1UL, 0xB7DC3E62UL, 0x7F10BDCEUL, + 0xF90A5C38UL, 0x0FF0443DUL, 0x606E6DC6UL, 0x60543A49UL, + 0x5727C148UL, 0x2BE98A1DUL, 0x8AB41738UL, 0x20E1BE24UL, + 0xAF96DA0FUL, 0x68458425UL, 0x99833BE5UL, 0x600D457DUL, + 0x282F9350UL, 0x8334B362UL, 0xD91D1120UL, 0x2B6D8DA0UL, + 0x642B1E31UL, 0x9C305A00UL, 0x52BCE688UL, 0x1B03588AUL, + 0xF7BAEFD5UL, 0x4142ED9CUL, 0xA4315C11UL, 0x83323EC5UL, + 0xDFEF4636UL, 0xA133C501UL, 0xE9D3531CUL, 0xEE353783UL + }, - { - 0x9DB30420UL, 0x1FB6E9DEUL, 0xA7BE7BEFUL, 0xD273A298UL, - 0x4A4F7BDBUL, 0x64AD8C57UL, 0x85510443UL, 0xFA020ED1UL, - 0x7E287AFFUL, 0xE60FB663UL, 0x095F35A1UL, 0x79EBF120UL, - 0xFD059D43UL, 0x6497B7B1UL, 0xF3641F63UL, 0x241E4ADFUL, - 0x28147F5FUL, 0x4FA2B8CDUL, 0xC9430040UL, 0x0CC32220UL, - 0xFDD30B30UL, 0xC0A5374FUL, 0x1D2D00D9UL, 0x24147B15UL, - 0xEE4D111AUL, 0x0FCA5167UL, 0x71FF904CUL, 0x2D195FFEUL, - 0x1A05645FUL, 0x0C13FEFEUL, 0x081B08CAUL, 0x05170121UL, - 0x80530100UL, 0xE83E5EFEUL, 0xAC9AF4F8UL, 0x7FE72701UL, - 0xD2B8EE5FUL, 0x06DF4261UL, 0xBB9E9B8AUL, 0x7293EA25UL, - 0xCE84FFDFUL, 0xF5718801UL, 0x3DD64B04UL, 0xA26F263BUL, - 0x7ED48400UL, 0x547EEBE6UL, 0x446D4CA0UL, 0x6CF3D6F5UL, - 0x2649ABDFUL, 0xAEA0C7F5UL, 0x36338CC1UL, 0x503F7E93UL, - 0xD3772061UL, 0x11B638E1UL, 0x72500E03UL, 0xF80EB2BBUL, - 0xABE0502EUL, 0xEC8D77DEUL, 0x57971E81UL, 0xE14F6746UL, - 0xC9335400UL, 0x6920318FUL, 0x081DBB99UL, 0xFFC304A5UL, - 0x4D351805UL, 0x7F3D5CE3UL, 0xA6C866C6UL, 0x5D5BCCA9UL, - 0xDAEC6FEAUL, 0x9F926F91UL, 0x9F46222FUL, 0x3991467DUL, - 0xA5BF6D8EUL, 0x1143C44FUL, 0x43958302UL, 0xD0214EEBUL, - 0x022083B8UL, 0x3FB6180CUL, 0x18F8931EUL, 0x281658E6UL, - 0x26486E3EUL, 0x8BD78A70UL, 0x7477E4C1UL, 0xB506E07CUL, - 0xF32D0A25UL, 0x79098B02UL, 0xE4EABB81UL, 0x28123B23UL, - 0x69DEAD38UL, 0x1574CA16UL, 0xDF871B62UL, 0x211C40B7UL, - 0xA51A9EF9UL, 0x0014377BUL, 0x041E8AC8UL, 0x09114003UL, - 0xBD59E4D2UL, 0xE3D156D5UL, 0x4FE876D5UL, 0x2F91A340UL, - 0x557BE8DEUL, 0x00EAE4A7UL, 0x0CE5C2ECUL, 0x4DB4BBA6UL, - 0xE756BDFFUL, 0xDD3369ACUL, 0xEC17B035UL, 0x06572327UL, - 0x99AFC8B0UL, 0x56C8C391UL, 0x6B65811CUL, 0x5E146119UL, - 0x6E85CB75UL, 0xBE07C002UL, 0xC2325577UL, 0x893FF4ECUL, - 0x5BBFC92DUL, 0xD0EC3B25UL, 0xB7801AB7UL, 0x8D6D3B24UL, - 0x20C763EFUL, 0xC366A5FCUL, 0x9C382880UL, 0x0ACE3205UL, - 0xAAC9548AUL, 0xECA1D7C7UL, 0x041AFA32UL, 0x1D16625AUL, - 0x6701902CUL, 0x9B757A54UL, 0x31D477F7UL, 0x9126B031UL, - 0x36CC6FDBUL, 0xC70B8B46UL, 0xD9E66A48UL, 0x56E55A79UL, - 0x026A4CEBUL, 0x52437EFFUL, 0x2F8F76B4UL, 0x0DF980A5UL, - 0x8674CDE3UL, 0xEDDA04EBUL, 0x17A9BE04UL, 0x2C18F4DFUL, - 0xB7747F9DUL, 0xAB2AF7B4UL, 0xEFC34D20UL, 0x2E096B7CUL, - 0x1741A254UL, 0xE5B6A035UL, 0x213D42F6UL, 0x2C1C7C26UL, - 0x61C2F50FUL, 0x6552DAF9UL, 0xD2C231F8UL, 0x25130F69UL, - 0xD8167FA2UL, 0x0418F2C8UL, 0x001A96A6UL, 0x0D1526ABUL, - 0x63315C21UL, 0x5E0A72ECUL, 0x49BAFEFDUL, 0x187908D9UL, - 0x8D0DBD86UL, 0x311170A7UL, 0x3E9B640CUL, 0xCC3E10D7UL, - 0xD5CAD3B6UL, 0x0CAEC388UL, 0xF73001E1UL, 0x6C728AFFUL, - 0x71EAE2A1UL, 0x1F9AF36EUL, 0xCFCBD12FUL, 0xC1DE8417UL, - 0xAC07BE6BUL, 0xCB44A1D8UL, 0x8B9B0F56UL, 0x013988C3UL, - 0xB1C52FCAUL, 0xB4BE31CDUL, 0xD8782806UL, 0x12A3A4E2UL, - 0x6F7DE532UL, 0x58FD7EB6UL, 0xD01EE900UL, 0x24ADFFC2UL, - 0xF4990FC5UL, 0x9711AAC5UL, 0x001D7B95UL, 0x82E5E7D2UL, - 0x109873F6UL, 0x00613096UL, 0xC32D9521UL, 0xADA121FFUL, - 0x29908415UL, 0x7FBB977FUL, 0xAF9EB3DBUL, 0x29C9ED2AUL, - 0x5CE2A465UL, 0xA730F32CUL, 0xD0AA3FE8UL, 0x8A5CC091UL, - 0xD49E2CE7UL, 0x0CE454A9UL, 0xD60ACD86UL, 0x015F1919UL, - 0x77079103UL, 0xDEA03AF6UL, 0x78A8565EUL, 0xDEE356DFUL, - 0x21F05CBEUL, 0x8B75E387UL, 0xB3C50651UL, 0xB8A5C3EFUL, - 0xD8EEB6D2UL, 0xE523BE77UL, 0xC2154529UL, 0x2F69EFDFUL, - 0xAFE67AFBUL, 0xF470C4B2UL, 0xF3E0EB5BUL, 0xD6CC9876UL, - 0x39E4460CUL, 0x1FDA8538UL, 0x1987832FUL, 0xCA007367UL, - 0xA99144F8UL, 0x296B299EUL, 0x492FC295UL, 0x9266BEABUL, - 0xB5676E69UL, 0x9BD3DDDAUL, 0xDF7E052FUL, 0xDB25701CUL, - 0x1B5E51EEUL, 0xF65324E6UL, 0x6AFCE36CUL, 0x0316CC04UL, - 0x8644213EUL, 0xB7DC59D0UL, 0x7965291FUL, 0xCCD6FD43UL, - 0x41823979UL, 0x932BCDF6UL, 0xB657C34DUL, 0x4EDFD282UL, - 0x7AE5290CUL, 0x3CB9536BUL, 0x851E20FEUL, 0x9833557EUL, - 0x13ECF0B0UL, 0xD3FFB372UL, 0x3F85C5C1UL, 0x0AEF7ED2UL - }, + { + 0x9DB30420UL, 0x1FB6E9DEUL, 0xA7BE7BEFUL, 0xD273A298UL, + 0x4A4F7BDBUL, 0x64AD8C57UL, 0x85510443UL, 0xFA020ED1UL, + 0x7E287AFFUL, 0xE60FB663UL, 0x095F35A1UL, 0x79EBF120UL, + 0xFD059D43UL, 0x6497B7B1UL, 0xF3641F63UL, 0x241E4ADFUL, + 0x28147F5FUL, 0x4FA2B8CDUL, 0xC9430040UL, 0x0CC32220UL, + 0xFDD30B30UL, 0xC0A5374FUL, 0x1D2D00D9UL, 0x24147B15UL, + 0xEE4D111AUL, 0x0FCA5167UL, 0x71FF904CUL, 0x2D195FFEUL, + 0x1A05645FUL, 0x0C13FEFEUL, 0x081B08CAUL, 0x05170121UL, + 0x80530100UL, 0xE83E5EFEUL, 0xAC9AF4F8UL, 0x7FE72701UL, + 0xD2B8EE5FUL, 0x06DF4261UL, 0xBB9E9B8AUL, 0x7293EA25UL, + 0xCE84FFDFUL, 0xF5718801UL, 0x3DD64B04UL, 0xA26F263BUL, + 0x7ED48400UL, 0x547EEBE6UL, 0x446D4CA0UL, 0x6CF3D6F5UL, + 0x2649ABDFUL, 0xAEA0C7F5UL, 0x36338CC1UL, 0x503F7E93UL, + 0xD3772061UL, 0x11B638E1UL, 0x72500E03UL, 0xF80EB2BBUL, + 0xABE0502EUL, 0xEC8D77DEUL, 0x57971E81UL, 0xE14F6746UL, + 0xC9335400UL, 0x6920318FUL, 0x081DBB99UL, 0xFFC304A5UL, + 0x4D351805UL, 0x7F3D5CE3UL, 0xA6C866C6UL, 0x5D5BCCA9UL, + 0xDAEC6FEAUL, 0x9F926F91UL, 0x9F46222FUL, 0x3991467DUL, + 0xA5BF6D8EUL, 0x1143C44FUL, 0x43958302UL, 0xD0214EEBUL, + 0x022083B8UL, 0x3FB6180CUL, 0x18F8931EUL, 0x281658E6UL, + 0x26486E3EUL, 0x8BD78A70UL, 0x7477E4C1UL, 0xB506E07CUL, + 0xF32D0A25UL, 0x79098B02UL, 0xE4EABB81UL, 0x28123B23UL, + 0x69DEAD38UL, 0x1574CA16UL, 0xDF871B62UL, 0x211C40B7UL, + 0xA51A9EF9UL, 0x0014377BUL, 0x041E8AC8UL, 0x09114003UL, + 0xBD59E4D2UL, 0xE3D156D5UL, 0x4FE876D5UL, 0x2F91A340UL, + 0x557BE8DEUL, 0x00EAE4A7UL, 0x0CE5C2ECUL, 0x4DB4BBA6UL, + 0xE756BDFFUL, 0xDD3369ACUL, 0xEC17B035UL, 0x06572327UL, + 0x99AFC8B0UL, 0x56C8C391UL, 0x6B65811CUL, 0x5E146119UL, + 0x6E85CB75UL, 0xBE07C002UL, 0xC2325577UL, 0x893FF4ECUL, + 0x5BBFC92DUL, 0xD0EC3B25UL, 0xB7801AB7UL, 0x8D6D3B24UL, + 0x20C763EFUL, 0xC366A5FCUL, 0x9C382880UL, 0x0ACE3205UL, + 0xAAC9548AUL, 0xECA1D7C7UL, 0x041AFA32UL, 0x1D16625AUL, + 0x6701902CUL, 0x9B757A54UL, 0x31D477F7UL, 0x9126B031UL, + 0x36CC6FDBUL, 0xC70B8B46UL, 0xD9E66A48UL, 0x56E55A79UL, + 0x026A4CEBUL, 0x52437EFFUL, 0x2F8F76B4UL, 0x0DF980A5UL, + 0x8674CDE3UL, 0xEDDA04EBUL, 0x17A9BE04UL, 0x2C18F4DFUL, + 0xB7747F9DUL, 0xAB2AF7B4UL, 0xEFC34D20UL, 0x2E096B7CUL, + 0x1741A254UL, 0xE5B6A035UL, 0x213D42F6UL, 0x2C1C7C26UL, + 0x61C2F50FUL, 0x6552DAF9UL, 0xD2C231F8UL, 0x25130F69UL, + 0xD8167FA2UL, 0x0418F2C8UL, 0x001A96A6UL, 0x0D1526ABUL, + 0x63315C21UL, 0x5E0A72ECUL, 0x49BAFEFDUL, 0x187908D9UL, + 0x8D0DBD86UL, 0x311170A7UL, 0x3E9B640CUL, 0xCC3E10D7UL, + 0xD5CAD3B6UL, 0x0CAEC388UL, 0xF73001E1UL, 0x6C728AFFUL, + 0x71EAE2A1UL, 0x1F9AF36EUL, 0xCFCBD12FUL, 0xC1DE8417UL, + 0xAC07BE6BUL, 0xCB44A1D8UL, 0x8B9B0F56UL, 0x013988C3UL, + 0xB1C52FCAUL, 0xB4BE31CDUL, 0xD8782806UL, 0x12A3A4E2UL, + 0x6F7DE532UL, 0x58FD7EB6UL, 0xD01EE900UL, 0x24ADFFC2UL, + 0xF4990FC5UL, 0x9711AAC5UL, 0x001D7B95UL, 0x82E5E7D2UL, + 0x109873F6UL, 0x00613096UL, 0xC32D9521UL, 0xADA121FFUL, + 0x29908415UL, 0x7FBB977FUL, 0xAF9EB3DBUL, 0x29C9ED2AUL, + 0x5CE2A465UL, 0xA730F32CUL, 0xD0AA3FE8UL, 0x8A5CC091UL, + 0xD49E2CE7UL, 0x0CE454A9UL, 0xD60ACD86UL, 0x015F1919UL, + 0x77079103UL, 0xDEA03AF6UL, 0x78A8565EUL, 0xDEE356DFUL, + 0x21F05CBEUL, 0x8B75E387UL, 0xB3C50651UL, 0xB8A5C3EFUL, + 0xD8EEB6D2UL, 0xE523BE77UL, 0xC2154529UL, 0x2F69EFDFUL, + 0xAFE67AFBUL, 0xF470C4B2UL, 0xF3E0EB5BUL, 0xD6CC9876UL, + 0x39E4460CUL, 0x1FDA8538UL, 0x1987832FUL, 0xCA007367UL, + 0xA99144F8UL, 0x296B299EUL, 0x492FC295UL, 0x9266BEABUL, + 0xB5676E69UL, 0x9BD3DDDAUL, 0xDF7E052FUL, 0xDB25701CUL, + 0x1B5E51EEUL, 0xF65324E6UL, 0x6AFCE36CUL, 0x0316CC04UL, + 0x8644213EUL, 0xB7DC59D0UL, 0x7965291FUL, 0xCCD6FD43UL, + 0x41823979UL, 0x932BCDF6UL, 0xB657C34DUL, 0x4EDFD282UL, + 0x7AE5290CUL, 0x3CB9536BUL, 0x851E20FEUL, 0x9833557EUL, + 0x13ECF0B0UL, 0xD3FFB372UL, 0x3F85C5C1UL, 0x0AEF7ED2UL + }, - { - 0x7EC90C04UL, 0x2C6E74B9UL, 0x9B0E66DFUL, 0xA6337911UL, - 0xB86A7FFFUL, 0x1DD358F5UL, 0x44DD9D44UL, 0x1731167FUL, - 0x08FBF1FAUL, 0xE7F511CCUL, 0xD2051B00UL, 0x735ABA00UL, - 0x2AB722D8UL, 0x386381CBUL, 0xACF6243AUL, 0x69BEFD7AUL, - 0xE6A2E77FUL, 0xF0C720CDUL, 0xC4494816UL, 0xCCF5C180UL, - 0x38851640UL, 0x15B0A848UL, 0xE68B18CBUL, 0x4CAADEFFUL, - 0x5F480A01UL, 0x0412B2AAUL, 0x259814FCUL, 0x41D0EFE2UL, - 0x4E40B48DUL, 0x248EB6FBUL, 0x8DBA1CFEUL, 0x41A99B02UL, - 0x1A550A04UL, 0xBA8F65CBUL, 0x7251F4E7UL, 0x95A51725UL, - 0xC106ECD7UL, 0x97A5980AUL, 0xC539B9AAUL, 0x4D79FE6AUL, - 0xF2F3F763UL, 0x68AF8040UL, 0xED0C9E56UL, 0x11B4958BUL, - 0xE1EB5A88UL, 0x8709E6B0UL, 0xD7E07156UL, 0x4E29FEA7UL, - 0x6366E52DUL, 0x02D1C000UL, 0xC4AC8E05UL, 0x9377F571UL, - 0x0C05372AUL, 0x578535F2UL, 0x2261BE02UL, 0xD642A0C9UL, - 0xDF13A280UL, 0x74B55BD2UL, 0x682199C0UL, 0xD421E5ECUL, - 0x53FB3CE8UL, 0xC8ADEDB3UL, 0x28A87FC9UL, 0x3D959981UL, - 0x5C1FF900UL, 0xFE38D399UL, 0x0C4EFF0BUL, 0x062407EAUL, - 0xAA2F4FB1UL, 0x4FB96976UL, 0x90C79505UL, 0xB0A8A774UL, - 0xEF55A1FFUL, 0xE59CA2C2UL, 0xA6B62D27UL, 0xE66A4263UL, - 0xDF65001FUL, 0x0EC50966UL, 0xDFDD55BCUL, 0x29DE0655UL, - 0x911E739AUL, 0x17AF8975UL, 0x32C7911CUL, 0x89F89468UL, - 0x0D01E980UL, 0x524755F4UL, 0x03B63CC9UL, 0x0CC844B2UL, - 0xBCF3F0AAUL, 0x87AC36E9UL, 0xE53A7426UL, 0x01B3D82BUL, - 0x1A9E7449UL, 0x64EE2D7EUL, 0xCDDBB1DAUL, 0x01C94910UL, - 0xB868BF80UL, 0x0D26F3FDUL, 0x9342EDE7UL, 0x04A5C284UL, - 0x636737B6UL, 0x50F5B616UL, 0xF24766E3UL, 0x8ECA36C1UL, - 0x136E05DBUL, 0xFEF18391UL, 0xFB887A37UL, 0xD6E7F7D4UL, - 0xC7FB7DC9UL, 0x3063FCDFUL, 0xB6F589DEUL, 0xEC2941DAUL, - 0x26E46695UL, 0xB7566419UL, 0xF654EFC5UL, 0xD08D58B7UL, - 0x48925401UL, 0xC1BACB7FUL, 0xE5FF550FUL, 0xB6083049UL, - 0x5BB5D0E8UL, 0x87D72E5AUL, 0xAB6A6EE1UL, 0x223A66CEUL, - 0xC62BF3CDUL, 0x9E0885F9UL, 0x68CB3E47UL, 0x086C010FUL, - 0xA21DE820UL, 0xD18B69DEUL, 0xF3F65777UL, 0xFA02C3F6UL, - 0x407EDAC3UL, 0xCBB3D550UL, 0x1793084DUL, 0xB0D70EBAUL, - 0x0AB378D5UL, 0xD951FB0CUL, 0xDED7DA56UL, 0x4124BBE4UL, - 0x94CA0B56UL, 0x0F5755D1UL, 0xE0E1E56EUL, 0x6184B5BEUL, - 0x580A249FUL, 0x94F74BC0UL, 0xE327888EUL, 0x9F7B5561UL, - 0xC3DC0280UL, 0x05687715UL, 0x646C6BD7UL, 0x44904DB3UL, - 0x66B4F0A3UL, 0xC0F1648AUL, 0x697ED5AFUL, 0x49E92FF6UL, - 0x309E374FUL, 0x2CB6356AUL, 0x85808573UL, 0x4991F840UL, - 0x76F0AE02UL, 0x083BE84DUL, 0x28421C9AUL, 0x44489406UL, - 0x736E4CB8UL, 0xC1092910UL, 0x8BC95FC6UL, 0x7D869CF4UL, - 0x134F616FUL, 0x2E77118DUL, 0xB31B2BE1UL, 0xAA90B472UL, - 0x3CA5D717UL, 0x7D161BBAUL, 0x9CAD9010UL, 0xAF462BA2UL, - 0x9FE459D2UL, 0x45D34559UL, 0xD9F2DA13UL, 0xDBC65487UL, - 0xF3E4F94EUL, 0x176D486FUL, 0x097C13EAUL, 0x631DA5C7UL, - 0x445F7382UL, 0x175683F4UL, 0xCDC66A97UL, 0x70BE0288UL, - 0xB3CDCF72UL, 0x6E5DD2F3UL, 0x20936079UL, 0x459B80A5UL, - 0xBE60E2DBUL, 0xA9C23101UL, 0xEBA5315CUL, 0x224E42F2UL, - 0x1C5C1572UL, 0xF6721B2CUL, 0x1AD2FFF3UL, 0x8C25404EUL, - 0x324ED72FUL, 0x4067B7FDUL, 0x0523138EUL, 0x5CA3BC78UL, - 0xDC0FD66EUL, 0x75922283UL, 0x784D6B17UL, 0x58EBB16EUL, - 0x44094F85UL, 0x3F481D87UL, 0xFCFEAE7BUL, 0x77B5FF76UL, - 0x8C2302BFUL, 0xAAF47556UL, 0x5F46B02AUL, 0x2B092801UL, - 0x3D38F5F7UL, 0x0CA81F36UL, 0x52AF4A8AUL, 0x66D5E7C0UL, - 0xDF3B0874UL, 0x95055110UL, 0x1B5AD7A8UL, 0xF61ED5ADUL, - 0x6CF6E479UL, 0x20758184UL, 0xD0CEFA65UL, 0x88F7BE58UL, - 0x4A046826UL, 0x0FF6F8F3UL, 0xA09C7F70UL, 0x5346ABA0UL, - 0x5CE96C28UL, 0xE176EDA3UL, 0x6BAC307FUL, 0x376829D2UL, - 0x85360FA9UL, 0x17E3FE2AUL, 0x24B79767UL, 0xF5A96B20UL, - 0xD6CD2595UL, 0x68FF1EBFUL, 0x7555442CUL, 0xF19F06BEUL, - 0xF9E0659AUL, 0xEEB9491DUL, 0x34010718UL, 0xBB30CAB8UL, - 0xE822FE15UL, 0x88570983UL, 0x750E6249UL, 0xDA627E55UL, - 0x5E76FFA8UL, 0xB1534546UL, 0x6D47DE08UL, 0xEFE9E7D4UL - }, + { + 0x7EC90C04UL, 0x2C6E74B9UL, 0x9B0E66DFUL, 0xA6337911UL, + 0xB86A7FFFUL, 0x1DD358F5UL, 0x44DD9D44UL, 0x1731167FUL, + 0x08FBF1FAUL, 0xE7F511CCUL, 0xD2051B00UL, 0x735ABA00UL, + 0x2AB722D8UL, 0x386381CBUL, 0xACF6243AUL, 0x69BEFD7AUL, + 0xE6A2E77FUL, 0xF0C720CDUL, 0xC4494816UL, 0xCCF5C180UL, + 0x38851640UL, 0x15B0A848UL, 0xE68B18CBUL, 0x4CAADEFFUL, + 0x5F480A01UL, 0x0412B2AAUL, 0x259814FCUL, 0x41D0EFE2UL, + 0x4E40B48DUL, 0x248EB6FBUL, 0x8DBA1CFEUL, 0x41A99B02UL, + 0x1A550A04UL, 0xBA8F65CBUL, 0x7251F4E7UL, 0x95A51725UL, + 0xC106ECD7UL, 0x97A5980AUL, 0xC539B9AAUL, 0x4D79FE6AUL, + 0xF2F3F763UL, 0x68AF8040UL, 0xED0C9E56UL, 0x11B4958BUL, + 0xE1EB5A88UL, 0x8709E6B0UL, 0xD7E07156UL, 0x4E29FEA7UL, + 0x6366E52DUL, 0x02D1C000UL, 0xC4AC8E05UL, 0x9377F571UL, + 0x0C05372AUL, 0x578535F2UL, 0x2261BE02UL, 0xD642A0C9UL, + 0xDF13A280UL, 0x74B55BD2UL, 0x682199C0UL, 0xD421E5ECUL, + 0x53FB3CE8UL, 0xC8ADEDB3UL, 0x28A87FC9UL, 0x3D959981UL, + 0x5C1FF900UL, 0xFE38D399UL, 0x0C4EFF0BUL, 0x062407EAUL, + 0xAA2F4FB1UL, 0x4FB96976UL, 0x90C79505UL, 0xB0A8A774UL, + 0xEF55A1FFUL, 0xE59CA2C2UL, 0xA6B62D27UL, 0xE66A4263UL, + 0xDF65001FUL, 0x0EC50966UL, 0xDFDD55BCUL, 0x29DE0655UL, + 0x911E739AUL, 0x17AF8975UL, 0x32C7911CUL, 0x89F89468UL, + 0x0D01E980UL, 0x524755F4UL, 0x03B63CC9UL, 0x0CC844B2UL, + 0xBCF3F0AAUL, 0x87AC36E9UL, 0xE53A7426UL, 0x01B3D82BUL, + 0x1A9E7449UL, 0x64EE2D7EUL, 0xCDDBB1DAUL, 0x01C94910UL, + 0xB868BF80UL, 0x0D26F3FDUL, 0x9342EDE7UL, 0x04A5C284UL, + 0x636737B6UL, 0x50F5B616UL, 0xF24766E3UL, 0x8ECA36C1UL, + 0x136E05DBUL, 0xFEF18391UL, 0xFB887A37UL, 0xD6E7F7D4UL, + 0xC7FB7DC9UL, 0x3063FCDFUL, 0xB6F589DEUL, 0xEC2941DAUL, + 0x26E46695UL, 0xB7566419UL, 0xF654EFC5UL, 0xD08D58B7UL, + 0x48925401UL, 0xC1BACB7FUL, 0xE5FF550FUL, 0xB6083049UL, + 0x5BB5D0E8UL, 0x87D72E5AUL, 0xAB6A6EE1UL, 0x223A66CEUL, + 0xC62BF3CDUL, 0x9E0885F9UL, 0x68CB3E47UL, 0x086C010FUL, + 0xA21DE820UL, 0xD18B69DEUL, 0xF3F65777UL, 0xFA02C3F6UL, + 0x407EDAC3UL, 0xCBB3D550UL, 0x1793084DUL, 0xB0D70EBAUL, + 0x0AB378D5UL, 0xD951FB0CUL, 0xDED7DA56UL, 0x4124BBE4UL, + 0x94CA0B56UL, 0x0F5755D1UL, 0xE0E1E56EUL, 0x6184B5BEUL, + 0x580A249FUL, 0x94F74BC0UL, 0xE327888EUL, 0x9F7B5561UL, + 0xC3DC0280UL, 0x05687715UL, 0x646C6BD7UL, 0x44904DB3UL, + 0x66B4F0A3UL, 0xC0F1648AUL, 0x697ED5AFUL, 0x49E92FF6UL, + 0x309E374FUL, 0x2CB6356AUL, 0x85808573UL, 0x4991F840UL, + 0x76F0AE02UL, 0x083BE84DUL, 0x28421C9AUL, 0x44489406UL, + 0x736E4CB8UL, 0xC1092910UL, 0x8BC95FC6UL, 0x7D869CF4UL, + 0x134F616FUL, 0x2E77118DUL, 0xB31B2BE1UL, 0xAA90B472UL, + 0x3CA5D717UL, 0x7D161BBAUL, 0x9CAD9010UL, 0xAF462BA2UL, + 0x9FE459D2UL, 0x45D34559UL, 0xD9F2DA13UL, 0xDBC65487UL, + 0xF3E4F94EUL, 0x176D486FUL, 0x097C13EAUL, 0x631DA5C7UL, + 0x445F7382UL, 0x175683F4UL, 0xCDC66A97UL, 0x70BE0288UL, + 0xB3CDCF72UL, 0x6E5DD2F3UL, 0x20936079UL, 0x459B80A5UL, + 0xBE60E2DBUL, 0xA9C23101UL, 0xEBA5315CUL, 0x224E42F2UL, + 0x1C5C1572UL, 0xF6721B2CUL, 0x1AD2FFF3UL, 0x8C25404EUL, + 0x324ED72FUL, 0x4067B7FDUL, 0x0523138EUL, 0x5CA3BC78UL, + 0xDC0FD66EUL, 0x75922283UL, 0x784D6B17UL, 0x58EBB16EUL, + 0x44094F85UL, 0x3F481D87UL, 0xFCFEAE7BUL, 0x77B5FF76UL, + 0x8C2302BFUL, 0xAAF47556UL, 0x5F46B02AUL, 0x2B092801UL, + 0x3D38F5F7UL, 0x0CA81F36UL, 0x52AF4A8AUL, 0x66D5E7C0UL, + 0xDF3B0874UL, 0x95055110UL, 0x1B5AD7A8UL, 0xF61ED5ADUL, + 0x6CF6E479UL, 0x20758184UL, 0xD0CEFA65UL, 0x88F7BE58UL, + 0x4A046826UL, 0x0FF6F8F3UL, 0xA09C7F70UL, 0x5346ABA0UL, + 0x5CE96C28UL, 0xE176EDA3UL, 0x6BAC307FUL, 0x376829D2UL, + 0x85360FA9UL, 0x17E3FE2AUL, 0x24B79767UL, 0xF5A96B20UL, + 0xD6CD2595UL, 0x68FF1EBFUL, 0x7555442CUL, 0xF19F06BEUL, + 0xF9E0659AUL, 0xEEB9491DUL, 0x34010718UL, 0xBB30CAB8UL, + 0xE822FE15UL, 0x88570983UL, 0x750E6249UL, 0xDA627E55UL, + 0x5E76FFA8UL, 0xB1534546UL, 0x6D47DE08UL, 0xEFE9E7D4UL + }, - { - 0xF6FA8F9DUL, 0x2CAC6CE1UL, 0x4CA34867UL, 0xE2337F7CUL, - 0x95DB08E7UL, 0x016843B4UL, 0xECED5CBCUL, 0x325553ACUL, - 0xBF9F0960UL, 0xDFA1E2EDUL, 0x83F0579DUL, 0x63ED86B9UL, - 0x1AB6A6B8UL, 0xDE5EBE39UL, 0xF38FF732UL, 0x8989B138UL, - 0x33F14961UL, 0xC01937BDUL, 0xF506C6DAUL, 0xE4625E7EUL, - 0xA308EA99UL, 0x4E23E33CUL, 0x79CBD7CCUL, 0x48A14367UL, - 0xA3149619UL, 0xFEC94BD5UL, 0xA114174AUL, 0xEAA01866UL, - 0xA084DB2DUL, 0x09A8486FUL, 0xA888614AUL, 0x2900AF98UL, - 0x01665991UL, 0xE1992863UL, 0xC8F30C60UL, 0x2E78EF3CUL, - 0xD0D51932UL, 0xCF0FEC14UL, 0xF7CA07D2UL, 0xD0A82072UL, - 0xFD41197EUL, 0x9305A6B0UL, 0xE86BE3DAUL, 0x74BED3CDUL, - 0x372DA53CUL, 0x4C7F4448UL, 0xDAB5D440UL, 0x6DBA0EC3UL, - 0x083919A7UL, 0x9FBAEED9UL, 0x49DBCFB0UL, 0x4E670C53UL, - 0x5C3D9C01UL, 0x64BDB941UL, 0x2C0E636AUL, 0xBA7DD9CDUL, - 0xEA6F7388UL, 0xE70BC762UL, 0x35F29ADBUL, 0x5C4CDD8DUL, - 0xF0D48D8CUL, 0xB88153E2UL, 0x08A19866UL, 0x1AE2EAC8UL, - 0x284CAF89UL, 0xAA928223UL, 0x9334BE53UL, 0x3B3A21BFUL, - 0x16434BE3UL, 0x9AEA3906UL, 0xEFE8C36EUL, 0xF890CDD9UL, - 0x80226DAEUL, 0xC340A4A3UL, 0xDF7E9C09UL, 0xA694A807UL, - 0x5B7C5ECCUL, 0x221DB3A6UL, 0x9A69A02FUL, 0x68818A54UL, - 0xCEB2296FUL, 0x53C0843AUL, 0xFE893655UL, 0x25BFE68AUL, - 0xB4628ABCUL, 0xCF222EBFUL, 0x25AC6F48UL, 0xA9A99387UL, - 0x53BDDB65UL, 0xE76FFBE7UL, 0xE967FD78UL, 0x0BA93563UL, - 0x8E342BC1UL, 0xE8A11BE9UL, 0x4980740DUL, 0xC8087DFCUL, - 0x8DE4BF99UL, 0xA11101A0UL, 0x7FD37975UL, 0xDA5A26C0UL, - 0xE81F994FUL, 0x9528CD89UL, 0xFD339FEDUL, 0xB87834BFUL, - 0x5F04456DUL, 0x22258698UL, 0xC9C4C83BUL, 0x2DC156BEUL, - 0x4F628DAAUL, 0x57F55EC5UL, 0xE2220ABEUL, 0xD2916EBFUL, - 0x4EC75B95UL, 0x24F2C3C0UL, 0x42D15D99UL, 0xCD0D7FA0UL, - 0x7B6E27FFUL, 0xA8DC8AF0UL, 0x7345C106UL, 0xF41E232FUL, - 0x35162386UL, 0xE6EA8926UL, 0x3333B094UL, 0x157EC6F2UL, - 0x372B74AFUL, 0x692573E4UL, 0xE9A9D848UL, 0xF3160289UL, - 0x3A62EF1DUL, 0xA787E238UL, 0xF3A5F676UL, 0x74364853UL, - 0x20951063UL, 0x4576698DUL, 0xB6FAD407UL, 0x592AF950UL, - 0x36F73523UL, 0x4CFB6E87UL, 0x7DA4CEC0UL, 0x6C152DAAUL, - 0xCB0396A8UL, 0xC50DFE5DUL, 0xFCD707ABUL, 0x0921C42FUL, - 0x89DFF0BBUL, 0x5FE2BE78UL, 0x448F4F33UL, 0x754613C9UL, - 0x2B05D08DUL, 0x48B9D585UL, 0xDC049441UL, 0xC8098F9BUL, - 0x7DEDE786UL, 0xC39A3373UL, 0x42410005UL, 0x6A091751UL, - 0x0EF3C8A6UL, 0x890072D6UL, 0x28207682UL, 0xA9A9F7BEUL, - 0xBF32679DUL, 0xD45B5B75UL, 0xB353FD00UL, 0xCBB0E358UL, - 0x830F220AUL, 0x1F8FB214UL, 0xD372CF08UL, 0xCC3C4A13UL, - 0x8CF63166UL, 0x061C87BEUL, 0x88C98F88UL, 0x6062E397UL, - 0x47CF8E7AUL, 0xB6C85283UL, 0x3CC2ACFBUL, 0x3FC06976UL, - 0x4E8F0252UL, 0x64D8314DUL, 0xDA3870E3UL, 0x1E665459UL, - 0xC10908F0UL, 0x513021A5UL, 0x6C5B68B7UL, 0x822F8AA0UL, - 0x3007CD3EUL, 0x74719EEFUL, 0xDC872681UL, 0x073340D4UL, - 0x7E432FD9UL, 0x0C5EC241UL, 0x8809286CUL, 0xF592D891UL, - 0x08A930F6UL, 0x957EF305UL, 0xB7FBFFBDUL, 0xC266E96FUL, - 0x6FE4AC98UL, 0xB173ECC0UL, 0xBC60B42AUL, 0x953498DAUL, - 0xFBA1AE12UL, 0x2D4BD736UL, 0x0F25FAABUL, 0xA4F3FCEBUL, - 0xE2969123UL, 0x257F0C3DUL, 0x9348AF49UL, 0x361400BCUL, - 0xE8816F4AUL, 0x3814F200UL, 0xA3F94043UL, 0x9C7A54C2UL, - 0xBC704F57UL, 0xDA41E7F9UL, 0xC25AD33AUL, 0x54F4A084UL, - 0xB17F5505UL, 0x59357CBEUL, 0xEDBD15C8UL, 0x7F97C5ABUL, - 0xBA5AC7B5UL, 0xB6F6DEAFUL, 0x3A479C3AUL, 0x5302DA25UL, - 0x653D7E6AUL, 0x54268D49UL, 0x51A477EAUL, 0x5017D55BUL, - 0xD7D25D88UL, 0x44136C76UL, 0x0404A8C8UL, 0xB8E5A121UL, - 0xB81A928AUL, 0x60ED5869UL, 0x97C55B96UL, 0xEAEC991BUL, - 0x29935913UL, 0x01FDB7F1UL, 0x088E8DFAUL, 0x9AB6F6F5UL, - 0x3B4CBF9FUL, 0x4A5DE3ABUL, 0xE6051D35UL, 0xA0E1D855UL, - 0xD36B4CF1UL, 0xF544EDEBUL, 0xB0E93524UL, 0xBEBB8FBDUL, - 0xA2D762CFUL, 0x49C92F54UL, 0x38B5F331UL, 0x7128A454UL, - 0x48392905UL, 0xA65B1DB8UL, 0x851C97BDUL, 0xD675CF2FUL - }, + { + 0xF6FA8F9DUL, 0x2CAC6CE1UL, 0x4CA34867UL, 0xE2337F7CUL, + 0x95DB08E7UL, 0x016843B4UL, 0xECED5CBCUL, 0x325553ACUL, + 0xBF9F0960UL, 0xDFA1E2EDUL, 0x83F0579DUL, 0x63ED86B9UL, + 0x1AB6A6B8UL, 0xDE5EBE39UL, 0xF38FF732UL, 0x8989B138UL, + 0x33F14961UL, 0xC01937BDUL, 0xF506C6DAUL, 0xE4625E7EUL, + 0xA308EA99UL, 0x4E23E33CUL, 0x79CBD7CCUL, 0x48A14367UL, + 0xA3149619UL, 0xFEC94BD5UL, 0xA114174AUL, 0xEAA01866UL, + 0xA084DB2DUL, 0x09A8486FUL, 0xA888614AUL, 0x2900AF98UL, + 0x01665991UL, 0xE1992863UL, 0xC8F30C60UL, 0x2E78EF3CUL, + 0xD0D51932UL, 0xCF0FEC14UL, 0xF7CA07D2UL, 0xD0A82072UL, + 0xFD41197EUL, 0x9305A6B0UL, 0xE86BE3DAUL, 0x74BED3CDUL, + 0x372DA53CUL, 0x4C7F4448UL, 0xDAB5D440UL, 0x6DBA0EC3UL, + 0x083919A7UL, 0x9FBAEED9UL, 0x49DBCFB0UL, 0x4E670C53UL, + 0x5C3D9C01UL, 0x64BDB941UL, 0x2C0E636AUL, 0xBA7DD9CDUL, + 0xEA6F7388UL, 0xE70BC762UL, 0x35F29ADBUL, 0x5C4CDD8DUL, + 0xF0D48D8CUL, 0xB88153E2UL, 0x08A19866UL, 0x1AE2EAC8UL, + 0x284CAF89UL, 0xAA928223UL, 0x9334BE53UL, 0x3B3A21BFUL, + 0x16434BE3UL, 0x9AEA3906UL, 0xEFE8C36EUL, 0xF890CDD9UL, + 0x80226DAEUL, 0xC340A4A3UL, 0xDF7E9C09UL, 0xA694A807UL, + 0x5B7C5ECCUL, 0x221DB3A6UL, 0x9A69A02FUL, 0x68818A54UL, + 0xCEB2296FUL, 0x53C0843AUL, 0xFE893655UL, 0x25BFE68AUL, + 0xB4628ABCUL, 0xCF222EBFUL, 0x25AC6F48UL, 0xA9A99387UL, + 0x53BDDB65UL, 0xE76FFBE7UL, 0xE967FD78UL, 0x0BA93563UL, + 0x8E342BC1UL, 0xE8A11BE9UL, 0x4980740DUL, 0xC8087DFCUL, + 0x8DE4BF99UL, 0xA11101A0UL, 0x7FD37975UL, 0xDA5A26C0UL, + 0xE81F994FUL, 0x9528CD89UL, 0xFD339FEDUL, 0xB87834BFUL, + 0x5F04456DUL, 0x22258698UL, 0xC9C4C83BUL, 0x2DC156BEUL, + 0x4F628DAAUL, 0x57F55EC5UL, 0xE2220ABEUL, 0xD2916EBFUL, + 0x4EC75B95UL, 0x24F2C3C0UL, 0x42D15D99UL, 0xCD0D7FA0UL, + 0x7B6E27FFUL, 0xA8DC8AF0UL, 0x7345C106UL, 0xF41E232FUL, + 0x35162386UL, 0xE6EA8926UL, 0x3333B094UL, 0x157EC6F2UL, + 0x372B74AFUL, 0x692573E4UL, 0xE9A9D848UL, 0xF3160289UL, + 0x3A62EF1DUL, 0xA787E238UL, 0xF3A5F676UL, 0x74364853UL, + 0x20951063UL, 0x4576698DUL, 0xB6FAD407UL, 0x592AF950UL, + 0x36F73523UL, 0x4CFB6E87UL, 0x7DA4CEC0UL, 0x6C152DAAUL, + 0xCB0396A8UL, 0xC50DFE5DUL, 0xFCD707ABUL, 0x0921C42FUL, + 0x89DFF0BBUL, 0x5FE2BE78UL, 0x448F4F33UL, 0x754613C9UL, + 0x2B05D08DUL, 0x48B9D585UL, 0xDC049441UL, 0xC8098F9BUL, + 0x7DEDE786UL, 0xC39A3373UL, 0x42410005UL, 0x6A091751UL, + 0x0EF3C8A6UL, 0x890072D6UL, 0x28207682UL, 0xA9A9F7BEUL, + 0xBF32679DUL, 0xD45B5B75UL, 0xB353FD00UL, 0xCBB0E358UL, + 0x830F220AUL, 0x1F8FB214UL, 0xD372CF08UL, 0xCC3C4A13UL, + 0x8CF63166UL, 0x061C87BEUL, 0x88C98F88UL, 0x6062E397UL, + 0x47CF8E7AUL, 0xB6C85283UL, 0x3CC2ACFBUL, 0x3FC06976UL, + 0x4E8F0252UL, 0x64D8314DUL, 0xDA3870E3UL, 0x1E665459UL, + 0xC10908F0UL, 0x513021A5UL, 0x6C5B68B7UL, 0x822F8AA0UL, + 0x3007CD3EUL, 0x74719EEFUL, 0xDC872681UL, 0x073340D4UL, + 0x7E432FD9UL, 0x0C5EC241UL, 0x8809286CUL, 0xF592D891UL, + 0x08A930F6UL, 0x957EF305UL, 0xB7FBFFBDUL, 0xC266E96FUL, + 0x6FE4AC98UL, 0xB173ECC0UL, 0xBC60B42AUL, 0x953498DAUL, + 0xFBA1AE12UL, 0x2D4BD736UL, 0x0F25FAABUL, 0xA4F3FCEBUL, + 0xE2969123UL, 0x257F0C3DUL, 0x9348AF49UL, 0x361400BCUL, + 0xE8816F4AUL, 0x3814F200UL, 0xA3F94043UL, 0x9C7A54C2UL, + 0xBC704F57UL, 0xDA41E7F9UL, 0xC25AD33AUL, 0x54F4A084UL, + 0xB17F5505UL, 0x59357CBEUL, 0xEDBD15C8UL, 0x7F97C5ABUL, + 0xBA5AC7B5UL, 0xB6F6DEAFUL, 0x3A479C3AUL, 0x5302DA25UL, + 0x653D7E6AUL, 0x54268D49UL, 0x51A477EAUL, 0x5017D55BUL, + 0xD7D25D88UL, 0x44136C76UL, 0x0404A8C8UL, 0xB8E5A121UL, + 0xB81A928AUL, 0x60ED5869UL, 0x97C55B96UL, 0xEAEC991BUL, + 0x29935913UL, 0x01FDB7F1UL, 0x088E8DFAUL, 0x9AB6F6F5UL, + 0x3B4CBF9FUL, 0x4A5DE3ABUL, 0xE6051D35UL, 0xA0E1D855UL, + 0xD36B4CF1UL, 0xF544EDEBUL, 0xB0E93524UL, 0xBEBB8FBDUL, + 0xA2D762CFUL, 0x49C92F54UL, 0x38B5F331UL, 0x7128A454UL, + 0x48392905UL, 0xA65B1DB8UL, 0x851C97BDUL, 0xD675CF2FUL + }, - { - 0x85E04019UL, 0x332BF567UL, 0x662DBFFFUL, 0xCFC65693UL, - 0x2A8D7F6FUL, 0xAB9BC912UL, 0xDE6008A1UL, 0x2028DA1FUL, - 0x0227BCE7UL, 0x4D642916UL, 0x18FAC300UL, 0x50F18B82UL, - 0x2CB2CB11UL, 0xB232E75CUL, 0x4B3695F2UL, 0xB28707DEUL, - 0xA05FBCF6UL, 0xCD4181E9UL, 0xE150210CUL, 0xE24EF1BDUL, - 0xB168C381UL, 0xFDE4E789UL, 0x5C79B0D8UL, 0x1E8BFD43UL, - 0x4D495001UL, 0x38BE4341UL, 0x913CEE1DUL, 0x92A79C3FUL, - 0x089766BEUL, 0xBAEEADF4UL, 0x1286BECFUL, 0xB6EACB19UL, - 0x2660C200UL, 0x7565BDE4UL, 0x64241F7AUL, 0x8248DCA9UL, - 0xC3B3AD66UL, 0x28136086UL, 0x0BD8DFA8UL, 0x356D1CF2UL, - 0x107789BEUL, 0xB3B2E9CEUL, 0x0502AA8FUL, 0x0BC0351EUL, - 0x166BF52AUL, 0xEB12FF82UL, 0xE3486911UL, 0xD34D7516UL, - 0x4E7B3AFFUL, 0x5F43671BUL, 0x9CF6E037UL, 0x4981AC83UL, - 0x334266CEUL, 0x8C9341B7UL, 0xD0D854C0UL, 0xCB3A6C88UL, - 0x47BC2829UL, 0x4725BA37UL, 0xA66AD22BUL, 0x7AD61F1EUL, - 0x0C5CBAFAUL, 0x4437F107UL, 0xB6E79962UL, 0x42D2D816UL, - 0x0A961288UL, 0xE1A5C06EUL, 0x13749E67UL, 0x72FC081AUL, - 0xB1D139F7UL, 0xF9583745UL, 0xCF19DF58UL, 0xBEC3F756UL, - 0xC06EBA30UL, 0x07211B24UL, 0x45C28829UL, 0xC95E317FUL, - 0xBC8EC511UL, 0x38BC46E9UL, 0xC6E6FA14UL, 0xBAE8584AUL, - 0xAD4EBC46UL, 0x468F508BUL, 0x7829435FUL, 0xF124183BUL, - 0x821DBA9FUL, 0xAFF60FF4UL, 0xEA2C4E6DUL, 0x16E39264UL, - 0x92544A8BUL, 0x009B4FC3UL, 0xABA68CEDUL, 0x9AC96F78UL, - 0x06A5B79AUL, 0xB2856E6EUL, 0x1AEC3CA9UL, 0xBE838688UL, - 0x0E0804E9UL, 0x55F1BE56UL, 0xE7E5363BUL, 0xB3A1F25DUL, - 0xF7DEBB85UL, 0x61FE033CUL, 0x16746233UL, 0x3C034C28UL, - 0xDA6D0C74UL, 0x79AAC56CUL, 0x3CE4E1ADUL, 0x51F0C802UL, - 0x98F8F35AUL, 0x1626A49FUL, 0xEED82B29UL, 0x1D382FE3UL, - 0x0C4FB99AUL, 0xBB325778UL, 0x3EC6D97BUL, 0x6E77A6A9UL, - 0xCB658B5CUL, 0xD45230C7UL, 0x2BD1408BUL, 0x60C03EB7UL, - 0xB9068D78UL, 0xA33754F4UL, 0xF430C87DUL, 0xC8A71302UL, - 0xB96D8C32UL, 0xEBD4E7BEUL, 0xBE8B9D2DUL, 0x7979FB06UL, - 0xE7225308UL, 0x8B75CF77UL, 0x11EF8DA4UL, 0xE083C858UL, - 0x8D6B786FUL, 0x5A6317A6UL, 0xFA5CF7A0UL, 0x5DDA0033UL, - 0xF28EBFB0UL, 0xF5B9C310UL, 0xA0EAC280UL, 0x08B9767AUL, - 0xA3D9D2B0UL, 0x79D34217UL, 0x021A718DUL, 0x9AC6336AUL, - 0x2711FD60UL, 0x438050E3UL, 0x069908A8UL, 0x3D7FEDC4UL, - 0x826D2BEFUL, 0x4EEB8476UL, 0x488DCF25UL, 0x36C9D566UL, - 0x28E74E41UL, 0xC2610ACAUL, 0x3D49A9CFUL, 0xBAE3B9DFUL, - 0xB65F8DE6UL, 0x92AEAF64UL, 0x3AC7D5E6UL, 0x9EA80509UL, - 0xF22B017DUL, 0xA4173F70UL, 0xDD1E16C3UL, 0x15E0D7F9UL, - 0x50B1B887UL, 0x2B9F4FD5UL, 0x625ABA82UL, 0x6A017962UL, - 0x2EC01B9CUL, 0x15488AA9UL, 0xD716E740UL, 0x40055A2CUL, - 0x93D29A22UL, 0xE32DBF9AUL, 0x058745B9UL, 0x3453DC1EUL, - 0xD699296EUL, 0x496CFF6FUL, 0x1C9F4986UL, 0xDFE2ED07UL, - 0xB87242D1UL, 0x19DE7EAEUL, 0x053E561AUL, 0x15AD6F8CUL, - 0x66626C1CUL, 0x7154C24CUL, 0xEA082B2AUL, 0x93EB2939UL, - 0x17DCB0F0UL, 0x58D4F2AEUL, 0x9EA294FBUL, 0x52CF564CUL, - 0x9883FE66UL, 0x2EC40581UL, 0x763953C3UL, 0x01D6692EUL, - 0xD3A0C108UL, 0xA1E7160EUL, 0xE4F2DFA6UL, 0x693ED285UL, - 0x74904698UL, 0x4C2B0EDDUL, 0x4F757656UL, 0x5D393378UL, - 0xA132234FUL, 0x3D321C5DUL, 0xC3F5E194UL, 0x4B269301UL, - 0xC79F022FUL, 0x3C997E7EUL, 0x5E4F9504UL, 0x3FFAFBBDUL, - 0x76F7AD0EUL, 0x296693F4UL, 0x3D1FCE6FUL, 0xC61E45BEUL, - 0xD3B5AB34UL, 0xF72BF9B7UL, 0x1B0434C0UL, 0x4E72B567UL, - 0x5592A33DUL, 0xB5229301UL, 0xCFD2A87FUL, 0x60AEB767UL, - 0x1814386BUL, 0x30BCC33DUL, 0x38A0C07DUL, 0xFD1606F2UL, - 0xC363519BUL, 0x589DD390UL, 0x5479F8E6UL, 0x1CB8D647UL, - 0x97FD61A9UL, 0xEA7759F4UL, 0x2D57539DUL, 0x569A58CFUL, - 0xE84E63ADUL, 0x462E1B78UL, 0x6580F87EUL, 0xF3817914UL, - 0x91DA55F4UL, 0x40A230F3UL, 0xD1988F35UL, 0xB6E318D2UL, - 0x3FFA50BCUL, 0x3D40F021UL, 0xC3C0BDAEUL, 0x4958C24CUL, - 0x518F36B2UL, 0x84B1D370UL, 0x0FEDCE83UL, 0x878DDADAUL, - 0xF2A279C7UL, 0x94E01BE8UL, 0x90716F4BUL, 0x954B8AA3UL - }, + { + 0x85E04019UL, 0x332BF567UL, 0x662DBFFFUL, 0xCFC65693UL, + 0x2A8D7F6FUL, 0xAB9BC912UL, 0xDE6008A1UL, 0x2028DA1FUL, + 0x0227BCE7UL, 0x4D642916UL, 0x18FAC300UL, 0x50F18B82UL, + 0x2CB2CB11UL, 0xB232E75CUL, 0x4B3695F2UL, 0xB28707DEUL, + 0xA05FBCF6UL, 0xCD4181E9UL, 0xE150210CUL, 0xE24EF1BDUL, + 0xB168C381UL, 0xFDE4E789UL, 0x5C79B0D8UL, 0x1E8BFD43UL, + 0x4D495001UL, 0x38BE4341UL, 0x913CEE1DUL, 0x92A79C3FUL, + 0x089766BEUL, 0xBAEEADF4UL, 0x1286BECFUL, 0xB6EACB19UL, + 0x2660C200UL, 0x7565BDE4UL, 0x64241F7AUL, 0x8248DCA9UL, + 0xC3B3AD66UL, 0x28136086UL, 0x0BD8DFA8UL, 0x356D1CF2UL, + 0x107789BEUL, 0xB3B2E9CEUL, 0x0502AA8FUL, 0x0BC0351EUL, + 0x166BF52AUL, 0xEB12FF82UL, 0xE3486911UL, 0xD34D7516UL, + 0x4E7B3AFFUL, 0x5F43671BUL, 0x9CF6E037UL, 0x4981AC83UL, + 0x334266CEUL, 0x8C9341B7UL, 0xD0D854C0UL, 0xCB3A6C88UL, + 0x47BC2829UL, 0x4725BA37UL, 0xA66AD22BUL, 0x7AD61F1EUL, + 0x0C5CBAFAUL, 0x4437F107UL, 0xB6E79962UL, 0x42D2D816UL, + 0x0A961288UL, 0xE1A5C06EUL, 0x13749E67UL, 0x72FC081AUL, + 0xB1D139F7UL, 0xF9583745UL, 0xCF19DF58UL, 0xBEC3F756UL, + 0xC06EBA30UL, 0x07211B24UL, 0x45C28829UL, 0xC95E317FUL, + 0xBC8EC511UL, 0x38BC46E9UL, 0xC6E6FA14UL, 0xBAE8584AUL, + 0xAD4EBC46UL, 0x468F508BUL, 0x7829435FUL, 0xF124183BUL, + 0x821DBA9FUL, 0xAFF60FF4UL, 0xEA2C4E6DUL, 0x16E39264UL, + 0x92544A8BUL, 0x009B4FC3UL, 0xABA68CEDUL, 0x9AC96F78UL, + 0x06A5B79AUL, 0xB2856E6EUL, 0x1AEC3CA9UL, 0xBE838688UL, + 0x0E0804E9UL, 0x55F1BE56UL, 0xE7E5363BUL, 0xB3A1F25DUL, + 0xF7DEBB85UL, 0x61FE033CUL, 0x16746233UL, 0x3C034C28UL, + 0xDA6D0C74UL, 0x79AAC56CUL, 0x3CE4E1ADUL, 0x51F0C802UL, + 0x98F8F35AUL, 0x1626A49FUL, 0xEED82B29UL, 0x1D382FE3UL, + 0x0C4FB99AUL, 0xBB325778UL, 0x3EC6D97BUL, 0x6E77A6A9UL, + 0xCB658B5CUL, 0xD45230C7UL, 0x2BD1408BUL, 0x60C03EB7UL, + 0xB9068D78UL, 0xA33754F4UL, 0xF430C87DUL, 0xC8A71302UL, + 0xB96D8C32UL, 0xEBD4E7BEUL, 0xBE8B9D2DUL, 0x7979FB06UL, + 0xE7225308UL, 0x8B75CF77UL, 0x11EF8DA4UL, 0xE083C858UL, + 0x8D6B786FUL, 0x5A6317A6UL, 0xFA5CF7A0UL, 0x5DDA0033UL, + 0xF28EBFB0UL, 0xF5B9C310UL, 0xA0EAC280UL, 0x08B9767AUL, + 0xA3D9D2B0UL, 0x79D34217UL, 0x021A718DUL, 0x9AC6336AUL, + 0x2711FD60UL, 0x438050E3UL, 0x069908A8UL, 0x3D7FEDC4UL, + 0x826D2BEFUL, 0x4EEB8476UL, 0x488DCF25UL, 0x36C9D566UL, + 0x28E74E41UL, 0xC2610ACAUL, 0x3D49A9CFUL, 0xBAE3B9DFUL, + 0xB65F8DE6UL, 0x92AEAF64UL, 0x3AC7D5E6UL, 0x9EA80509UL, + 0xF22B017DUL, 0xA4173F70UL, 0xDD1E16C3UL, 0x15E0D7F9UL, + 0x50B1B887UL, 0x2B9F4FD5UL, 0x625ABA82UL, 0x6A017962UL, + 0x2EC01B9CUL, 0x15488AA9UL, 0xD716E740UL, 0x40055A2CUL, + 0x93D29A22UL, 0xE32DBF9AUL, 0x058745B9UL, 0x3453DC1EUL, + 0xD699296EUL, 0x496CFF6FUL, 0x1C9F4986UL, 0xDFE2ED07UL, + 0xB87242D1UL, 0x19DE7EAEUL, 0x053E561AUL, 0x15AD6F8CUL, + 0x66626C1CUL, 0x7154C24CUL, 0xEA082B2AUL, 0x93EB2939UL, + 0x17DCB0F0UL, 0x58D4F2AEUL, 0x9EA294FBUL, 0x52CF564CUL, + 0x9883FE66UL, 0x2EC40581UL, 0x763953C3UL, 0x01D6692EUL, + 0xD3A0C108UL, 0xA1E7160EUL, 0xE4F2DFA6UL, 0x693ED285UL, + 0x74904698UL, 0x4C2B0EDDUL, 0x4F757656UL, 0x5D393378UL, + 0xA132234FUL, 0x3D321C5DUL, 0xC3F5E194UL, 0x4B269301UL, + 0xC79F022FUL, 0x3C997E7EUL, 0x5E4F9504UL, 0x3FFAFBBDUL, + 0x76F7AD0EUL, 0x296693F4UL, 0x3D1FCE6FUL, 0xC61E45BEUL, + 0xD3B5AB34UL, 0xF72BF9B7UL, 0x1B0434C0UL, 0x4E72B567UL, + 0x5592A33DUL, 0xB5229301UL, 0xCFD2A87FUL, 0x60AEB767UL, + 0x1814386BUL, 0x30BCC33DUL, 0x38A0C07DUL, 0xFD1606F2UL, + 0xC363519BUL, 0x589DD390UL, 0x5479F8E6UL, 0x1CB8D647UL, + 0x97FD61A9UL, 0xEA7759F4UL, 0x2D57539DUL, 0x569A58CFUL, + 0xE84E63ADUL, 0x462E1B78UL, 0x6580F87EUL, 0xF3817914UL, + 0x91DA55F4UL, 0x40A230F3UL, 0xD1988F35UL, 0xB6E318D2UL, + 0x3FFA50BCUL, 0x3D40F021UL, 0xC3C0BDAEUL, 0x4958C24CUL, + 0x518F36B2UL, 0x84B1D370UL, 0x0FEDCE83UL, 0x878DDADAUL, + 0xF2A279C7UL, 0x94E01BE8UL, 0x90716F4BUL, 0x954B8AA3UL + }, - { - 0xE216300DUL, 0xBBDDFFFCUL, 0xA7EBDABDUL, 0x35648095UL, - 0x7789F8B7UL, 0xE6C1121BUL, 0x0E241600UL, 0x052CE8B5UL, - 0x11A9CFB0UL, 0xE5952F11UL, 0xECE7990AUL, 0x9386D174UL, - 0x2A42931CUL, 0x76E38111UL, 0xB12DEF3AUL, 0x37DDDDFCUL, - 0xDE9ADEB1UL, 0x0A0CC32CUL, 0xBE197029UL, 0x84A00940UL, - 0xBB243A0FUL, 0xB4D137CFUL, 0xB44E79F0UL, 0x049EEDFDUL, - 0x0B15A15DUL, 0x480D3168UL, 0x8BBBDE5AUL, 0x669DED42UL, - 0xC7ECE831UL, 0x3F8F95E7UL, 0x72DF191BUL, 0x7580330DUL, - 0x94074251UL, 0x5C7DCDFAUL, 0xABBE6D63UL, 0xAA402164UL, - 0xB301D40AUL, 0x02E7D1CAUL, 0x53571DAEUL, 0x7A3182A2UL, - 0x12A8DDECUL, 0xFDAA335DUL, 0x176F43E8UL, 0x71FB46D4UL, - 0x38129022UL, 0xCE949AD4UL, 0xB84769ADUL, 0x965BD862UL, - 0x82F3D055UL, 0x66FB9767UL, 0x15B80B4EUL, 0x1D5B47A0UL, - 0x4CFDE06FUL, 0xC28EC4B8UL, 0x57E8726EUL, 0x647A78FCUL, - 0x99865D44UL, 0x608BD593UL, 0x6C200E03UL, 0x39DC5FF6UL, - 0x5D0B00A3UL, 0xAE63AFF2UL, 0x7E8BD632UL, 0x70108C0CUL, - 0xBBD35049UL, 0x2998DF04UL, 0x980CF42AUL, 0x9B6DF491UL, - 0x9E7EDD53UL, 0x06918548UL, 0x58CB7E07UL, 0x3B74EF2EUL, - 0x522FFFB1UL, 0xD24708CCUL, 0x1C7E27CDUL, 0xA4EB215BUL, - 0x3CF1D2E2UL, 0x19B47A38UL, 0x424F7618UL, 0x35856039UL, - 0x9D17DEE7UL, 0x27EB35E6UL, 0xC9AFF67BUL, 0x36BAF5B8UL, - 0x09C467CDUL, 0xC18910B1UL, 0xE11DBF7BUL, 0x06CD1AF8UL, - 0x7170C608UL, 0x2D5E3354UL, 0xD4DE495AUL, 0x64C6D006UL, - 0xBCC0C62CUL, 0x3DD00DB3UL, 0x708F8F34UL, 0x77D51B42UL, - 0x264F620FUL, 0x24B8D2BFUL, 0x15C1B79EUL, 0x46A52564UL, - 0xF8D7E54EUL, 0x3E378160UL, 0x7895CDA5UL, 0x859C15A5UL, - 0xE6459788UL, 0xC37BC75FUL, 0xDB07BA0CUL, 0x0676A3ABUL, - 0x7F229B1EUL, 0x31842E7BUL, 0x24259FD7UL, 0xF8BEF472UL, - 0x835FFCB8UL, 0x6DF4C1F2UL, 0x96F5B195UL, 0xFD0AF0FCUL, - 0xB0FE134CUL, 0xE2506D3DUL, 0x4F9B12EAUL, 0xF215F225UL, - 0xA223736FUL, 0x9FB4C428UL, 0x25D04979UL, 0x34C713F8UL, - 0xC4618187UL, 0xEA7A6E98UL, 0x7CD16EFCUL, 0x1436876CUL, - 0xF1544107UL, 0xBEDEEE14UL, 0x56E9AF27UL, 0xA04AA441UL, - 0x3CF7C899UL, 0x92ECBAE6UL, 0xDD67016DUL, 0x151682EBUL, - 0xA842EEDFUL, 0xFDBA60B4UL, 0xF1907B75UL, 0x20E3030FUL, - 0x24D8C29EUL, 0xE139673BUL, 0xEFA63FB8UL, 0x71873054UL, - 0xB6F2CF3BUL, 0x9F326442UL, 0xCB15A4CCUL, 0xB01A4504UL, - 0xF1E47D8DUL, 0x844A1BE5UL, 0xBAE7DFDCUL, 0x42CBDA70UL, - 0xCD7DAE0AUL, 0x57E85B7AUL, 0xD53F5AF6UL, 0x20CF4D8CUL, - 0xCEA4D428UL, 0x79D130A4UL, 0x3486EBFBUL, 0x33D3CDDCUL, - 0x77853B53UL, 0x37EFFCB5UL, 0xC5068778UL, 0xE580B3E6UL, - 0x4E68B8F4UL, 0xC5C8B37EUL, 0x0D809EA2UL, 0x398FEB7CUL, - 0x132A4F94UL, 0x43B7950EUL, 0x2FEE7D1CUL, 0x223613BDUL, - 0xDD06CAA2UL, 0x37DF932BUL, 0xC4248289UL, 0xACF3EBC3UL, - 0x5715F6B7UL, 0xEF3478DDUL, 0xF267616FUL, 0xC148CBE4UL, - 0x9052815EUL, 0x5E410FABUL, 0xB48A2465UL, 0x2EDA7FA4UL, - 0xE87B40E4UL, 0xE98EA084UL, 0x5889E9E1UL, 0xEFD390FCUL, - 0xDD07D35BUL, 0xDB485694UL, 0x38D7E5B2UL, 0x57720101UL, - 0x730EDEBCUL, 0x5B643113UL, 0x94917E4FUL, 0x503C2FBAUL, - 0x646F1282UL, 0x7523D24AUL, 0xE0779695UL, 0xF9C17A8FUL, - 0x7A5B2121UL, 0xD187B896UL, 0x29263A4DUL, 0xBA510CDFUL, - 0x81F47C9FUL, 0xAD1163EDUL, 0xEA7B5965UL, 0x1A00726EUL, - 0x11403092UL, 0x00DA6D77UL, 0x4A0CDD61UL, 0xAD1F4603UL, - 0x605BDFB0UL, 0x9EEDC364UL, 0x22EBE6A8UL, 0xCEE7D28AUL, - 0xA0E736A0UL, 0x5564A6B9UL, 0x10853209UL, 0xC7EB8F37UL, - 0x2DE705CAUL, 0x8951570FUL, 0xDF09822BUL, 0xBD691A6CUL, - 0xAA12E4F2UL, 0x87451C0FUL, 0xE0F6A27AUL, 0x3ADA4819UL, - 0x4CF1764FUL, 0x0D771C2BUL, 0x67CDB156UL, 0x350D8384UL, - 0x5938FA0FUL, 0x42399EF3UL, 0x36997B07UL, 0x0E84093DUL, - 0x4AA93E61UL, 0x8360D87BUL, 0x1FA98B0CUL, 0x1149382CUL, - 0xE97625A5UL, 0x0614D1B7UL, 0x0E25244BUL, 0x0C768347UL, - 0x589E8D82UL, 0x0D2059D1UL, 0xA466BB1EUL, 0xF8DA0A82UL, - 0x04F19130UL, 0xBA6E4EC0UL, 0x99265164UL, 0x1EE7230DUL, - 0x50B2AD80UL, 0xEAEE6801UL, 0x8DB2A283UL, 0xEA8BF59EUL - } + { + 0xE216300DUL, 0xBBDDFFFCUL, 0xA7EBDABDUL, 0x35648095UL, + 0x7789F8B7UL, 0xE6C1121BUL, 0x0E241600UL, 0x052CE8B5UL, + 0x11A9CFB0UL, 0xE5952F11UL, 0xECE7990AUL, 0x9386D174UL, + 0x2A42931CUL, 0x76E38111UL, 0xB12DEF3AUL, 0x37DDDDFCUL, + 0xDE9ADEB1UL, 0x0A0CC32CUL, 0xBE197029UL, 0x84A00940UL, + 0xBB243A0FUL, 0xB4D137CFUL, 0xB44E79F0UL, 0x049EEDFDUL, + 0x0B15A15DUL, 0x480D3168UL, 0x8BBBDE5AUL, 0x669DED42UL, + 0xC7ECE831UL, 0x3F8F95E7UL, 0x72DF191BUL, 0x7580330DUL, + 0x94074251UL, 0x5C7DCDFAUL, 0xABBE6D63UL, 0xAA402164UL, + 0xB301D40AUL, 0x02E7D1CAUL, 0x53571DAEUL, 0x7A3182A2UL, + 0x12A8DDECUL, 0xFDAA335DUL, 0x176F43E8UL, 0x71FB46D4UL, + 0x38129022UL, 0xCE949AD4UL, 0xB84769ADUL, 0x965BD862UL, + 0x82F3D055UL, 0x66FB9767UL, 0x15B80B4EUL, 0x1D5B47A0UL, + 0x4CFDE06FUL, 0xC28EC4B8UL, 0x57E8726EUL, 0x647A78FCUL, + 0x99865D44UL, 0x608BD593UL, 0x6C200E03UL, 0x39DC5FF6UL, + 0x5D0B00A3UL, 0xAE63AFF2UL, 0x7E8BD632UL, 0x70108C0CUL, + 0xBBD35049UL, 0x2998DF04UL, 0x980CF42AUL, 0x9B6DF491UL, + 0x9E7EDD53UL, 0x06918548UL, 0x58CB7E07UL, 0x3B74EF2EUL, + 0x522FFFB1UL, 0xD24708CCUL, 0x1C7E27CDUL, 0xA4EB215BUL, + 0x3CF1D2E2UL, 0x19B47A38UL, 0x424F7618UL, 0x35856039UL, + 0x9D17DEE7UL, 0x27EB35E6UL, 0xC9AFF67BUL, 0x36BAF5B8UL, + 0x09C467CDUL, 0xC18910B1UL, 0xE11DBF7BUL, 0x06CD1AF8UL, + 0x7170C608UL, 0x2D5E3354UL, 0xD4DE495AUL, 0x64C6D006UL, + 0xBCC0C62CUL, 0x3DD00DB3UL, 0x708F8F34UL, 0x77D51B42UL, + 0x264F620FUL, 0x24B8D2BFUL, 0x15C1B79EUL, 0x46A52564UL, + 0xF8D7E54EUL, 0x3E378160UL, 0x7895CDA5UL, 0x859C15A5UL, + 0xE6459788UL, 0xC37BC75FUL, 0xDB07BA0CUL, 0x0676A3ABUL, + 0x7F229B1EUL, 0x31842E7BUL, 0x24259FD7UL, 0xF8BEF472UL, + 0x835FFCB8UL, 0x6DF4C1F2UL, 0x96F5B195UL, 0xFD0AF0FCUL, + 0xB0FE134CUL, 0xE2506D3DUL, 0x4F9B12EAUL, 0xF215F225UL, + 0xA223736FUL, 0x9FB4C428UL, 0x25D04979UL, 0x34C713F8UL, + 0xC4618187UL, 0xEA7A6E98UL, 0x7CD16EFCUL, 0x1436876CUL, + 0xF1544107UL, 0xBEDEEE14UL, 0x56E9AF27UL, 0xA04AA441UL, + 0x3CF7C899UL, 0x92ECBAE6UL, 0xDD67016DUL, 0x151682EBUL, + 0xA842EEDFUL, 0xFDBA60B4UL, 0xF1907B75UL, 0x20E3030FUL, + 0x24D8C29EUL, 0xE139673BUL, 0xEFA63FB8UL, 0x71873054UL, + 0xB6F2CF3BUL, 0x9F326442UL, 0xCB15A4CCUL, 0xB01A4504UL, + 0xF1E47D8DUL, 0x844A1BE5UL, 0xBAE7DFDCUL, 0x42CBDA70UL, + 0xCD7DAE0AUL, 0x57E85B7AUL, 0xD53F5AF6UL, 0x20CF4D8CUL, + 0xCEA4D428UL, 0x79D130A4UL, 0x3486EBFBUL, 0x33D3CDDCUL, + 0x77853B53UL, 0x37EFFCB5UL, 0xC5068778UL, 0xE580B3E6UL, + 0x4E68B8F4UL, 0xC5C8B37EUL, 0x0D809EA2UL, 0x398FEB7CUL, + 0x132A4F94UL, 0x43B7950EUL, 0x2FEE7D1CUL, 0x223613BDUL, + 0xDD06CAA2UL, 0x37DF932BUL, 0xC4248289UL, 0xACF3EBC3UL, + 0x5715F6B7UL, 0xEF3478DDUL, 0xF267616FUL, 0xC148CBE4UL, + 0x9052815EUL, 0x5E410FABUL, 0xB48A2465UL, 0x2EDA7FA4UL, + 0xE87B40E4UL, 0xE98EA084UL, 0x5889E9E1UL, 0xEFD390FCUL, + 0xDD07D35BUL, 0xDB485694UL, 0x38D7E5B2UL, 0x57720101UL, + 0x730EDEBCUL, 0x5B643113UL, 0x94917E4FUL, 0x503C2FBAUL, + 0x646F1282UL, 0x7523D24AUL, 0xE0779695UL, 0xF9C17A8FUL, + 0x7A5B2121UL, 0xD187B896UL, 0x29263A4DUL, 0xBA510CDFUL, + 0x81F47C9FUL, 0xAD1163EDUL, 0xEA7B5965UL, 0x1A00726EUL, + 0x11403092UL, 0x00DA6D77UL, 0x4A0CDD61UL, 0xAD1F4603UL, + 0x605BDFB0UL, 0x9EEDC364UL, 0x22EBE6A8UL, 0xCEE7D28AUL, + 0xA0E736A0UL, 0x5564A6B9UL, 0x10853209UL, 0xC7EB8F37UL, + 0x2DE705CAUL, 0x8951570FUL, 0xDF09822BUL, 0xBD691A6CUL, + 0xAA12E4F2UL, 0x87451C0FUL, 0xE0F6A27AUL, 0x3ADA4819UL, + 0x4CF1764FUL, 0x0D771C2BUL, 0x67CDB156UL, 0x350D8384UL, + 0x5938FA0FUL, 0x42399EF3UL, 0x36997B07UL, 0x0E84093DUL, + 0x4AA93E61UL, 0x8360D87BUL, 0x1FA98B0CUL, 0x1149382CUL, + 0xE97625A5UL, 0x0614D1B7UL, 0x0E25244BUL, 0x0C768347UL, + 0x589E8D82UL, 0x0D2059D1UL, 0xA466BB1EUL, 0xF8DA0A82UL, + 0x04F19130UL, 0xBA6E4EC0UL, 0x99265164UL, 0x1EE7230DUL, + 0x50B2AD80UL, 0xEAEE6801UL, 0x8DB2A283UL, 0xEA8BF59EUL + } }; DECLSPEC void Cast5Encrypt (PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key, SHM_TYPE u32 (*s_S)[256]) { - u32 l; GET_UINT32BE(l, inBlock, 0); - u32 r; GET_UINT32BE(r, inBlock, 4); - PRIVATE_AS u32 *K = key->K; - u32 t; + u32 l; GET_UINT32BE(l, inBlock, 0); + u32 r; GET_UINT32BE(r, inBlock, 4); + PRIVATE_AS u32 *K = key->K; + u32 t; - /* Do the work */ - _CAST_F1(l, r, 0, 16); - _CAST_F2(r, l, 1, 16); - _CAST_F3(l, r, 2, 16); - _CAST_F1(r, l, 3, 16); - _CAST_F2(l, r, 4, 16); - _CAST_F3(r, l, 5, 16); - _CAST_F1(l, r, 6, 16); - _CAST_F2(r, l, 7, 16); - _CAST_F3(l, r, 8, 16); - _CAST_F1(r, l, 9, 16); - _CAST_F2(l, r, 10, 16); - _CAST_F3(r, l, 11, 16); - _CAST_F1(l, r, 12, 16); - _CAST_F2(r, l, 13, 16); - _CAST_F3(l, r, 14, 16); - _CAST_F1(r, l, 15, 16); + /* Do the work */ + _CAST_F1(l, r, 0, 16); + _CAST_F2(r, l, 1, 16); + _CAST_F3(l, r, 2, 16); + _CAST_F1(r, l, 3, 16); + _CAST_F2(l, r, 4, 16); + _CAST_F3(r, l, 5, 16); + _CAST_F1(l, r, 6, 16); + _CAST_F2(r, l, 7, 16); + _CAST_F3(l, r, 8, 16); + _CAST_F1(r, l, 9, 16); + _CAST_F2(l, r, 10, 16); + _CAST_F3(r, l, 11, 16); + _CAST_F1(l, r, 12, 16); + _CAST_F2(r, l, 13, 16); + _CAST_F3(l, r, 14, 16); + _CAST_F1(r, l, 15, 16); - /* Put l,r into outblock */ - PUT_UINT32BE(r, outBlock, 0); - PUT_UINT32BE(l, outBlock, 4); + /* Put l,r into outblock */ + PUT_UINT32BE(r, outBlock, 0); + PUT_UINT32BE(l, outBlock, 4); } DECLSPEC void Cast5Decrypt (PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key, SHM_TYPE u32 (*s_S)[256]) { - u32 l; GET_UINT32BE(l, inBlock, 0); - u32 r; GET_UINT32BE(r, inBlock, 4); - PRIVATE_AS u32 *K = key->K; - u32 t; + u32 l; GET_UINT32BE(l, inBlock, 0); + u32 r; GET_UINT32BE(r, inBlock, 4); + PRIVATE_AS u32 *K = key->K; + u32 t; - /* Only do full 16 rounds if key length > 80 bits */ - _CAST_F1(r, l, 15, 16); - _CAST_F3(l, r, 14, 16); - _CAST_F2(r, l, 13, 16); - _CAST_F1(l, r, 12, 16); - _CAST_F3(r, l, 11, 16); - _CAST_F2(l, r, 10, 16); - _CAST_F1(r, l, 9, 16); - _CAST_F3(l, r, 8, 16); - _CAST_F2(r, l, 7, 16); - _CAST_F1(l, r, 6, 16); - _CAST_F3(r, l, 5, 16); - _CAST_F2(l, r, 4, 16); - _CAST_F1(r, l, 3, 16); - _CAST_F3(l, r, 2, 16); - _CAST_F2(r, l, 1, 16); - _CAST_F1(l, r, 0, 16); - /* Put l,r into outblock */ - PUT_UINT32BE(r, outBlock, 0); - PUT_UINT32BE(l, outBlock, 4); - /* Wipe clean */ - t = l = r = 0; + /* Only do full 16 rounds if key length > 80 bits */ + _CAST_F1(r, l, 15, 16); + _CAST_F3(l, r, 14, 16); + _CAST_F2(r, l, 13, 16); + _CAST_F1(l, r, 12, 16); + _CAST_F3(r, l, 11, 16); + _CAST_F2(l, r, 10, 16); + _CAST_F1(r, l, 9, 16); + _CAST_F3(l, r, 8, 16); + _CAST_F2(r, l, 7, 16); + _CAST_F1(l, r, 6, 16); + _CAST_F3(r, l, 5, 16); + _CAST_F2(l, r, 4, 16); + _CAST_F1(r, l, 3, 16); + _CAST_F3(l, r, 2, 16); + _CAST_F2(r, l, 1, 16); + _CAST_F1(l, r, 0, 16); + /* Put l,r into outblock */ + PUT_UINT32BE(r, outBlock, 0); + PUT_UINT32BE(l, outBlock, 4); + /* Wipe clean */ + t = l = r = 0; } DECLSPEC void Cast5SetKey (PRIVATE_AS CAST_KEY *key, u32 keylength, PRIVATE_AS const u8 *userKey, SHM_TYPE u32 (*s_S)[256]) { - u32 i; - PRIVATE_AS u32 *K = key->K; - u32 X[4], Z[4]; + u32 i; + PRIVATE_AS u32 *K = key->K; + u32 X[4], Z[4]; - GET_UINT32BE(X[0], userKey, 0); - GET_UINT32BE(X[1], userKey, 4); - GET_UINT32BE(X[2], userKey, 8); - GET_UINT32BE(X[3], userKey, 12); + GET_UINT32BE(X[0], userKey, 0); + GET_UINT32BE(X[1], userKey, 4); + GET_UINT32BE(X[2], userKey, 8); + GET_UINT32BE(X[3], userKey, 12); #define x(i) GETBYTE(X[i/4], 3-i%4) #define z(i) GETBYTE(Z[i/4], 3-i%4) - for (i=0; i<=16; i+=16) { - // this part is copied directly from RFC 2144 (with some search and replace) by Wei Dai - Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; - Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; - Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; - Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; - K[i+0] = s_S[4][z(0x8)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0x7)] ^ s_S[7][z(0x6)] ^ s_S[4][z(0x2)]; - K[i+1] = s_S[4][z(0xA)] ^ s_S[5][z(0xB)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[5][z(0x6)]; - K[i+2] = s_S[4][z(0xC)] ^ s_S[5][z(0xD)] ^ s_S[6][z(0x3)] ^ s_S[7][z(0x2)] ^ s_S[6][z(0x9)]; - K[i+3] = s_S[4][z(0xE)] ^ s_S[5][z(0xF)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x0)] ^ s_S[7][z(0xC)]; - X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; - X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; - X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; - X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; - K[i+4] = s_S[4][x(0x3)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xD)] ^ s_S[4][x(0x8)]; - K[i+5] = s_S[4][x(0x1)] ^ s_S[5][x(0x0)] ^ s_S[6][x(0xE)] ^ s_S[7][x(0xF)] ^ s_S[5][x(0xD)]; - K[i+6] = s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x8)] ^ s_S[7][x(0x9)] ^ s_S[6][x(0x3)]; - K[i+7] = s_S[4][x(0x5)] ^ s_S[5][x(0x4)] ^ s_S[6][x(0xA)] ^ s_S[7][x(0xB)] ^ s_S[7][x(0x7)]; - Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; - Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; - Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; - Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; - K[i+8] = s_S[4][z(0x3)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0xC)] ^ s_S[7][z(0xD)] ^ s_S[4][z(0x9)]; - K[i+9] = s_S[4][z(0x1)] ^ s_S[5][z(0x0)] ^ s_S[6][z(0xE)] ^ s_S[7][z(0xF)] ^ s_S[5][z(0xC)]; - K[i+10] = s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x8)] ^ s_S[7][z(0x9)] ^ s_S[6][z(0x2)]; - K[i+11] = s_S[4][z(0x5)] ^ s_S[5][z(0x4)] ^ s_S[6][z(0xA)] ^ s_S[7][z(0xB)] ^ s_S[7][z(0x6)]; - X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; - X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; - X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; - X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; - K[i+12] = s_S[4][x(0x8)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0x7)] ^ s_S[7][x(0x6)] ^ s_S[4][x(0x3)]; - K[i+13] = s_S[4][x(0xA)] ^ s_S[5][x(0xB)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[5][x(0x7)]; - K[i+14] = s_S[4][x(0xC)] ^ s_S[5][x(0xD)] ^ s_S[6][x(0x3)] ^ s_S[7][x(0x2)] ^ s_S[6][x(0x8)]; - K[i+15] = s_S[4][x(0xE)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x0)] ^ s_S[7][x(0xD)]; - } + for (i = 0; i <= 16; i += 16) + { + // this part is copied directly from RFC 2144 (with some search and replace) by Wei Dai + Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; + Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; + Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; + Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; + K[i+0] = s_S[4][z(0x8)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0x7)] ^ s_S[7][z(0x6)] ^ s_S[4][z(0x2)]; + K[i+1] = s_S[4][z(0xA)] ^ s_S[5][z(0xB)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[5][z(0x6)]; + K[i+2] = s_S[4][z(0xC)] ^ s_S[5][z(0xD)] ^ s_S[6][z(0x3)] ^ s_S[7][z(0x2)] ^ s_S[6][z(0x9)]; + K[i+3] = s_S[4][z(0xE)] ^ s_S[5][z(0xF)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x0)] ^ s_S[7][z(0xC)]; + X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; + X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; + X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; + X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; + K[i+4] = s_S[4][x(0x3)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xD)] ^ s_S[4][x(0x8)]; + K[i+5] = s_S[4][x(0x1)] ^ s_S[5][x(0x0)] ^ s_S[6][x(0xE)] ^ s_S[7][x(0xF)] ^ s_S[5][x(0xD)]; + K[i+6] = s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x8)] ^ s_S[7][x(0x9)] ^ s_S[6][x(0x3)]; + K[i+7] = s_S[4][x(0x5)] ^ s_S[5][x(0x4)] ^ s_S[6][x(0xA)] ^ s_S[7][x(0xB)] ^ s_S[7][x(0x7)]; + Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; + Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; + Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; + Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; + K[i+8] = s_S[4][z(0x3)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0xC)] ^ s_S[7][z(0xD)] ^ s_S[4][z(0x9)]; + K[i+9] = s_S[4][z(0x1)] ^ s_S[5][z(0x0)] ^ s_S[6][z(0xE)] ^ s_S[7][z(0xF)] ^ s_S[5][z(0xC)]; + K[i+10] = s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x8)] ^ s_S[7][z(0x9)] ^ s_S[6][z(0x2)]; + K[i+11] = s_S[4][z(0x5)] ^ s_S[5][z(0x4)] ^ s_S[6][z(0xA)] ^ s_S[7][z(0xB)] ^ s_S[7][z(0x6)]; + X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; + X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; + X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; + X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; + K[i+12] = s_S[4][x(0x8)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0x7)] ^ s_S[7][x(0x6)] ^ s_S[4][x(0x3)]; + K[i+13] = s_S[4][x(0xA)] ^ s_S[5][x(0xB)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[5][x(0x7)]; + K[i+14] = s_S[4][x(0xC)] ^ s_S[5][x(0xD)] ^ s_S[6][x(0x3)] ^ s_S[7][x(0x2)] ^ s_S[6][x(0x8)]; + K[i+15] = s_S[4][x(0xE)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x0)] ^ s_S[7][x(0xD)]; + } - u32 data[32]; - for (i = 0; i < 16; i++) { - data[i * 2] = K[i]; - data[i * 2 + 1] = ((K[i + 16]) + 16) & 0x1f; // here only the lowest 5 bits are set.. - } + u32 data[32]; - for (i=16; i<32; i++) - K[i] &= 0x1f; + for (i = 0; i < 16; i++) + { + data[i * 2] = K[i]; + data[i * 2 + 1] = ((K[i + 16]) + 16) & 0x1f; // here only the lowest 5 bits are set.. + } + + for (i = 16; i < 32; i++) + K[i] &= 0x1f; } diff --git a/OpenCL/inc_cipher_cast.h b/OpenCL/inc_cipher_cast.h index 7b96dc558..2ee4ab62a 100644 --- a/OpenCL/inc_cipher_cast.h +++ b/OpenCL/inc_cipher_cast.h @@ -4,23 +4,23 @@ #define _OPENCL_CAST_H // #include "opencl_misc.h" -#define GET_UINT32BE(n, b, i) \ - { \ - (n) = ((uint) (b)[(i)] << 24) \ - | ((uint) (b)[(i) + 1] << 16) \ - | ((uint) (b)[(i) + 2] << 8) \ - | ((uint) (b)[(i) + 3] ); \ - } -#define PUT_UINT32BE(n, b, i) \ - { \ - (b)[(i) ] = (u8) ((n) >> 24); \ - (b)[(i) + 1] = (u8) ((n) >> 16); \ - (b)[(i) + 2] = (u8) ((n) >> 8); \ - (b)[(i) + 3] = (u8) ((n) ); \ - } +#define GET_UINT32BE(n, b, i) \ + { \ + (n) = ((uint) (b)[(i)] << 24) \ + | ((uint) (b)[(i) + 1] << 16) \ + | ((uint) (b)[(i) + 2] << 8) \ + | ((uint) (b)[(i) + 3] ); \ + } +#define PUT_UINT32BE(n, b, i) \ + { \ + (b)[(i) ] = (u8) ((n) >> 24); \ + (b)[(i) + 1] = (u8) ((n) >> 16); \ + (b)[(i) + 2] = (u8) ((n) >> 8); \ + (b)[(i) + 3] = (u8) ((n) ); \ + } typedef struct { - u32 K[32]; + u32 K[32]; } CAST_KEY; #define GETBYTE(x, y) (uint)(u8)((x)>>(8*(y))) @@ -32,18 +32,18 @@ typedef struct { #define U8d(x) GETBYTE(x,0) /* CAST uses three different round functions */ -#define _CAST_f1(l, r, km, kr) \ - t = hc_rotl32_S(km + r, kr); \ - l ^= ((s_S[0][U8a(t)] ^ s_S[1][U8b(t)]) - \ - s_S[2][U8c(t)]) + s_S[3][U8d(t)]; -#define _CAST_f2(l, r, km, kr) \ - t = hc_rotl32_S(km ^ r, kr); \ - l ^= ((s_S[0][U8a(t)] - s_S[1][U8b(t)]) + \ - s_S[2][U8c(t)]) ^ s_S[3][U8d(t)]; -#define _CAST_f3(l, r, km, kr) \ - t = hc_rotl32_S(km - r, kr); \ - l ^= ((s_S[0][U8a(t)] + s_S[1][U8b(t)]) ^ \ - s_S[2][U8c(t)]) - s_S[3][U8d(t)]; +#define _CAST_f1(l, r, km, kr) \ + t = hc_rotl32_S(km + r, kr); \ + l ^= ((s_S[0][U8a(t)] ^ s_S[1][U8b(t)]) - \ + s_S[2][U8c(t)]) + s_S[3][U8d(t)]; +#define _CAST_f2(l, r, km, kr) \ + t = hc_rotl32_S(km ^ r, kr); \ + l ^= ((s_S[0][U8a(t)] - s_S[1][U8b(t)]) + \ + s_S[2][U8c(t)]) ^ s_S[3][U8d(t)]; +#define _CAST_f3(l, r, km, kr) \ + t = hc_rotl32_S(km - r, kr); \ + l ^= ((s_S[0][U8a(t)] + s_S[1][U8b(t)]) ^ \ + s_S[2][U8c(t)]) - s_S[3][U8d(t)]; #define _CAST_F1(l, r, i, j) _CAST_f1(l, r, K[i], K[i+j]) #define _CAST_F2(l, r, i, j) _CAST_f2(l, r, K[i], K[i+j]) diff --git a/OpenCL/m31900-pure.cl b/OpenCL/m31900-pure.cl index fca9b423d..022132bc7 100644 --- a/OpenCL/m31900-pure.cl +++ b/OpenCL/m31900-pure.cl @@ -440,9 +440,9 @@ KERNEL_FQ void m31900_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha512_tmp_t, pbkdf2_sh + is_valid_printable_32 (pt_buf[2]) + is_valid_printable_32 (pt_buf[3]); - if (correct_b1 != 4) return; + if (correct_b1 != 4) return; - // proceed with second block to further reduce false-positives + // proceed with second block to further reduce false-positives AES256_decrypt (ks, ct_buf+4, pt_buf+4, s_td0, s_td1, s_td2, s_td3, s_td4); @@ -456,8 +456,8 @@ KERNEL_FQ void m31900_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha512_tmp_t, pbkdf2_sh + is_valid_printable_32 (pt_buf[6]) + is_valid_printable_32 (pt_buf[7]); - if (correct_b2 != 4) return; - + if (correct_b2 != 4) return; + const u32 r0 = ct_buf[0]; const u32 r1 = ct_buf[1]; const u32 r2 = ct_buf[2]; diff --git a/src/modules/module_31500.c b/src/modules/module_31500.c index 26ec4d0f3..eeaca000f 100644 --- a/src/modules/module_31500.c +++ b/src/modules/module_31500.c @@ -69,7 +69,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; memset (&token, 0, sizeof (hc_token_t)); - + token.token_cnt = 2; token.sep[0] = hashconfig->separator; diff --git a/src/modules/module_31600.c b/src/modules/module_31600.c index dbc87e485..5c98d153f 100644 --- a/src/modules/module_31600.c +++ b/src/modules/module_31600.c @@ -70,7 +70,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; memset (&token, 0, sizeof (hc_token_t)); - + token.token_cnt = 4; token.signatures_cnt = 1; From bf6a4e34bd70aafea63c2efd309252a6cdf26898 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Mon, 20 May 2024 10:49:24 +0100 Subject: [PATCH 030/357] Fix max iteration values https://github.com/hashcat/hashcat/pull/3980#discussion_r1606514918 --- src/modules/module_23400.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index 246b32c54..2e42f50d4 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -167,14 +167,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10); if (iter1 < 1) return (PARSER_SALT_ITERATION); - if (iter1 > 10^10) return (PARSER_SALT_ITERATION); + if (iter1 > 4294967294) return (PARSER_SALT_ITERATION); salt->salt_iter = iter1 - 1; const u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10); if (iter2 < 1) return (PARSER_SALT_ITERATION); - if (iter2 > 10^10) return (PARSER_SALT_ITERATION); + if (iter2 > 4294967294) return (PARSER_SALT_ITERATION); salt->salt_iter2 = iter2 - 1; From f80d916142cf8c3b627b2682246a47045f4eea3a Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Mon, 20 May 2024 16:35:39 +0100 Subject: [PATCH 031/357] Update module_23400.c --- src/modules/module_23400.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index 2e42f50d4..b2a6116e8 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "limits.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -167,14 +168,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10); if (iter1 < 1) return (PARSER_SALT_ITERATION); - if (iter1 > 4294967294) return (PARSER_SALT_ITERATION); + if (iter1 > UINT_MAX) return (PARSER_SALT_ITERATION); salt->salt_iter = iter1 - 1; const u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10); if (iter2 < 1) return (PARSER_SALT_ITERATION); - if (iter2 > 4294967294) return (PARSER_SALT_ITERATION); + if (iter2 > UINT_MAX) return (PARSER_SALT_ITERATION); salt->salt_iter2 = iter2 - 1; From 86ac061c16ae9b1a2aaac94b1501f8ea6c846911 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 <64717060+PenguinKeeper7@users.noreply.github.com> Date: Mon, 20 May 2024 23:57:42 +0100 Subject: [PATCH 032/357] Update src/modules/module_23400.c Co-authored-by: kgolawski --- src/modules/module_23400.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index b2a6116e8..141b6f5b5 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -167,8 +167,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10); - if (iter1 < 1) return (PARSER_SALT_ITERATION); - if (iter1 > UINT_MAX) return (PARSER_SALT_ITERATION); + if (iter1 == 0) return (PARSER_SALT_ITERATION); salt->salt_iter = iter1 - 1; From ad03dcaffa12a16760fb99f064b6c01a5b4a654e Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:23:24 -0400 Subject: [PATCH 033/357] add Apache Shiro 1 algorithm (12150) --- .gitignore | 1 + OpenCL/m12150-pure.cl | 155 +++++++++++++++++++++ src/modules/module_12150.c | 278 +++++++++++++++++++++++++++++++++++++ 3 files changed, 434 insertions(+) create mode 100644 OpenCL/m12150-pure.cl create mode 100644 src/modules/module_12150.c diff --git a/.gitignore b/.gitignore index d8ff600bb..5d6b271d0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ obj/*.o obj/*.a include/CL tools/luks_tests +.vscode/ diff --git a/OpenCL/m12150-pure.cl b/OpenCL/m12150-pure.cl new file mode 100644 index 000000000..0b8c0bd62 --- /dev/null +++ b/OpenCL/m12150-pure.cl @@ -0,0 +1,155 @@ +// m12150-pure.cl +//#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +#define SHA512_DIGEST_LENGTH 64 + +typedef struct shiro1_sha512 +{ + u32 salt_buf[4]; + u32 iterations; +} shiro1_sha512_t; + +typedef struct shiro1_sha512_tmp +{ + u64 dgst[8]; + u64 out[8]; // Final output hash +} shiro1_sha512_tmp_t; + +KERNEL_FQ void m12150_init (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sha512_t)) +{ + const u32 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + /*printf("Salt length: %d\n", salt_bufs[SALT_POS_HOST].salt_len); + printf("Iterations: %d\n", esalt_bufs[DIGESTS_OFFSET_HOST].iterations); + printf("Password: %s length: %d\n", pws[gid].i, pws[gid].pw_len); + printf("Salt: "); + for (int i = 0; i < 4; i++) { + printf("%08x", esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[i]); + } + printf("\n");*/ + + sha512_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha512_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + + sha512_final (&ctx); + + //printf("Initial hash: "); + for (int i = 0; i < 8; i++) { + tmps[gid].dgst[i] = ctx.h[i]; + tmps[gid].out[i] = ctx.h[i]; + //printf("%016llx", ctx.h[i]); + } + //printf("\n"); +} + +KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha512_t)) { + const u32 gid = get_global_id(0); + + if (gid >= GID_CNT) return; + + sha512_ctx_t sha512_ctx; + + // Temporary buffer to hold the digest in u32 format + u32 digest_u32[16]; + + // Convert u64 digest to u32 format manually + digest_u32[0] = h32_from_64_S(tmps[gid].dgst[0]); + digest_u32[1] = l32_from_64_S(tmps[gid].dgst[0]); + digest_u32[2] = h32_from_64_S(tmps[gid].dgst[1]); + digest_u32[3] = l32_from_64_S(tmps[gid].dgst[1]); + digest_u32[4] = h32_from_64_S(tmps[gid].dgst[2]); + digest_u32[5] = l32_from_64_S(tmps[gid].dgst[2]); + digest_u32[6] = h32_from_64_S(tmps[gid].dgst[3]); + digest_u32[7] = l32_from_64_S(tmps[gid].dgst[3]); + digest_u32[8] = h32_from_64_S(tmps[gid].dgst[4]); + digest_u32[9] = l32_from_64_S(tmps[gid].dgst[4]); + digest_u32[10] = h32_from_64_S(tmps[gid].dgst[5]); + digest_u32[11] = l32_from_64_S(tmps[gid].dgst[5]); + digest_u32[12] = h32_from_64_S(tmps[gid].dgst[6]); + digest_u32[13] = l32_from_64_S(tmps[gid].dgst[6]); + digest_u32[14] = h32_from_64_S(tmps[gid].dgst[7]); + digest_u32[15] = l32_from_64_S(tmps[gid].dgst[7]); + + for (u32 i = 0; i < LOOP_CNT; i++) { + sha512_init(&sha512_ctx); + sha512_update_global(&sha512_ctx, digest_u32, SHA512_DIGEST_LENGTH); + sha512_final(&sha512_ctx); + + for (int j = 0; j < 8; j++) { + tmps[gid].dgst[j] = sha512_ctx.h[j]; + } + + // Update the digest_u32 array for the next iteration + digest_u32[0] = h32_from_64_S(tmps[gid].dgst[0]); + digest_u32[1] = l32_from_64_S(tmps[gid].dgst[0]); + digest_u32[2] = h32_from_64_S(tmps[gid].dgst[1]); + digest_u32[3] = l32_from_64_S(tmps[gid].dgst[1]); + digest_u32[4] = h32_from_64_S(tmps[gid].dgst[2]); + digest_u32[5] = l32_from_64_S(tmps[gid].dgst[2]); + digest_u32[6] = h32_from_64_S(tmps[gid].dgst[3]); + digest_u32[7] = l32_from_64_S(tmps[gid].dgst[3]); + digest_u32[8] = h32_from_64_S(tmps[gid].dgst[4]); + digest_u32[9] = l32_from_64_S(tmps[gid].dgst[4]); + digest_u32[10] = h32_from_64_S(tmps[gid].dgst[5]); + digest_u32[11] = l32_from_64_S(tmps[gid].dgst[5]); + digest_u32[12] = h32_from_64_S(tmps[gid].dgst[6]); + digest_u32[13] = l32_from_64_S(tmps[gid].dgst[6]); + digest_u32[14] = h32_from_64_S(tmps[gid].dgst[7]); + digest_u32[15] = l32_from_64_S(tmps[gid].dgst[7]); + } + + // Store the final digest in the tmps buffer + for (int i = 0; i < 8; i++) { + tmps[gid].out[i] = sha512_ctx.h[i]; + } +} + +KERNEL_FQ void m12150_comp (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sha512_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /*printf("Comparing hash: "); + for (int i = 0; i < 8; i++) { + printf("%016llx", tmps[gid].out[i]); + } + printf("\n");*/ + + const u64 lid = get_local_id (0); + + const u64 a = tmps[gid].out[0]; + const u64 b = tmps[gid].out[1]; + + const u32 r0 = l32_from_64_S (a); + const u32 r1 = h32_from_64_S (a); + const u32 r2 = l32_from_64_S (b); + const u32 r3 = h32_from_64_S (b); + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c new file mode 100644 index 000000000..b6360c98f --- /dev/null +++ b/src/modules/module_12150.c @@ -0,0 +1,278 @@ +// https://github.com/hashcat/hashcat/blob/master/docs/hashcat-plugin-development-guide.md +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF; +static const char *HASH_NAME = "Apache Shiro 1 SHA-512"; +static const u64 KERN_TYPE = 12150; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_PREPENDED_SALT + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_ST_BASE64 + | OPTS_TYPE_HASH_COPY; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "admin123"; +static const char *ST_HASH = "$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA=="; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct shiro1_sha512 +{ + u32 salt_buf[4]; + u32 iterations; +} shiro1_sha512_t; + +typedef struct shiro1_sha512_tmp +{ + u64 dgst[8]; + u64 out[8]; // Final output hash +} shiro1_sha512_tmp_t; + +static const char *SIGNATURE_SHIRO1_SHA512 = "$shiro1$"; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (shiro1_sha512_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (shiro1_sha512_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + shiro1_sha512_t *shiro_sha512 = (shiro1_sha512_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 5; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_SHIRO1_SHA512; + + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 7; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 999999; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[3] = '$'; + token.len_min[3] = ((SALT_MIN * 8) / 6) + 0; + token.len_max[3] = ((SALT_MAX * 8) / 6) + 3; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[4] = '$'; + token.len_min[4] = 16; + token.len_max[4] = 256; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + /*for (int i = 0; i < token.token_cnt; i++) { + printf("Token %d: %.*s (length: %d)\n", i, token.len[i], token.buf[i], token.len[i]); + } + printf("\n");*/ + + if (rc_tokenizer != PARSER_OK) { return (rc_tokenizer); } + + u8 tmp_buf[512]; + int tmp_len; + + // iterations + const u8 *iter_pos = token.buf[2]; + const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10); + shiro_sha512->iterations = iter - 1; + salt->salt_iter = iter - 1; + + // salt + const u8 *salt_pos = token.buf[3]; + const int salt_len = token.len[3]; + memset (tmp_buf, 0, sizeof (tmp_buf)); + //printf("Salt (b64): %.*s\n", salt_len, salt_pos); + tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); + /*printf("Decoded Salt (hex): "); + for (size_t i = 0; i < tmp_len; i++) { + printf("%02x", tmp_buf[i]); + } + printf("\n");*/ + memcpy (shiro_sha512->salt_buf, tmp_buf, tmp_len); + salt->salt_len = tmp_len; + salt->salt_buf[0] = shiro_sha512->salt_buf[0]; + salt->salt_buf[1] = shiro_sha512->salt_buf[1]; + salt->salt_buf[2] = shiro_sha512->salt_buf[2]; + salt->salt_buf[3] = shiro_sha512->salt_buf[3]; + // Print the salt as u32 values + /*printf("Salt (interpreted as u32): "); + for (int i = 0; i < 4; i++) { + printf("%08x", salt->salt_buf[i]); + } + printf("\n");*/ + // Print the salt as bytes for comparison + /*printf("Salt (interpreted as bytes): "); + for (int i = 0; i < tmp_len; i++) { + printf("%02x", ((u8 *)salt->salt_buf)[i]); + } + printf("\n");*/ + + // hash + const u8 *hash_pos = token.buf[4]; + const int hash_len = token.len[4]; + memset (tmp_buf, 0, sizeof (tmp_buf)); + tmp_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf); + if (tmp_len < 64) return (PARSER_HASH_LENGTH); + memcpy (digest, tmp_buf, 64); + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + /*printf("Hash: "); + for (int i = 0; i < 8; i++) { + printf("%016llx", digest[i]); + } + printf("\n");*/ + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const int line_len = snprintf (line_buf, line_size, "%s", hash_info->orighash); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} \ No newline at end of file From d0dc41f98daba2b4a5da351c30c41bd0a7dcf3b2 Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:43:00 -0400 Subject: [PATCH 034/357] PR comments polish 1 --- .gitignore | 1 - OpenCL/m12150-pure.cl | 30 +++++++----------------------- docs/credits.txt | 3 +++ src/modules/module_12150.c | 36 ++++++------------------------------ 4 files changed, 16 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 5d6b271d0..d8ff600bb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,3 @@ obj/*.o obj/*.a include/CL tools/luks_tests -.vscode/ diff --git a/OpenCL/m12150-pure.cl b/OpenCL/m12150-pure.cl index 0b8c0bd62..5b837c13d 100644 --- a/OpenCL/m12150-pure.cl +++ b/OpenCL/m12150-pure.cl @@ -1,5 +1,7 @@ -// m12150-pure.cl -//#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ #define NEW_SIMD_CODE @@ -39,28 +41,16 @@ KERNEL_FQ void m12150_init (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sh sha512_init (&ctx); - /*printf("Salt length: %d\n", salt_bufs[SALT_POS_HOST].salt_len); - printf("Iterations: %d\n", esalt_bufs[DIGESTS_OFFSET_HOST].iterations); - printf("Password: %s length: %d\n", pws[gid].i, pws[gid].pw_len); - printf("Salt: "); - for (int i = 0; i < 4; i++) { - printf("%08x", esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[i]); - } - printf("\n");*/ - sha512_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); sha512_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); sha512_final (&ctx); - //printf("Initial hash: "); for (int i = 0; i < 8; i++) { tmps[gid].dgst[i] = ctx.h[i]; tmps[gid].out[i] = ctx.h[i]; - //printf("%016llx", ctx.h[i]); } - //printf("\n"); } KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha512_t)) { @@ -92,9 +82,9 @@ KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha5 digest_u32[15] = l32_from_64_S(tmps[gid].dgst[7]); for (u32 i = 0; i < LOOP_CNT; i++) { - sha512_init(&sha512_ctx); - sha512_update_global(&sha512_ctx, digest_u32, SHA512_DIGEST_LENGTH); - sha512_final(&sha512_ctx); + sha512_init (&sha512_ctx); + sha512_update (&sha512_ctx, digest_u32, SHA512_DIGEST_LENGTH); + sha512_final (&sha512_ctx); for (int j = 0; j < 8; j++) { tmps[gid].dgst[j] = sha512_ctx.h[j]; @@ -131,12 +121,6 @@ KERNEL_FQ void m12150_comp (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sh if (gid >= GID_CNT) return; - /*printf("Comparing hash: "); - for (int i = 0; i < 8; i++) { - printf("%016llx", tmps[gid].out[i]); - } - printf("\n");*/ - const u64 lid = get_local_id (0); const u64 a = tmps[gid].out[0]; diff --git a/docs/credits.txt b/docs/credits.txt index f126840c8..f8779c6aa 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -85,4 +85,7 @@ Brandon Chalk (@brandoncasaba) Jamie Riden * Web2py pbkdf2-sha512 plugin +Dylan Evans (@fin3ss3g0d) +* Apache Shiro 1 SHA-512 plugin + !!! All the package maintainers of hashcat !!! diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c index b6360c98f..91d1c1e6f 100644 --- a/src/modules/module_12150.c +++ b/src/modules/module_12150.c @@ -1,4 +1,8 @@ -// https://github.com/hashcat/hashcat/blob/master/docs/hashcat-plugin-development-guide.md +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + #include "common.h" #include "types.h" #include "modules.h" @@ -120,11 +124,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); - /*for (int i = 0; i < token.token_cnt; i++) { - printf("Token %d: %.*s (length: %d)\n", i, token.len[i], token.buf[i], token.len[i]); - } - printf("\n");*/ - if (rc_tokenizer != PARSER_OK) { return (rc_tokenizer); } u8 tmp_buf[512]; @@ -140,31 +139,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[3]; const int salt_len = token.len[3]; memset (tmp_buf, 0, sizeof (tmp_buf)); - //printf("Salt (b64): %.*s\n", salt_len, salt_pos); tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); - /*printf("Decoded Salt (hex): "); - for (size_t i = 0; i < tmp_len; i++) { - printf("%02x", tmp_buf[i]); - } - printf("\n");*/ memcpy (shiro_sha512->salt_buf, tmp_buf, tmp_len); salt->salt_len = tmp_len; salt->salt_buf[0] = shiro_sha512->salt_buf[0]; salt->salt_buf[1] = shiro_sha512->salt_buf[1]; salt->salt_buf[2] = shiro_sha512->salt_buf[2]; salt->salt_buf[3] = shiro_sha512->salt_buf[3]; - // Print the salt as u32 values - /*printf("Salt (interpreted as u32): "); - for (int i = 0; i < 4; i++) { - printf("%08x", salt->salt_buf[i]); - } - printf("\n");*/ - // Print the salt as bytes for comparison - /*printf("Salt (interpreted as bytes): "); - for (int i = 0; i < tmp_len; i++) { - printf("%02x", ((u8 *)salt->salt_buf)[i]); - } - printf("\n");*/ // hash const u8 *hash_pos = token.buf[4]; @@ -181,11 +162,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[5] = byte_swap_64 (digest[5]); digest[6] = byte_swap_64 (digest[6]); digest[7] = byte_swap_64 (digest[7]); - /*printf("Hash: "); - for (int i = 0; i < 8; i++) { - printf("%016llx", digest[i]); - } - printf("\n");*/ return (PARSER_OK); } @@ -275,4 +251,4 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_tmp_size = module_tmp_size; module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; -} \ No newline at end of file +} From b19101ed0892b5258224dfeb70ed45197e25e6eb Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:53:45 -0400 Subject: [PATCH 035/357] PR comments polish 2 --- OpenCL/m12150-pure.cl | 6 +-- src/modules/module_12150.c | 81 +++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/OpenCL/m12150-pure.cl b/OpenCL/m12150-pure.cl index 5b837c13d..e6d8f56f0 100644 --- a/OpenCL/m12150-pure.cl +++ b/OpenCL/m12150-pure.cl @@ -31,7 +31,7 @@ typedef struct shiro1_sha512_tmp u64 out[8]; // Final output hash } shiro1_sha512_tmp_t; -KERNEL_FQ void m12150_init (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sha512_t)) +KERNEL_FQ void m12150_init (KERN_ATTR_TMPS (shiro1_sha512_tmp_t)) { const u32 gid = get_global_id (0); @@ -53,7 +53,7 @@ KERNEL_FQ void m12150_init (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sh } } -KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha512_t)) { +KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS (shiro1_sha512_tmp_t)) { const u32 gid = get_global_id(0); if (gid >= GID_CNT) return; @@ -115,7 +115,7 @@ KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha5 } } -KERNEL_FQ void m12150_comp (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sha512_t)) +KERNEL_FQ void m12150_comp (KERN_ATTR_TMPS (shiro1_sha512_tmp_t)) { const u64 gid = get_global_id (0); diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c index 91d1c1e6f..82fb91abe 100644 --- a/src/modules/module_12150.c +++ b/src/modules/module_12150.c @@ -32,20 +32,20 @@ static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "admin123"; static const char *ST_HASH = "$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA=="; -u32 module_attack_exec (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 ATTACK_EXEC; } -u32 module_dgst_pos0 (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 DGST_POS0; } -u32 module_dgst_pos1 (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 DGST_POS1; } -u32 module_dgst_pos2 (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 DGST_POS2; } -u32 module_dgst_pos3 (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 DGST_POS3; } -u32 module_dgst_size (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 DGST_SIZE; } -u32 module_hash_category (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 HASH_CATEGORY; } -const char *module_hash_name (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 HASH_NAME; } -u64 module_kern_type (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 KERN_TYPE; } -u32 module_opti_type (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 OPTI_TYPE; } -u64 module_opts_type (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 OPTS_TYPE; } -u32 module_salt_type (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 SALT_TYPE; } -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; } +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } typedef struct shiro1_sha512 { @@ -59,7 +59,7 @@ typedef struct shiro1_sha512_tmp u64 out[8]; // Final output hash } shiro1_sha512_tmp_t; -static const char *SIGNATURE_SHIRO1_SHA512 = "$shiro1$"; +static const char *SIGNATURE_SHIRO1_SHA512 = "$shiro1$SHA-512$"; u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { @@ -85,71 +85,62 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; - shiro1_sha512_t *shiro_sha512 = (shiro1_sha512_t *) esalt_buf; hc_token_t token; memset (&token, 0, sizeof (hc_token_t)); - token.token_cnt = 5; + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SHIRO1_SHA512; - token.len[0] = 8; + token.len[0] = 16; token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len[1] = 7; - token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; - - token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 999999; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len_min[1] = 1; + token.len_max[1] = 999999; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.sep[3] = '$'; - token.len_min[3] = ((SALT_MIN * 8) / 6) + 0; - token.len_max[3] = ((SALT_MAX * 8) / 6) + 3; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[2] = '$'; + token.len_min[2] = ((SALT_MIN * 8) / 6) + 0; + token.len_max[2] = ((SALT_MAX * 8) / 6) + 3; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 256; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[3] = '$'; + token.len_min[3] = 16; + token.len_max[3] = 256; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); - if (rc_tokenizer != PARSER_OK) { return (rc_tokenizer); } + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); u8 tmp_buf[512]; int tmp_len; // iterations - const u8 *iter_pos = token.buf[2]; + const u8 *iter_pos = token.buf[1]; const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10); - shiro_sha512->iterations = iter - 1; salt->salt_iter = iter - 1; // salt - const u8 *salt_pos = token.buf[3]; - const int salt_len = token.len[3]; + const u8 *salt_pos = token.buf[2]; + const int salt_len = token.len[2]; memset (tmp_buf, 0, sizeof (tmp_buf)); tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); - memcpy (shiro_sha512->salt_buf, tmp_buf, tmp_len); + if (tmp_len > SALT_MAX) return (PARSER_SALT_LENGTH); + memcpy (salt->salt_buf, tmp_buf, tmp_len); salt->salt_len = tmp_len; - salt->salt_buf[0] = shiro_sha512->salt_buf[0]; - salt->salt_buf[1] = shiro_sha512->salt_buf[1]; - salt->salt_buf[2] = shiro_sha512->salt_buf[2]; - salt->salt_buf[3] = shiro_sha512->salt_buf[3]; // hash - const u8 *hash_pos = token.buf[4]; - const int hash_len = token.len[4]; + const u8 *hash_pos = token.buf[3]; + const int hash_len = token.len[3]; memset (tmp_buf, 0, sizeof (tmp_buf)); tmp_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf); if (tmp_len < 64) return (PARSER_HASH_LENGTH); From 02b1a7930bf7c8f7e3263c22a07395ca9804b516 Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:10:09 -0400 Subject: [PATCH 036/357] PR comments polish 3 --- OpenCL/m12150-pure.cl | 6 ------ src/modules/module_12150.c | 15 +-------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/OpenCL/m12150-pure.cl b/OpenCL/m12150-pure.cl index e6d8f56f0..2768ee295 100644 --- a/OpenCL/m12150-pure.cl +++ b/OpenCL/m12150-pure.cl @@ -19,12 +19,6 @@ #define SHA512_DIGEST_LENGTH 64 -typedef struct shiro1_sha512 -{ - u32 salt_buf[4]; - u32 iterations; -} shiro1_sha512_t; - typedef struct shiro1_sha512_tmp { u64 dgst[8]; diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c index 82fb91abe..9f6bd39dd 100644 --- a/src/modules/module_12150.c +++ b/src/modules/module_12150.c @@ -47,12 +47,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE 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; } -typedef struct shiro1_sha512 -{ - u32 salt_buf[4]; - u32 iterations; -} shiro1_sha512_t; - typedef struct shiro1_sha512_tmp { u64 dgst[8]; @@ -61,13 +55,6 @@ typedef struct shiro1_sha512_tmp static const char *SIGNATURE_SHIRO1_SHA512 = "$shiro1$SHA-512$"; -u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u64 esalt_size = (const u64) sizeof (shiro1_sha512_t); - - return esalt_size; -} - u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (shiro1_sha512_tmp_t); @@ -184,7 +171,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_dgst_pos3 = module_dgst_pos3; module_ctx->module_dgst_size = module_dgst_size; module_ctx->module_dictstat_disable = MODULE_DEFAULT; - module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_esalt_size = MODULE_DEFAULT; module_ctx->module_extra_buffer_size = MODULE_DEFAULT; module_ctx->module_extra_tmp_size = MODULE_DEFAULT; module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; From 99b5fa1338cf8a6ec7389b3492d68a0020054338 Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:22:41 -0400 Subject: [PATCH 037/357] Create m12150.pm --- tools/test_modules/m12150.pm | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tools/test_modules/m12150.pm diff --git a/tools/test_modules/m12150.pm b/tools/test_modules/m12150.pm new file mode 100644 index 000000000..b1ae4bd24 --- /dev/null +++ b/tools/test_modules/m12150.pm @@ -0,0 +1,77 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use MIME::Base64 qw(encode_base64 decode_base64); +use Digest::SHA qw(sha512); + +sub module_constraints { + return [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]]; +} + +sub module_generate_hash { + my $word = shift; + my $salt = shift; + my $iterations = shift // 1024; + + if (length $salt == 0) { + $salt = random_bytes(16); + } + + # Initialize the hash with the salt and password + my $ctx = Digest::SHA->new(512); + $ctx->add($salt); + $ctx->add($word); + + my $digest = $ctx->digest; + + # Perform the iterations + for (my $i = 1; $i < $iterations; $i++) { + $ctx = Digest::SHA->new(512); + $ctx->add($digest); + $digest = $ctx->digest; + } + + # Encode the final hash and salt + my $hash_encoded = encode_base64($digest, ""); + my $salt_encoded = encode_base64($salt, ""); + + # Format the final hash + my $hash = sprintf('$shiro1$SHA-512$%i$%s$%s', $iterations, $salt_encoded, $hash_encoded); + + return $hash; +} + +sub module_verify_hash { + my $line = shift; + + # Split the input line into components + my ($digest, $word) = split(/:/, $line, 2); + + return unless defined $digest; + return unless defined $word; + + # Match and capture the hash format components + if ($digest =~ /^\$shiro1\$SHA-512\$(\d+)\$([A-Za-z0-9+\/=]+)\$([A-Za-z0-9+\/=]+)$/) { + my ($iterations, $salt_encoded, $hash_encoded) = ($1, $2, $3); + + # Decode base64 encoded salt + my $salt = decode_base64($salt_encoded); + + # Verify the hash + my $word_packed = pack_if_HEX_notation($word); + my $new_hash = module_generate_hash($word_packed, $salt, $iterations); + + return ($new_hash, $word); + } + + return; # Return undefined if the digest doesn't match the expected format +} + +1; From 9bf2c527a641adaa0532d39710d5b3a5321cbccc Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:51:35 -0400 Subject: [PATCH 038/357] PR comments polish 4 --- src/modules/module_12150.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c index 9f6bd39dd..5c84c7696 100644 --- a/src/modules/module_12150.c +++ b/src/modules/module_12150.c @@ -29,8 +29,8 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_ST_BASE64 | OPTS_TYPE_HASH_COPY; static const u32 SALT_TYPE = SALT_TYPE_GENERIC; -static const char *ST_PASS = "admin123"; -static const char *ST_HASH = "$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA=="; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$shiro1$SHA-512$1024$WobJGSjbUhsMdaILomMOdw==$9uptGJ24vzZCqZI55F77N7xjUxGlVrK5aCmAwIrV1vwDmFM4akE6Hmd23Aj8ANLSUdIEkHLZ6SnoitZbOsoQNQ=="; u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } From 1aeeced038511aba1bf398afcfa7e639f3b25c42 Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:37:23 -0400 Subject: [PATCH 039/357] Create tools/shiro1-to-hashcat.py --- tools/shiro1-to-hashcat.py | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/shiro1-to-hashcat.py diff --git a/tools/shiro1-to-hashcat.py b/tools/shiro1-to-hashcat.py new file mode 100644 index 000000000..9619530ef --- /dev/null +++ b/tools/shiro1-to-hashcat.py @@ -0,0 +1,56 @@ +import os +import re +import glob +import argparse + +def extract_hashes_from_pcl(file_path): + shiro_pattern = re.compile(br'\$shiro1\$SHA-512\$(\d+)\$[A-Za-z0-9+/=]+\$[A-Za-z0-9+/=]+') + + try: + with open(file_path, 'rb') as f: + data = f.read() + + matches = shiro_pattern.finditer(data) + extracted_hashes = [] + + for match in matches: + full_match = match.group(0).decode() + print(f'[+] Found Shiro 1 hash: {full_match}') + extracted_hashes.append(full_match) + + if not extracted_hashes: + print(f"No Shiro 1 hashes found in {file_path}") + return None + + return extracted_hashes + + except Exception as e: + print(f"Failed to parse {file_path}: {e}") + return None + +def main(): + parser = argparse.ArgumentParser(description="Extract Apache Shiro 1 hashes from .pcl files for use with Hashcat.") + parser.add_argument("input_dir", help="Directory path containing the .pcl files") + parser.add_argument("output_file", help="Output file to save the hashes") + + args = parser.parse_args() + + pcl_files = glob.glob(os.path.join(args.input_dir, '*.pcl')) + all_hashes = [] + + for pcl_file in pcl_files: + print(f"Processing {pcl_file}") + hashes = extract_hashes_from_pcl(pcl_file) + if hashes: + all_hashes.extend(hashes) + + if all_hashes: + with open(args.output_file, 'w') as f: + for hashcat_hash in all_hashes: + f.write(f"{hashcat_hash}\n") + print(f"Extracted hashes have been saved to {args.output_file}!\nTotal hashes: {len(all_hashes)}\nRun hashcat with mode 12150!") + else: + print("No hashes were extracted.") + +if __name__ == '__main__': + main() From d299b2833eb80f56e555efbdf486d3f48db51c9b Mon Sep 17 00:00:00 2001 From: Flaggx1 Date: Thu, 25 Jul 2024 07:07:27 -0400 Subject: [PATCH 040/357] Reduce user-defined charsets to 8. Remove unnecessary code. --- include/types.h | 2 -- src/brain.c | 14 -------------- src/mpsp.c | 19 ++----------------- src/status.c | 23 ++++++++++------------- src/usage.c | 1 - src/user_options.c | 34 ++++------------------------------ 6 files changed, 16 insertions(+), 77 deletions(-) diff --git a/include/types.h b/include/types.h index 02b83da2b..961cde915 100644 --- a/include/types.h +++ b/include/types.h @@ -759,7 +759,6 @@ typedef enum user_options_map IDX_CUSTOM_CHARSET_6 = '6', IDX_CUSTOM_CHARSET_7 = '7', IDX_CUSTOM_CHARSET_8 = '8', - IDX_CUSTOM_CHARSET_9 = '9', IDX_DEBUG_FILE = 0xff12, IDX_DEBUG_MODE = 0xff13, IDX_DEPRECATED_CHECK_DISABLE = 0xff14, @@ -2396,7 +2395,6 @@ typedef struct user_options char *brain_session_whitelist; #endif char *cpu_affinity; - char *custom_charset_9; char *debug_file; char *induction_dir; char *keyboard_layout_mapping; diff --git a/src/brain.c b/src/brain.c index 646a334d3..f313b5536 100644 --- a/src/brain.c +++ b/src/brain.c @@ -373,13 +373,6 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, custom_charset_8, strlen (custom_charset_8)); } - - if (user_options->custom_charset_9) - { - const char *custom_charset_9 = user_options->custom_charset_9; - - XXH64_update (state, custom_charset_9, strlen (custom_charset_9)); - } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) @@ -469,13 +462,6 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, custom_charset_8, strlen (custom_charset_8)); } - if (user_options->custom_charset_9) - { - const char *custom_charset_9 = user_options->custom_charset_9; - - XXH64_update (state, custom_charset_9, strlen (custom_charset_9)); - } - const int hex_wordlist = user_options->hex_wordlist; XXH64_update (state, &hex_wordlist, sizeof (hex_wordlist)); diff --git a/src/mpsp.c b/src/mpsp.c index d694dc242..02d5b7f45 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -18,7 +18,7 @@ static const char *const DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; -#define MAX_MFS 10 // 9*charset, 1*mask +#define MAX_MFS 9 // 8*charset, 1*mask static int sp_comp_val (const void *p1, const void *p2) { @@ -326,9 +326,6 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_ case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; } rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, mp_usr, mp_usr_offset); break; - case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; } - rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, mp_usr, mp_usr_offset); - break; case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); break; default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", in_buf); @@ -454,9 +451,6 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; } rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, css_buf, css_pos); break; - case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; } - rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, css_buf, css_pos); - break; case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos); break; default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", mask_buf); @@ -1446,7 +1440,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; mask_ctx->mp_sys = (cs_t *) hccalloc (8, sizeof (cs_t)); - mask_ctx->mp_usr = (cs_t *) hccalloc (9, sizeof (cs_t)); + mask_ctx->mp_usr = (cs_t *) hccalloc (8, sizeof (cs_t)); mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t)); mask_ctx->css_cnt = 0; @@ -1477,7 +1471,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->custom_charset_6) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_6, 5) == -1) return -1; } if (user_options->custom_charset_7) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_7, 6) == -1) return -1; } if (user_options->custom_charset_8) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7) == -1) return -1; } - if (user_options->custom_charset_9) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8) == -1) return -1; } if (user_options->benchmark == true) { @@ -1777,7 +1770,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) mfs_buf[5].mf_len = 0; mfs_buf[6].mf_len = 0; mfs_buf[7].mf_len = 0; - mfs_buf[8].mf_len = 0; size_t mfs_cnt = 0; @@ -1839,7 +1831,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_6 = NULL; user_options->custom_charset_7 = NULL; user_options->custom_charset_8 = NULL; - user_options->custom_charset_9 = NULL; mp_reset_usr (mask_ctx->mp_usr, 0); mp_reset_usr (mask_ctx->mp_usr, 1); @@ -1849,7 +1840,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) mp_reset_usr (mask_ctx->mp_usr, 5); mp_reset_usr (mask_ctx->mp_usr, 6); mp_reset_usr (mask_ctx->mp_usr, 7); - mp_reset_usr (mask_ctx->mp_usr, 8); for (size_t i = 0; i < mfs_cnt; i++) { @@ -1894,11 +1884,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_8 = mfs_buf[7].mf_buf; mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7); break; - - case 8: - user_options->custom_charset_9 = mfs_buf[8].mf_buf; - mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8); - break; } } diff --git a/src/status.c b/src/status.c index 4c973bdab..ac661acd4 100644 --- a/src/status.c +++ b/src/status.c @@ -398,7 +398,6 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx) if (user_options->custom_charset_6) has_mask_cs = true; if (user_options->custom_charset_7) has_mask_cs = true; if (user_options->custom_charset_8) has_mask_cs = true; - if (user_options->custom_charset_9) has_mask_cs = true; if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)) { @@ -787,23 +786,21 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) const char *custom_charset_6 = user_options->custom_charset_6; const char *custom_charset_7 = user_options->custom_charset_7; const char *custom_charset_8 = user_options->custom_charset_8; - const char *custom_charset_9 = user_options->custom_charset_9; - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL) || (custom_charset_9 != NULL)) + if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL)); { char *tmp_buf; - if (custom_charset_1 == NULL) custom_charset_1 = "Undef"; - if (custom_charset_2 == NULL) custom_charset_2 = "Undef"; - if (custom_charset_3 == NULL) custom_charset_3 = "Undef"; - if (custom_charset_4 == NULL) custom_charset_4 = "Undef"; - if (custom_charset_5 == NULL) custom_charset_5 = "Undef"; - if (custom_charset_6 == NULL) custom_charset_6 = "Undef"; - if (custom_charset_7 == NULL) custom_charset_7 = "Undef"; - if (custom_charset_8 == NULL) custom_charset_8 = "Undef"; - if (custom_charset_9 == NULL) custom_charset_9 = "Undef"; + if (custom_charset_1 == NULL) custom_charset_1 = "N/A"; + if (custom_charset_2 == NULL) custom_charset_2 = "N/A"; + if (custom_charset_3 == NULL) custom_charset_3 = "N/A"; + if (custom_charset_4 == NULL) custom_charset_4 = "N/A"; + if (custom_charset_5 == NULL) custom_charset_5 = "N/A"; + if (custom_charset_6 == NULL) custom_charset_6 = "N/A"; + if (custom_charset_7 == NULL) custom_charset_7 = "N/A"; + if (custom_charset_8 == NULL) custom_charset_8 = "N/A"; - hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s, -9 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8, custom_charset_9); + hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8); return tmp_buf; } diff --git a/src/usage.c b/src/usage.c index 0b735fe0d..51f658981 100644 --- a/src/usage.c +++ b/src/usage.c @@ -134,7 +134,6 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -6, --custom-charset6 | CS | User-defined charset ?6 |", " -7, --custom-charset7 | CS | User-defined charset ?7 |", " -8, --custom-charset8 | CS | User-defined charset ?8 |", - " -9, --custom-charset9 | CS | User-defined charset ?9 |", " --identify | | Shows all supported algorithms for input hashes | --identify my.hash", " -i, --increment | | Enable mask increment mode |", " --increment-min | Num | Start mask incrementing at X | --increment-min=4", diff --git a/src/user_options.c b/src/user_options.c index 5093301e9..427351939 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -21,9 +21,9 @@ #endif #ifdef WITH_BRAIN -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:z"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:iIbw:OMSY:z"; #else -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:iIbw:OMSY:"; #endif static char *const SEPARATOR = ":"; @@ -55,7 +55,6 @@ static const struct option long_options[] = {"custom-charset6", required_argument, NULL, IDX_CUSTOM_CHARSET_6}, {"custom-charset7", required_argument, NULL, IDX_CUSTOM_CHARSET_7}, {"custom-charset8", required_argument, NULL, IDX_CUSTOM_CHARSET_8}, - {"custom-charset9", required_argument, NULL, IDX_CUSTOM_CHARSET_9}, {"debug-file", required_argument, NULL, IDX_DEBUG_FILE}, {"debug-mode", required_argument, NULL, IDX_DEBUG_MODE}, {"deprecated-check-disable", no_argument, NULL, IDX_DEPRECATED_CHECK_DISABLE}, @@ -171,11 +170,6 @@ static const char *const RULE_BUF_L = ":"; static const char *const DEF_MASK_CS_1 = "?l?d?u"; static const char *const DEF_MASK_CS_2 = "?l?d"; static const char *const DEF_MASK_CS_3 = "?l?d*!$@_"; -static const char *const DEF_MASK_CS_4 = "a"; -static const char *const DEF_MASK_CS_5 = "b"; -static const char *const DEF_MASK_CS_6 = "c"; -static const char *const DEF_MASK_CS_7 = "d"; -static const char *const DEF_MASK_CS_8 = "e"; int user_options_init (hashcat_ctx_t *hashcat_ctx) { @@ -217,7 +211,6 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_6 = NULL; user_options->custom_charset_7 = NULL; user_options->custom_charset_8 = NULL; - user_options->custom_charset_9 = NULL; user_options->debug_file = NULL; user_options->debug_mode = DEBUG_MODE; user_options->deprecated_check = DEPRECATED_CHECK; @@ -551,7 +544,6 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_CUSTOM_CHARSET_6: user_options->custom_charset_6 = optarg; break; case IDX_CUSTOM_CHARSET_7: user_options->custom_charset_7 = optarg; break; case IDX_CUSTOM_CHARSET_8: user_options->custom_charset_8 = optarg; break; - case IDX_CUSTOM_CHARSET_9: user_options->custom_charset_9 = optarg; break; case IDX_SLOW_CANDIDATES: user_options->slow_candidates = true; break; #ifdef WITH_BRAIN case IDX_BRAIN_CLIENT: user_options->brain_client = true; break; @@ -1353,8 +1345,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) || (user_options->custom_charset_5 != NULL) || (user_options->custom_charset_6 != NULL) || (user_options->custom_charset_7 != NULL) - || (user_options->custom_charset_8 != NULL) - || (user_options->custom_charset_9 != NULL)) + || (user_options->custom_charset_8 != NULL)) { if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION)) { @@ -1526,8 +1517,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) || (user_options->custom_charset_5 != NULL) || (user_options->custom_charset_6 != NULL) || (user_options->custom_charset_7 != NULL) - || (user_options->custom_charset_8 != NULL) - || (user_options->custom_charset_9 != NULL)) + || (user_options->custom_charset_8 != NULL)) { if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { @@ -2071,11 +2061,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; - user_options->custom_charset_4 = DEF_MASK_CS_4; - user_options->custom_charset_5 = DEF_MASK_CS_5; - user_options->custom_charset_6 = DEF_MASK_CS_6; - user_options->custom_charset_7 = DEF_MASK_CS_7; - user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -2087,11 +2072,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; - user_options->custom_charset_4 = DEF_MASK_CS_4; - user_options->custom_charset_5 = DEF_MASK_CS_5; - user_options->custom_charset_6 = DEF_MASK_CS_6; - user_options->custom_charset_7 = DEF_MASK_CS_7; - user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -2103,11 +2083,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_1 = DEF_MASK_CS_1; user_options->custom_charset_2 = DEF_MASK_CS_2; user_options->custom_charset_3 = DEF_MASK_CS_3; - user_options->custom_charset_4 = DEF_MASK_CS_4; - user_options->custom_charset_5 = DEF_MASK_CS_5; - user_options->custom_charset_6 = DEF_MASK_CS_6; - user_options->custom_charset_7 = DEF_MASK_CS_7; - user_options->custom_charset_8 = DEF_MASK_CS_8; user_options->increment = true; } @@ -3248,7 +3223,6 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_string (user_options->custom_charset_6); logfile_top_string (user_options->custom_charset_7); logfile_top_string (user_options->custom_charset_8); - logfile_top_string (user_options->custom_charset_9); logfile_top_string (user_options->debug_file); logfile_top_string (user_options->encoding_from); logfile_top_string (user_options->encoding_to); From 4e0fc2099eef1f2e367a4290fdc305f9edb710d1 Mon Sep 17 00:00:00 2001 From: Flaggx1 Date: Thu, 25 Jul 2024 07:29:26 -0400 Subject: [PATCH 041/357] Removed incorrect semicolon and blank line --- src/brain.c | 1 - src/status.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/brain.c b/src/brain.c index f313b5536..2aec26300 100644 --- a/src/brain.c +++ b/src/brain.c @@ -374,7 +374,6 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx) XXH64_update (state, custom_charset_8, strlen (custom_charset_8)); } } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { const u64 wordlist_hash = brain_compute_attack_wordlist (straight_ctx->dict); diff --git a/src/status.c b/src/status.c index ac661acd4..b33fba85e 100644 --- a/src/status.c +++ b/src/status.c @@ -787,7 +787,7 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) const char *custom_charset_7 = user_options->custom_charset_7; const char *custom_charset_8 = user_options->custom_charset_8; - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL)); + if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL)) { char *tmp_buf; From 3e48db8206721d67c6db4c46bc9cd5e7ed1aad66 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Wed, 31 Jul 2024 15:40:09 +0100 Subject: [PATCH 042/357] Show all autotune setting changes in -b Previous behaviour was to only show the first autotune setting, this change makes it so it shows everything if it's changed as there's no reason to hide it and is safer to show everything that's changed --- src/user_options.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..11e644929 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -2155,20 +2155,20 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) { event_log_info (hashcat_ctx, "* --kernel-accel=%u", user_options->kernel_accel); } - else if (user_options->kernel_loops_chgd == true) + + if (user_options->kernel_loops_chgd == true) { event_log_info (hashcat_ctx, "* --kernel-loops=%u", user_options->kernel_loops); } - else if (user_options->kernel_threads_chgd == true) + + if (user_options->kernel_threads_chgd == true) { event_log_info (hashcat_ctx, "* --kernel-threads=%u", user_options->kernel_threads); } - else + + if (user_options->workload_profile_chgd == true) { - if (user_options->workload_profile_chgd == true) - { - event_log_info (hashcat_ctx, "* --workload-profile=%u", user_options->workload_profile); - } + event_log_info (hashcat_ctx, "* --workload-profile=%u", user_options->workload_profile); } event_log_info (hashcat_ctx, NULL); @@ -2219,20 +2219,20 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) { event_log_info (hashcat_ctx, "# option: --kernel-accel=%u", user_options->kernel_accel); } - else if (user_options->kernel_loops_chgd == true) + + if (user_options->kernel_loops_chgd == true) { event_log_info (hashcat_ctx, "# option: --kernel-loops=%u", user_options->kernel_loops); } - else if (user_options->kernel_threads_chgd == true) + + if (user_options->kernel_threads_chgd == true) { event_log_info (hashcat_ctx, "# option: --kernel-threads=%u", user_options->kernel_threads); } - else + + if (user_options->workload_profile_chgd == true) { - if (user_options->workload_profile_chgd == true) - { - event_log_info (hashcat_ctx, "# option: --workload-profile=%u", user_options->workload_profile); - } + event_log_info (hashcat_ctx, "# option: --workload-profile=%u", user_options->workload_profile); } } } From dda0cc2d4b7433a9907dedf0b3933c7b59bec967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Go=C5=82awski?= Date: Wed, 11 Sep 2024 10:53:22 +0200 Subject: [PATCH 043/357] Fix hash encoding in WinZip format --- src/modules/module_13600.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module_13600.c b/src/modules/module_13600.c index f927d5761..0000f26a1 100644 --- a/src/modules/module_13600.c +++ b/src/modules/module_13600.c @@ -383,7 +383,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE snprintf (auth_tmp + j, 3, "%02x", ptr[i]); } - const int line_len = snprintf (line_buf, line_size, "%s*%u*%u*%u*%s*%x*%x*%s*%s*%s", + const int line_len = snprintf (line_buf, line_size, "%s*%u*%u*%u*%s*%04x*%x*%s*%s*%s", SIGNATURE_ZIP2_START, zip2->type, zip2->mode, From 55ca7fb27b3167ca9fe31a3f1b580642960d23a5 Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:19:27 +0100 Subject: [PATCH 044/357] Add bitlocker2hashcat.py For generating hashes for mode 22100. Hashcat supports modes $bitlocker$0$ and $bitlocker$1$ and therefore this script will output hashes that relate to a VMK protected by a user password only. Script created since bitlocker2john takes an extremely long time to run and sometimes fails to output a hash, or outputs incorrect information. Script created using information at https://github.com/libyal/libbde/blob/main/documentation/BitLocker%20Drive%20Encryption%20(BDE)%20format.asciidoc#encryption_methods and tested on Windows hard drives and USB sticks. --- tools/bitlocker2hashcat.py | 234 +++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 tools/bitlocker2hashcat.py diff --git a/tools/bitlocker2hashcat.py b/tools/bitlocker2hashcat.py new file mode 100644 index 000000000..56e185311 --- /dev/null +++ b/tools/bitlocker2hashcat.py @@ -0,0 +1,234 @@ +# Construct a hash for use with hashcat mode 22100 +# Usage: python3 bitlocker2hashcat.py -o +# Hashcat supports modes $bitlocker$0$ and $bitlocker$1$ and therefore this script will output hashes that relate to a VMK protected by a user password only. +# It is not possible to create a hash for VMKs protected by a TPM, and is infeasible to attempt to crack a hash of the recovery password. +# Refs: https://github.com/libyal/libbde/blob/main/documentation/BitLocker%20Drive%20Encryption%20(BDE)%20format.asciidoc#encryption_methods + +import argparse + +BITLOCKER_SIGNATURE = '-FVE-FS-' +BITLOCKER_TO_GO_SIGNATURE = 'MSWIN4.1' +BITLOCKER_GUIDS = {'4967D63B-2E29-4AD8-8399-F6A339E3D001' : 'BitLocker', '4967D63B-2E29-4AD8-8399-F6A339E3D01' : 'BitLocker To Go', '92A84D3B-DD80-4D0E-9E4E-B1E3284EAED8' : 'BitLocker Used Disk Space Only'} +PROTECTION_TYPES = {0x0: 'VMK protected with clear key', 0x100: 'VMK protected with TPM', 0x200: 'VMK protected with startup key', 0x500: 'VMK protected with TPM and PIN', 0x800: 'VMK protected with recovery password', 0x2000: 'VMK protected with password'} +FVE_ENTRY_TYPES = {0x0: 'None', 0x2: 'VMK', 0x3: 'FVEK', 0x4: 'Validation', 0x6: 'Startup key', 0x7: 'Computer description', 0xb: 'FVEK backup', 0xf: 'Volume header block'} +FVE_VALUE_TYPES = {0x0: 'Erased', 0x1: 'Key', 0x2: 'UTF-16 string', 0x3: 'Stretch key', 0x4: 'Use key', 0x5: 'AES-CCM encrypted key', 0x6: 'TPM encoded key', 0x7: 'Validation', 0x8: 'VMK', 0x9: 'External key', 0xa: 'Update', 0xb: 'Error', 0xf: 'Offset and size'} +ITERATION_COUNT = 0x100000 +BITLOCKER_HASH_VERSIONS = [0,1] # 0,1 both supported on hashcat +HASHCAT_HASH = [] + +def guid_to_hex(guid): + guid_parts = guid.split('-') + + search_target = ''.join([guid_parts[0][i:i+2] for i in range(0, len(guid_parts[0]), 2)][::-1]) + search_target += ''.join([guid_parts[1][i:i+2] for i in range(0, len(guid_parts[1]), 2)][::-1]) + search_target += ''.join([guid_parts[2][i:i+2] for i in range(0, len(guid_parts[2]), 2)][::-1]) + search_target += guid_parts[3] + search_target += guid_parts[4] + + return search_target + +def hex_to_guid(hex_str): + + guid_parts = [0] * 5 + guid_parts[0] = hex_str[0:8] + guid_parts[1] = hex_str[8:12] + guid_parts[2] = hex_str[12:16] + guid_parts[3] = hex_str[16:20] + guid_parts[4] = hex_str[20:] + + guid = ''.join([guid_parts[0][i:i+2] for i in range(0, len(guid_parts[0]), 2)][::-1]) + guid += '-' + guid += ''.join([guid_parts[1][i:i+2] for i in range(0, len(guid_parts[1]), 2)][::-1]) + guid += '-' + guid += ''.join([guid_parts[2][i:i+2] for i in range(0, len(guid_parts[2]), 2)][::-1]) + guid += '-' + guid += guid_parts[3] + guid += '-' + guid += guid_parts[4] + + return guid.upper() + +def uint_to_int(b): + return int(b[::-1].hex(), 16) + +def parse_FVEK(fvek_data): + print("\nParsing FVEK...") + nonce = fvek_data[:12] + mac = fvek_data[12:28] + enc_data = fvek_data[28:] + + print("Mac:", mac.hex()) + print("Nonce:", nonce.hex()) + print("Encrypted data:", enc_data.hex()) + + return nonce, mac, enc_data + +def parse_stretch_key(data): + print("\nParsing stretch key...") + encryption_method = hex(uint_to_int(data[0:4])) + salt = data[4:20] + print("Encryption method:", encryption_method) + print("Salt:", salt.hex()) + current_pos = 0 + aes_ccm_data = data[20:] + current_pos, data, value_type = parse_fve_metadata_entry(current_pos, aes_ccm_data) + nonce, mac, enc_data = parse_aes_ccm_encrypted_key(data) + + return salt, nonce, mac, enc_data + +def generate_hashcat_hash(salt, nonce, mac, enc_data): + print("\nFound hashcat hash!") + for version in BITLOCKER_HASH_VERSIONS: + generated_hash = f"$bitlocker${version}${len(salt)}${salt.hex()}${ITERATION_COUNT}${len(nonce)}${nonce.hex()}${len(mac + enc_data)}${(mac + enc_data).hex()}" + print(generated_hash) + HASHCAT_HASH.append(generated_hash) + +def parse_aes_ccm_encrypted_key(data): + print("Parsing AES CCM key...") + nonce, mac, enc_data = parse_FVEK(data) + return nonce, mac, enc_data + +def parse_description(data): + print("\nParsing description...") + print(f"Info: {data.decode('utf-16')}") + return + +def parse_volume_header_block(data): + print("\nParsing volume header block...") + block_offset = uint_to_int(data[0:8]) + block_size = uint_to_int(data[8:16]) + print(f"Block offset: {hex(block_offset)}") + print(f"Block size: {block_size}") + +def parse_VMK(VMK_data): + print("\nParsing VMK...") + guid = hex_to_guid(VMK_data[:16].hex()) + protection_type = uint_to_int(VMK_data[26:28]) + properties = VMK_data[28:] + print("GUID:", guid) + print(f"Protection type: {hex(protection_type)} = {PROTECTION_TYPES.get(protection_type)}") + + # only try parse properties if correct protection type + if protection_type == 0x2000: + current_pos = 28 + while current_pos < len(properties): + current_pos, data, value_type = parse_fve_metadata_entry(current_pos, VMK_data[current_pos:]) + if value_type == 0x3: + salt, strech_nonce, stretch_mac, stretch_enc_data = parse_stretch_key(data) + if value_type == 0x5: + nonce, mac, enc_data = parse_aes_ccm_encrypted_key(data) + generate_hashcat_hash(salt, nonce, mac, enc_data) + + return + +def parse_fve_metadata_block(block): + print('\nParsing FVE block...') + signature = block[0:8] + fve_metadata_header = block[64:64+48] + metadata_size = parse_fve_metadata_header(fve_metadata_header) + + entry_size = uint_to_int(block[112:114]) + current_pos = 112 + while current_pos < metadata_size: + current_pos, data, value_type = parse_fve_metadata_entry(current_pos, block[current_pos:current_pos+entry_size]) + if value_type == 0x2: + parse_description(data) + if value_type == 0x5: + parse_aes_ccm_encrypted_key(data) + if value_type == 0x8: + parse_VMK(data) + if value_type == 0xf: + parse_volume_header_block(data) + + try: + entry_size = uint_to_int(block[current_pos:current_pos+2]) + except: + return + +def parse_fve_metadata_entry(current_pos, block): + print("\nParsing FVE metadata entry...") + entry_size = uint_to_int(block[0:2]) + entry_type = uint_to_int(block[2:4]) + value_type = uint_to_int(block[4:6]) + version = hex(uint_to_int(block[6:8])) + data = block[8:entry_size] + + print(f"Entry size: {entry_size}") + print(f"Entry type: {hex(entry_type)} = {FVE_ENTRY_TYPES.get(entry_type)}") + print(f"Value type: {hex(value_type)} = {FVE_VALUE_TYPES.get(value_type)}") + + current_pos = current_pos + entry_size + + return current_pos, data, value_type + +def parse_fve_metadata_header(block): + print("\nParsing FVE metadata header...") + metadata_size = uint_to_int(block[0:4]) + volume_guid = hex_to_guid(block[16:32].hex()) + nonce_counter = uint_to_int(block[32:36]) + encryption_method = hex(uint_to_int(block[36:40])) + + print("Metadata size:", metadata_size) + print("Volume GUID:", volume_guid) + print("Encryption method:", encryption_method) + + return metadata_size + +def main(): + + p = argparse.ArgumentParser() + p.add_argument('image_path', help="Path to encrypted BitLocker image") + p.add_argument('-o', '--offset', help='Offset in image where BitLocker partition starts, default=0') + args = p.parse_args() + bitlocker_partition = args.image_path + + bitlocker_offset = 0 + if args.offset: + bitlocker_offset = int(args.offset) + + with open(bitlocker_partition, 'rb') as fp: + + fp.seek(bitlocker_offset) + boot_entry_point = fp.read(3) + + header = fp.read(8) + if header.decode('latin-1') not in [BITLOCKER_SIGNATURE, BITLOCKER_TO_GO_SIGNATURE]: + print("[!] Supplied image path is not a BitLocker partition. Try specifiying the offset of the BitLocker partition with -o") + exit() + print(f'[+] BitLocker signature found: {header.decode()}') + sector_size = uint_to_int(fp.read(2)) + + if header.decode('latin-1') == BITLOCKER_SIGNATURE: + guid_offset = 0xa0 + if header.decode('latin-1') == BITLOCKER_TO_GO_SIGNATURE: + guid_offset = 0x1a8 + + fp.seek(guid_offset + bitlocker_offset) + volume_guid = fp.read(16) + print(f'[+] Identified volume GUID: {hex_to_guid(volume_guid.hex())} = {BITLOCKER_GUIDS.get(hex_to_guid(volume_guid.hex()))}') + + # get FVE metadata block addresses + FVE_metadata_offsets = [hex(uint_to_int(fp.read(8)) + bitlocker_offset) for _ in range(3)] + print(f'[+] FVE metadata info found at offsets {FVE_metadata_offsets}') + + # all metadata blocks should be the same + for f in FVE_metadata_offsets: + + fp.seek(int(f, 16)) + FVE_metadata_block = fp.read(2048) + parse_fve_metadata_block(FVE_metadata_block) + + break + + if HASHCAT_HASH == []: + print("\nNo hashes associated with the user password found. Exiting...") + else: + print("\nThe following hashcat hashes were found:") + for bitlocker_hash in HASHCAT_HASH: + print(bitlocker_hash) + + return + + +if __name__ == "__main__": + main() \ No newline at end of file From 7c1688a266909c4987346dd8e9363bfee935aae0 Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:07:01 +0100 Subject: [PATCH 045/357] Update tools/bitlocker2hashcat.py Co-authored-by: kgolawski --- tools/bitlocker2hashcat.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/bitlocker2hashcat.py b/tools/bitlocker2hashcat.py index 56e185311..19d0be2d7 100644 --- a/tools/bitlocker2hashcat.py +++ b/tools/bitlocker2hashcat.py @@ -178,13 +178,11 @@ def main(): p = argparse.ArgumentParser() p.add_argument('image_path', help="Path to encrypted BitLocker image") - p.add_argument('-o', '--offset', help='Offset in image where BitLocker partition starts, default=0') + p.add_argument('-o', '--offset', default=0, type=int, help='Offset in image where BitLocker partition starts') args = p.parse_args() bitlocker_partition = args.image_path - bitlocker_offset = 0 - if args.offset: - bitlocker_offset = int(args.offset) + bitlocker_offset = args.offset with open(bitlocker_partition, 'rb') as fp: From cbc21cf767a30105aef31cfe1e69407249445317 Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:08:31 +0100 Subject: [PATCH 046/357] Update tools/bitlocker2hashcat.py Co-authored-by: kgolawski --- tools/bitlocker2hashcat.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/bitlocker2hashcat.py b/tools/bitlocker2hashcat.py index 19d0be2d7..f7501a37b 100644 --- a/tools/bitlocker2hashcat.py +++ b/tools/bitlocker2hashcat.py @@ -29,12 +29,13 @@ def guid_to_hex(guid): def hex_to_guid(hex_str): - guid_parts = [0] * 5 - guid_parts[0] = hex_str[0:8] - guid_parts[1] = hex_str[8:12] - guid_parts[2] = hex_str[12:16] - guid_parts[3] = hex_str[16:20] - guid_parts[4] = hex_str[20:] + guid_parts = [ + hex_str[0:8], + hex_str[8:12], + hex_str[12:16], + hex_str[16:20], + hex_str[20:], + ] guid = ''.join([guid_parts[0][i:i+2] for i in range(0, len(guid_parts[0]), 2)][::-1]) guid += '-' From 6264e6412d9592868e02134d4bb52537e9e0e270 Mon Sep 17 00:00:00 2001 From: Matt Weir Date: Wed, 18 Sep 2024 22:07:32 -0400 Subject: [PATCH 047/357] Updated radmin3_to_hashcat.pl to support multiple users I tried to keep much of the hash extraction code the same. The main changes are it detects the file encoding to deal with ASCII vs. UTF16-LE, it strips out any header info in the registry dump, and then it breaks up the registry for each radmin3 user so that it can then loop through them to generate the hash. --- tools/radmin3_to_hashcat.pl | 381 ++++++++++++++++++++---------------- 1 file changed, 217 insertions(+), 164 deletions(-) diff --git a/tools/radmin3_to_hashcat.pl b/tools/radmin3_to_hashcat.pl index e096fbd7e..c39ad7c7a 100755 --- a/tools/radmin3_to_hashcat.pl +++ b/tools/radmin3_to_hashcat.pl @@ -48,6 +48,8 @@ use strict; use warnings; use utf8; +use Encode; +use Encode::Guess; # @@ -93,197 +95,248 @@ if (! open ($fh, "<", $file_name)) binmode ($fh); -my $file_content = ""; +# Strip out any leading info from the registry file or the registry dumping program +# Then break up the registry keys into an array so each one can be processed if there are multiple +# Radmin users +my @sections; +my $current_section = ''; { - local $/ = undef; + local $/; # Enable slurp mode + my $file_info = <$fh>; - $file_content = <$fh>; + # Registry dumps are often UTF-16LE, but some programs might dump + # it as a different format + my $enc = guess_encoding($file_info, qw/ ascii cp1252 iso-8859-1 utf-8 UTF-16LE /); + + # Decode using the encoding detected + $file_info = decode($enc->name, $file_info); + + # Split lines, handling both Unix and Windows line endings + my @lines = split /\r?\n/, $file_info; + + # Read the file line by line + foreach my $line (@lines) { + chomp $line; + + # Check if the line is a section header + if ($line =~ /^\[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Radmin\\v3\.0\\Server\\Parameters\\Radmin Security\\/) { + # If we already have a section, push it to the array + if ($current_section) { + push @sections, $current_section; + } + + # Start a new section with the header + $current_section = "$line\n"; + } + elsif ($current_section) { + # If we are in a section, continue adding lines to it + if ($line =~ /^\[.*\]$/) { + # New section starts, save the current one + push @sections, $current_section; + $current_section = ''; + } else { + # Add data to the current section + $current_section .= "$line\n"; + } + } + } } -close ($fh); +# Push the last section if there was one +if ($current_section) { + push @sections, $current_section; +} +close $fh; - -if (length ($file_content) < 5 + 0) # replace 0 with minimum expected length -{ - print STDERR "ERROR: File size of file '$file_name' is invalid\n"; +if (!@sections) { + print STDERR "ERROR: Did not find any Radmin users in the file'\n"; exit (1); } -$file_content =~ s/[\x00]//g; # this could be true if UTF16 + BOM are being used +# Loop over the data +my $file_content = ''; +while($file_content=shift(@sections)) { -my $prefix_idx = index ($file_content, $REGISTRY_PREFIX); - -if ($prefix_idx < 0) -{ - print STDERR "ERROR: Could not find the key '=hex:' within the file content\n"; - - exit (1); -} - -$file_content = substr ($file_content, $prefix_idx + length ($REGISTRY_PREFIX)); - -# $file_content =~ s/[ \r\n,\\]//g; - -# we could also remove every character that is not an hexadecimal symbol: -$file_content =~ s/[^0-9a-fA-F]//g; - -$file_content = pack ("H*", $file_content); - - -# final length check (needed ?): - -my $file_content_len = length ($file_content); - -if ($file_content_len < 2 + 1 + 2 + 1 + 2 + 32 + 2 + 256 + 2 + 256) # replace with min length -{ - print STDERR "ERROR: File content of file '$file_name' is too short\n"; - - exit (1); -} - - -# loop over the data: - -my $user = ""; -my $salt = ""; -my $verifier = ""; - -my $found_user = 0; -my $found_modulus = 0; -my $found_generator = 0; -my $found_salt = 0; -my $found_verifier = 0; - -for (my $i = 0; $i < $file_content_len; $i += 4) -{ - if ($i + 4 > $file_content_len) + if (length ($file_content) < 5 + 0) # replace 0 with minimum expected length { - print STDERR "ERROR: Unexpected EOF (end of file) in file '$file_name'\n"; + print STDERR "ERROR: File size of file '$file_name' is invalid\n"; exit (1); } - my $type = ord (substr ($file_content, $i + 1, 1)) * 256 + - ord (substr ($file_content, $i + 0, 1)); - my $len = ord (substr ($file_content, $i + 2, 1)) * 256 + - ord (substr ($file_content, $i + 3, 1)); + $file_content =~ s/[\x00]//g; # this could be true if UTF16 + BOM are being used - my $pos = $i + 4; + my $prefix_idx = index ($file_content, $REGISTRY_PREFIX); - $i += $len; - - # we are not interested in other values than what we need: - - if (($type != $ENTRY_KEY_USER) && - ($type != $ENTRY_KEY_MODULUS) && - ($type != $ENTRY_KEY_GENERATOR) && - ($type != $ENTRY_KEY_SALT) && - ($type != $ENTRY_KEY_VERIFIER)) + if ($prefix_idx < 0) { - next; + print STDERR "ERROR: Could not find the key '=hex:' within the file content\n"; + + exit (1); } - if ($i > $file_content_len) + $file_content = substr ($file_content, $prefix_idx + length ($REGISTRY_PREFIX)); + + # $file_content =~ s/[ \r\n,\\]//g; + + # we could also remove every character that is not an hexadecimal symbol: + $file_content =~ s/[^0-9a-fA-F]//g; + + $file_content = pack ("H*", $file_content); + + + # final length check (needed ?): + + my $file_content_len = length ($file_content); + + if ($file_content_len < 2 + 1 + 2 + 1 + 2 + 32 + 2 + 256 + 2 + 256) # replace with min length { - print STDERR "ERROR: Unexpected EOF (end of file) in file '$file_name'\n"; + print STDERR "ERROR: File content of file '$file_name' is too short\n"; + + exit (1); + } + + my $user = ""; + my $salt = ""; + my $verifier = ""; + + my $found_user = 0; + my $found_modulus = 0; + my $found_generator = 0; + my $found_salt = 0; + my $found_verifier = 0; + + for (my $i = 0; $i < $file_content_len; $i += 4) + { + if ($i + 4 > $file_content_len) + { + print STDERR "ERROR: Unexpected EOF (end of file) in file '$file_name'\n"; + + exit (1); + } + + my $type = ord (substr ($file_content, $i + 1, 1)) * 256 + + ord (substr ($file_content, $i + 0, 1)); + my $len = ord (substr ($file_content, $i + 2, 1)) * 256 + + ord (substr ($file_content, $i + 3, 1)); + + my $pos = $i + 4; + + $i += $len; + + # we are not interested in other values than what we need: + + if (($type != $ENTRY_KEY_USER) && + ($type != $ENTRY_KEY_MODULUS) && + ($type != $ENTRY_KEY_GENERATOR) && + ($type != $ENTRY_KEY_SALT) && + ($type != $ENTRY_KEY_VERIFIER)) + { + next; + } + + if ($i > $file_content_len) + { + print STDERR "ERROR: Unexpected EOF (end of file) in file '$file_name'\n"; + + exit (1); + } + + + # + # get the data, finally: + # + + my $value = substr ($file_content, $pos, $len); + + $value = unpack ("H*", $value); + + if ($type == $ENTRY_KEY_USER) + { + $user = $value; + + $found_user = 1; + } + elsif ($type == $ENTRY_KEY_MODULUS) + { + if ($value ne $HARD_CODED_MODULUS) + { + print STDERR "ERROR: Non-default modulus found in file '$file_name'\n"; + + exit (1); + } + + $found_modulus = 1; + } + elsif ($type == $ENTRY_KEY_GENERATOR) + { + if ($value ne $HARD_CODED_GENERATOR) + { + print STDERR "ERROR: Non-default generator found in file '$file_name'\n"; + + exit (1); + } + + $found_generator = 1; + } + elsif ($type == $ENTRY_KEY_SALT) + { + $salt = $value; + + $found_salt = 1; + } + elsif ($type == $ENTRY_KEY_VERIFIER) + { + $verifier = $value; + + $found_verifier = 1; + } + } + + if ($found_user == 0) + { + print STDERR "ERROR: No user name found in file '$file_name'\n"; + + exit (1); + } + + if ($found_modulus == 0) + { + print STDERR "ERROR: No modulus found in file '$file_name'\n"; + + exit (1); + } + + if ($found_generator == 0) + { + print STDERR "ERROR: No generator found in file '$file_name'\n"; + + exit (1); + } + + if ($found_salt == 0) + { + print STDERR "ERROR: No salt found in file '$file_name'\n"; + + exit (1); + } + + if ($found_verifier == 0) + { + print STDERR "ERROR: No verifier found in file '$file_name'\n"; exit (1); } # - # get the data, finally: + # Output: # - my $value = substr ($file_content, $pos, $len); - - $value = unpack ("H*", $value); - - if ($type == $ENTRY_KEY_USER) - { - $user = $value; - - $found_user = 1; - } - elsif ($type == $ENTRY_KEY_MODULUS) - { - if ($value ne $HARD_CODED_MODULUS) - { - print STDERR "ERROR: Non-default modulus found in file '$file_name'\n"; - - exit (1); - } - - $found_modulus = 1; - } - elsif ($type == $ENTRY_KEY_GENERATOR) - { - if ($value ne $HARD_CODED_GENERATOR) - { - print STDERR "ERROR: Non-default generator found in file '$file_name'\n"; - - exit (1); - } - - $found_generator = 1; - } - elsif ($type == $ENTRY_KEY_SALT) - { - $salt = $value; - - $found_salt = 1; - } - elsif ($type == $ENTRY_KEY_VERIFIER) - { - $verifier = $value; - - $found_verifier = 1; - } -} - -if ($found_user == 0) -{ - print STDERR "ERROR: No user name found in file '$file_name'\n"; - - exit (1); -} - -if ($found_modulus == 0) -{ - print STDERR "ERROR: No modulus found in file '$file_name'\n"; - - exit (1); -} - -if ($found_generator == 0) -{ - print STDERR "ERROR: No generator found in file '$file_name'\n"; - - exit (1); -} - -if ($found_salt == 0) -{ - print STDERR "ERROR: No salt found in file '$file_name'\n"; - - exit (1); -} - -if ($found_verifier == 0) -{ - print STDERR "ERROR: No verifier found in file '$file_name'\n"; - - exit (1); -} - - -# -# Output: -# - -print sprintf ("\$radmin3\$%s*%s*%s\n", - $user, - $salt, - $verifier); + print sprintf ("\$radmin3\$%s*%s*%s\n", + $user, + $salt, + $verifier); +} \ No newline at end of file From 844f2a92d2ffe68731fa8dae214cd7ef537da54a Mon Sep 17 00:00:00 2001 From: Jakub Kramarz Date: Thu, 10 Oct 2024 18:44:32 +0200 Subject: [PATCH 048/357] Add support for Mojolicious session cookies --- src/modules/module_16501.c | 332 +++++++++++++++++++++++++++++++++++ tools/test_modules/m16501.pm | 91 ++++++++++ 2 files changed, 423 insertions(+) create mode 100644 src/modules/module_16501.c create mode 100644 tools/test_modules/m16501.pm diff --git a/src/modules/module_16501.c b/src/modules/module_16501.c new file mode 100644 index 000000000..b6cd10528 --- /dev/null +++ b/src/modules/module_16501.c @@ -0,0 +1,332 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_16; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; +static const char *HASH_NAME = "Perl Mojolicious session cookie (HMAC-SHA256, >= v9.19)"; +// Padded cookie with HMAC-SHA256 signature was introduced in version v9.19 of Mojolicious framework +// It's very like JWT HS256 tokens without a header, so it reuses the kernel. +// For versions pre v9.19, that uses non-padded HMAC-SHA1 signed cookies, use module 150. +static const u64 KERN_TYPE = 16511; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_SELF_TEST_DISABLE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "secret"; +static const char *ST_HASH = "mojolicious=eyIyODY0NTk0MyI6Mzc4NzMyMzJ9ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ--d70a4d495a7eb5764cf7a7db95079bfb23280d33b67aa1589dd4e4f926be1f34"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct mojolicious +{ + u32 salt_buf[1024]; + u32 salt_len; + + u32 signature_len; + +} mojolicious_t; + +salt_t *module_benchmark_salt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + salt_t *salt = (salt_t *) hcmalloc (sizeof (salt_t)); + + salt->salt_iter = 1; + salt->salt_len = 16; + + return salt; +} + +void *module_benchmark_esalt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + mojolicious_t *mojolicious = (mojolicious_t *) hcmalloc (sizeof (mojolicious_t)); + + mojolicious->signature_len = 43; + mojolicious->salt_len = 32; + + return mojolicious; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (mojolicious_t); + + return esalt_size; +} + +u64 module_kern_type_dynamic (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info) +{ + return 16511; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + mojolicious_t *mojolicious = (mojolicious_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 4; + + // total = max 4096 characters + // name=value = max 4030 characters + + // cookie name + token.sep[0] = '='; + token.len_min[0] = 1; + token.len_max[0] = 3005; // what's left of max cookie length + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + + // '=' as separator + + // cookie value + token.sep[1] = '-'; + token.len_min[1] = 1024; // if there's no padding, it's not new cookie + token.len_max[1] = 4030; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + // '--' as separator + token.sep[2] = '-'; + token.len_min[2] = 0; + token.len_max[2] = 0; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + + // signature = 64 characters + token.sep[3] = '-'; + token.len_min[3] = 64; + token.len_max[3] = 64; + token.attr[3] = 0; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const int name_len = token.len[0]; + const int payload_len = token.len[1]; + mojolicious->signature_len = token.len[3]; + + // esalt + + const int esalt_len = name_len + 1 + payload_len; + + if (esalt_len > 4096) return (PARSER_SALT_LENGTH); + + memcpy (mojolicious->salt_buf, line_buf, esalt_len); + + mojolicious->salt_len = esalt_len; + + + // salt + + // Create a hash of the esalt because esalt buffer can change somewhere behind salt->salt_buf size + // Not a regular MD5 but good enough + + u32 hash[4]; + + hash[0] = 0; + hash[1] = 1; + hash[2] = 2; + hash[3] = 3; + + u32 block[16]; + + memset (block, 0, sizeof (block)); + + for (int i = 0; i < 1024; i += 16) + { + for (int j = 0; j < 16; j++) + { + block[j] = mojolicious->salt_buf[i + j]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + } + } + + salt->salt_buf[0] = hash[0]; + salt->salt_buf[1] = hash[1]; + salt->salt_buf[2] = hash[2]; + salt->salt_buf[3] = hash[3]; + + salt->salt_len = 16; + + + const u8 *hash_pos = token.buf[3]; + u32 *digest = (u32 *) digest_buf; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const mojolicious_t *mojolicious = (const mojolicious_t *) esalt_buf; + + const u32 *digest32 = (const u32 *) digest_buf; + + char ptr_plain[128]; + + + u32 tmp[8]; + + tmp[0] = byte_swap_32 (digest32[0]); + tmp[1] = byte_swap_32 (digest32[1]); + tmp[2] = byte_swap_32 (digest32[2]); + tmp[3] = byte_swap_32 (digest32[3]); + tmp[4] = byte_swap_32 (digest32[4]); + tmp[5] = byte_swap_32 (digest32[5]); + tmp[6] = byte_swap_32 (digest32[6]); + tmp[7] = byte_swap_32 (digest32[7]); + + + u8 *out_buf = (u8 *) ptr_plain; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[4], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[5], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[6], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[7], out_buf + out_len); out_len += 8; + + out_buf[65]=0; + + + const int line_len = snprintf (line_buf, line_size, "%s--%s", (char *) mojolicious->salt_buf, (char *) ptr_plain); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = module_benchmark_esalt; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = module_benchmark_salt; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = module_kern_type_dynamic; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/test_modules/m16501.pm b/tools/test_modules/m16501.pm new file mode 100644 index 000000000..09361d368 --- /dev/null +++ b/tools/test_modules/m16501.pm @@ -0,0 +1,91 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::HMAC qw (hmac); +use MIME::Base64 qw (encode_base64url); +use JSON qw (encode_json); + +sub module_constraints { [[0, 64], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift || get_random_mojolicious_salt (); + + ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQ + my ($name, $value) = split('=', $salt); + + ## example is 102 chars in length, 1025-102 = so it gets 923 chars of "Z" padding, "--" separator and HMAC-SHA256 signature + ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQZZZZZZZ(...)ZZZZZZ--1bf346f55562ac2a08d1b86a28e87bf5aad357d7a92e816567271f5b420b93c1 + my $hash = get_signed_cookie ($name, $value, $word); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split (/--/, $hash); + + return unless scalar @data == 2; + + my ($padded_cookie, $signature) = @data; + + my $unpadded_cookie = $padded_cookie =~ s/\}\KZ*$//r; + + my ($cookie_name, $cookie_value) = split('=', $unpadded_cookie); + + my $salt = $cookie_name . "=" . $cookie_value; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +sub get_random_mojolicious_salt +{ + my $random_key = random_number (1, 100000000); + my $random_val = random_number (1, 100000000); + + my $payload = + { + $random_key => $random_val + }; + + my $payload_json = encode_json ($payload); + + my $payload_base64 = encode_base64url ($payload_json, ""); + + return "mojolicious=$payload_base64"; +} + +sub get_signed_cookie +{ + my ($name, $value, $secret) = @_; + + sub add_mojolicious_padding { + return $_[0] . 'Z' x (1025 - length $_[0]); + } + + my $padded = add_mojolicious_padding $value; + + my $sum = Digest::SHA::hmac_sha256_hex("$name=$padded", $secret); + return "$name=$padded--$sum" +} + +1; From 7398b03be30b45d1e89dd7b7ec7799ee5d5b0f52 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 24 Oct 2024 20:15:08 +0200 Subject: [PATCH 049/357] User Options: limit --bitmap-max value to 31 --- docs/changes.txt | 1 + src/bitmap.c | 2 ++ src/usage.c | 2 +- src/user_options.c | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..ef9be50bb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -130,6 +130,7 @@ - Metal Backend: allow use of devices with Metal if runtime version is >= 200 - Metal Backend: disable Metal devices only if at least one OpenCL device is active - User Options: added --metal-compiler-runtime option +- User Options: limit --bitmap-max value to 31 - Hardware Monitor: avoid sprintf in src/ext_iokit.c - Help: show supported hash-modes only with -hh - Makefile: prevent make failure with Apple Silicon in case of partial rebuild diff --git a/src/bitmap.c b/src/bitmap.c index 367b16a7c..12f701fe5 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -110,6 +110,8 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) u32 *bitmap_s2_c = (u32 *) hcmalloc ((1U << bitmap_max) * sizeof (u32)); u32 *bitmap_s2_d = (u32 *) hcmalloc ((1U << bitmap_max) * sizeof (u32)); + if (!bitmap_s1_a || !bitmap_s1_b || !bitmap_s1_c || !bitmap_s1_d || !bitmap_s2_a || !bitmap_s2_b || !bitmap_s2_c || !bitmap_s2_d) return -1; + u32 bitmap_bits; u32 bitmap_nums; u32 bitmap_mask; diff --git a/src/usage.c b/src/usage.c index 7cbf22348..1bee7c547 100644 --- a/src/usage.c +++ b/src/usage.c @@ -91,7 +91,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --progress-only | | Return ideal progress step size and time to process |", " -c, --segment-size | Num | Sets size in MB to cache from the wordfile to X | -c 32", " --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24", - " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24", + " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X (max: 31) | --bitmap-max=24", " --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3", " --hook-threads | Num | Sets number of threads for a hook (per compute unit) | --hook-threads=8", " --hash-info | | Show information for each hash-mode |", diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..1bf346d13 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -945,6 +945,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->bitmap_max > 31) + { + event_log_error (hashcat_ctx, "Invalid --bitmap-max value specified - must be lower than 32."); + + return -1; + } + if (user_options->rp_gen_func_min > user_options->rp_gen_func_max) { event_log_error (hashcat_ctx, "Invalid --rp-gen-func-min value specified."); From a66c93ae1e3b3f4b299a220322821dfa5599e6ee Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 24 Oct 2024 21:13:11 +0200 Subject: [PATCH 050/357] Fixed bug in --stdout when multiple computing devices are active --- docs/changes.txt | 1 + include/types.h | 2 ++ src/outfile.c | 5 +++++ src/stdout.c | 11 +++++++++++ 4 files changed, 19 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..a4a17bfd8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -82,6 +82,7 @@ - Fixed bug in grep out-of-memory workaround on Unit Test - Fixed bug in input_tokenizer when TOKEN_ATTR_FIXED_LENGTH is used and refactor modules - Fixed bug in --stdout that caused certain rules to malfunction +- Fixed bug in --stdout when multiple computing devices are active - Fixed build failed for 10700 optimized with Apple Metal - Fixed build failed for 13772 and 13773 with Apple Metal - Fixed build failed for 18400 with Apple Metal diff --git a/include/types.h b/include/types.h index e6ea946f9..6b508d7f0 100644 --- a/include/types.h +++ b/include/types.h @@ -2122,6 +2122,8 @@ typedef struct outfile_ctx char *filename; + hc_thread_mutex_t mux_outfile; + } outfile_ctx_t; typedef struct pot diff --git a/src/outfile.c b/src/outfile.c index b14b56a7a..43ddb8611 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -15,6 +15,7 @@ #include "backend.h" #include "shared.h" #include "locking.h" +#include "thread.h" #include "outfile.h" u32 outfile_format_parse (const char *format_string) @@ -506,6 +507,8 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx) outfile_ctx->outfile_json = user_options->outfile_json; outfile_ctx->is_fifo = hc_path_is_fifo (outfile_ctx->filename); + hc_thread_mutex_init (outfile_ctx->mux_outfile); + return 0; } @@ -513,6 +516,8 @@ void outfile_destroy (hashcat_ctx_t *hashcat_ctx) { outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + hc_thread_mutex_delete (outfile_ctx->mux_outfile); + if (outfile_ctx->is_fifo == true && outfile_ctx->fp.pfp != NULL) { hc_unlockfile (&outfile_ctx->fp); diff --git a/src/stdout.c b/src/stdout.c index 429836793..127232d0e 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -12,6 +12,7 @@ #include "mpsp.h" #include "backend.h" #include "shared.h" +#include "thread.h" #include "stdout.h" static void out_flush (out_t *out) @@ -59,6 +60,10 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; user_options_t *user_options = hashcat_ctx->user_options; + // prevent wrong candidates in output when backend_ctx->backend_devices_active > 1 + + hc_thread_mutex_lock (outfile_ctx->mux_outfile); + char *filename = outfile_ctx->filename; out_t out; @@ -69,6 +74,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno)); + hc_thread_mutex_unlock (outfile_ctx->mux_outfile); + return -1; } @@ -78,6 +85,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno)); + hc_thread_mutex_unlock (outfile_ctx->mux_outfile); + return -1; } } @@ -341,5 +350,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, hc_fclose (&out.fp); } + hc_thread_mutex_unlock (outfile_ctx->mux_outfile); + return rc; } From 0788fd9ae745dacc3b697cdae8534f73329bdc91 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 26 Oct 2024 13:24:00 +0200 Subject: [PATCH 051/357] Fixed stack buffer overflow in PKZIP modules (17200, 17210, 17220, 17225, 17230) --- docs/changes.txt | 1 + src/modules/module_17200.c | 9 +++++++-- src/modules/module_17210.c | 9 +++++++-- src/modules/module_17220.c | 9 +++++++-- src/modules/module_17225.c | 9 +++++++-- src/modules/module_17230.c | 9 +++++++-- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..e1aab3de3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -98,6 +98,7 @@ - Fixed minimum password length in module of hash-mode 28200 - Fixed minimum password length in module of hash-mode 29800 - Fixed out-of-boundary read when a fast hash defines a kernel_loops_min value higher than the amplifiers provided by the user +- Fixed stack buffer overflow in PKZIP modules (17200, 17210, 17220, 17225, 17230) - Fixed vector datatypes usage for HIP - Fix missing check for -j and -k before writing hashcat.dictstat2 which can lead to false negatives - Handle signed/unsigned PDF permission P value for all PDF hash-modes diff --git a/src/modules/module_17200.c b/src/modules/module_17200.c index 24f77798f..2125812e2 100644 --- a/src/modules/module_17200.c +++ b/src/modules/module_17200.c @@ -91,6 +91,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -206,9 +207,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; - char input[line_len + 1]; + char *input = (char *) hcmalloc (line_len + 1); + if (!input) return PARSER_HAVE_ERRNO; + + memcpy (input, line_buf, line_len); input[line_len] = '\0'; - memcpy (&input, line_buf, line_len); char *saveptr = NULL; @@ -318,6 +321,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = 0; digest[3] = 0; + hcfree (input); + return (PARSER_OK); } diff --git a/src/modules/module_17210.c b/src/modules/module_17210.c index 307757689..58edcf343 100644 --- a/src/modules/module_17210.c +++ b/src/modules/module_17210.c @@ -91,6 +91,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -186,9 +187,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; - char input[line_len + 1]; + char *input = (char *) hcmalloc (line_len + 1); + if (!input) return PARSER_HAVE_ERRNO; + + memcpy (input, line_buf, line_len); input[line_len] = '\0'; - memcpy (&input, line_buf, line_len); char *saveptr = NULL; @@ -297,6 +300,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = 0; digest[3] = 0; + hcfree (input); + return (PARSER_OK); } diff --git a/src/modules/module_17220.c b/src/modules/module_17220.c index c2ac82b2c..1356cf5e5 100644 --- a/src/modules/module_17220.c +++ b/src/modules/module_17220.c @@ -91,6 +91,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -206,9 +207,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; - char input[line_len + 1]; + char *input = (char *) hcmalloc (line_len + 1); + if (!input) return PARSER_HAVE_ERRNO; + + memcpy (input, line_buf, line_len); input[line_len] = '\0'; - memcpy (&input, line_buf, line_len); char *saveptr = NULL; @@ -314,6 +317,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_len = pkzip->hash_count << 2; + hcfree (input); + return (PARSER_OK); } diff --git a/src/modules/module_17225.c b/src/modules/module_17225.c index 3cbf0f51b..376d77e60 100644 --- a/src/modules/module_17225.c +++ b/src/modules/module_17225.c @@ -91,6 +91,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -207,9 +208,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; - char input[line_len + 1]; + char *input = (char *) hcmalloc (line_len + 1); + if (!input) return PARSER_HAVE_ERRNO; + + memcpy (input, line_buf, line_len); input[line_len] = '\0'; - memcpy (&input, line_buf, line_len); char *saveptr = NULL; @@ -315,6 +318,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_len = pkzip->hash_count << 2; + hcfree (input); + return (PARSER_OK); } diff --git a/src/modules/module_17230.c b/src/modules/module_17230.c index 2b3ef24c9..2166c3f6d 100644 --- a/src/modules/module_17230.c +++ b/src/modules/module_17230.c @@ -91,6 +91,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp #include "bitops.h" #include "convert.h" #include "shared.h" +#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -199,9 +200,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; - char input[line_len + 1]; + char *input = (char *) hcmalloc (line_len + 1); + if (!input) return PARSER_HAVE_ERRNO; + + memcpy (input, line_buf, line_len); input[line_len] = '\0'; - memcpy (&input, line_buf, line_len); char *saveptr = NULL; @@ -308,6 +311,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_len = pkzip->hash_count << 2; + hcfree (input); + return (PARSER_OK); } From e3c097c88bca1a9395fdf91738e3b2aab314c1bc Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 26 Oct 2024 14:51:11 +0200 Subject: [PATCH 052/357] do not allow --show and --restore --- src/hashcat.c | 2 ++ src/user_options.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/hashcat.c b/src/hashcat.c index a6dd823d1..642a13952 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1430,6 +1430,8 @@ bool autodetect_hashmode_test (hashcat_ctx_t *hashcat_ctx) { char *input_buf = user_options_extra->hc_hash; + if (!input_buf) return false; + size_t input_len = strlen (input_buf); char *hash_buf = NULL; diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..3576cb3d2 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1059,6 +1059,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return 0; } + if (user_options->show == true && user_options->restore == true) + { + event_log_error (hashcat_ctx, "Mixing --show and --restore is not allowed."); + + return -1; + } + if (user_options->show == true || user_options->left == true) { if (user_options->remove == true) From b67638ab36224a3201cea67696b25ebc7f962dc9 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 26 Oct 2024 15:11:45 +0200 Subject: [PATCH 053/357] do not allow --stdout and --slow-candidates --- src/user_options.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..f9bf491ea 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1052,6 +1052,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) } } + if (user_options->stdout_flag == true && user_options->slow_candidates == true) + { + event_log_error (hashcat_ctx, "Slow candidates (-S) is not allowed in stdout mode."); + + return -1; + } + if ((user_options->show == true) && ((user_options->username == true) || (user_options->dynamic_x == true))) { event_log_error (hashcat_ctx, "Mixing --show with --username or --dynamic-x can cause exponential delay in output."); From 356ad9f927a16a85ec490c70112f8553f3811d36 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 27 Oct 2024 00:45:44 +0200 Subject: [PATCH 054/357] Fixed memory leaks in tuning_db_init in tuningdb.c --- docs/changes.txt | 1 + src/tuningdb.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..727f93bf2 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -95,6 +95,7 @@ - Fixed keys extraction in luks2hashcat - now extracts all active keys - Fixed maximum password length in module/test_module of hash-mode 2400 - Fixed maximum password length in module/test_module of hash-mode 2410 +- Fixed memory leaks in tuning_db_init in tuningdb.c - Fixed minimum password length in module of hash-mode 28200 - Fixed minimum password length in module of hash-mode 29800 - Fixed out-of-boundary read when a fast hash defines a kernel_loops_min value higher than the amplifiers provided by the user diff --git a/src/tuningdb.c b/src/tuningdb.c index 2f983b31e..332ab51cb 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -72,6 +72,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) char **tuning_db_files = scan_directory (tuning_db_folder); + hcfree (tuning_db_folder); + for (int i = 0; tuning_db_files[i] != NULL; i++) { char *tuning_db_file = tuning_db_files[i]; @@ -80,9 +82,19 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) const size_t dblen = strlen (tuning_db_file); - if (dblen < suflen) continue; // make sure to not do any out-of-boundary reads + if (dblen < suflen) + { + hcfree (tuning_db_file); - if (memcmp (tuning_db_file + dblen - suflen, TUNING_DB_SUFFIX, suflen) != 0) continue; + continue; // make sure to not do any out-of-boundary reads + } + + if (memcmp (tuning_db_file + dblen - suflen, TUNING_DB_SUFFIX, suflen) != 0) + { + hcfree (tuning_db_file); + + continue; + } HCFILE fp; @@ -90,6 +102,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: %s", tuning_db_file, strerror (errno)); + for (int j = 0; tuning_db_files[j] != NULL; j++) hcfree (tuning_db_files[j]); + return -1; } From cb99fcf73b9c51c211a2ab72d47358327d8b8956 Mon Sep 17 00:00:00 2001 From: hashrepublic Date: Tue, 29 Oct 2024 07:27:11 +0100 Subject: [PATCH 055/357] fixed mode m21310 OpenCL types --- OpenCL/m21310_a1-pure.cl | 2 +- OpenCL/m21310_a3-pure.cl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenCL/m21310_a1-pure.cl b/OpenCL/m21310_a1-pure.cl index be8285e50..67a0eeb2d 100644 --- a/OpenCL/m21310_a1-pure.cl +++ b/OpenCL/m21310_a1-pure.cl @@ -37,7 +37,7 @@ typedef struct md5_double_salt } md5_double_salt_t; -KERNEL_FQ void m21310_mxx (KERN_ATTR_ESALT (md5_double_salt)) +KERNEL_FQ void m21310_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) { /** * modifier diff --git a/OpenCL/m21310_a3-pure.cl b/OpenCL/m21310_a3-pure.cl index 546e7defb..985d67cae 100644 --- a/OpenCL/m21310_a3-pure.cl +++ b/OpenCL/m21310_a3-pure.cl @@ -37,7 +37,7 @@ typedef struct md5_double_salt } md5_double_salt_t; -KERNEL_FQ void m21310_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt)) +KERNEL_FQ void m21310_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) { /** * modifier From bf338e0c12fbae21f78df5749a487723f626b5f3 Mon Sep 17 00:00:00 2001 From: hashrepublic Date: Tue, 29 Oct 2024 14:22:29 +0100 Subject: [PATCH 056/357] fixed m21310_sxx --- OpenCL/m21310_a1-pure.cl | 2 +- OpenCL/m21310_a3-pure.cl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenCL/m21310_a1-pure.cl b/OpenCL/m21310_a1-pure.cl index 67a0eeb2d..006246416 100644 --- a/OpenCL/m21310_a1-pure.cl +++ b/OpenCL/m21310_a1-pure.cl @@ -149,7 +149,7 @@ KERNEL_FQ void m21310_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) } } -KERNEL_FQ void m21310_sxx (KERN_ATTR_ESALT (md5_double_salt)) +KERNEL_FQ void m21310_sxx (KERN_ATTR_ESALT (md5_double_salt_t)) { /** * modifier diff --git a/OpenCL/m21310_a3-pure.cl b/OpenCL/m21310_a3-pure.cl index 985d67cae..ce53dbc26 100644 --- a/OpenCL/m21310_a3-pure.cl +++ b/OpenCL/m21310_a3-pure.cl @@ -168,7 +168,7 @@ KERNEL_FQ void m21310_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) } } -KERNEL_FQ void m21310_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt)) +KERNEL_FQ void m21310_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) { /** * modifier From d756a6617c8b2a6f7342a56ee74b8da910952221 Mon Sep 17 00:00:00 2001 From: Mathias Date: Tue, 29 Oct 2024 15:35:10 +0100 Subject: [PATCH 057/357] Update backend.c Fixes hiprtcCompileProgram(): HIPRTC_ERROR_COMPILATION on AMD 6900XT. ```bash hiprtcCompileProgram(): HIPRTC_ERROR_COMPILATION ld.lld: error: undefined hidden symbol: __ockl_get_group_id >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset) >>> referenced 7 more times ld.lld: error: undefined hidden symbol: __ockl_get_local_size >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset) >>> referenced 7 more times ld.lld: error: undefined hidden symbol: __ockl_get_local_id >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_decompress) >>> referenced by /home/mathias/.local/share/hashcat/comgr-69ec34/input/shared_kernel.o:(gpu_memset) >>> referenced 7 more times * Device #1: Kernel /usr/local/share/hashcat/OpenCL/shared.cl build failed. * Device #1: Kernel /usr/local/share/hashcat/OpenCL/shared.cl build failed. ``` --- src/backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..4120f449d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -8754,8 +8754,8 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p hiprtc_options[5] = "-I"; */ - hiprtc_options[1] = "-nocudainc"; - hiprtc_options[2] = "-nocudalib"; + hiprtc_options[1] = ""; + hiprtc_options[2] = ""; hiprtc_options[3] = ""; hiprtc_options[4] = ""; From 0700efa01570b0ab6324c54cc8309c67df220c47 Mon Sep 17 00:00:00 2001 From: Jakub Kramarz Date: Thu, 31 Oct 2024 09:16:10 +0100 Subject: [PATCH 058/357] Fixed padding format in Mojolicious session cookies --- src/modules/module_16501.c | 2 +- tools/test_modules/m16501.pm | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/modules/module_16501.c b/src/modules/module_16501.c index b6cd10528..06b8f7e37 100644 --- a/src/modules/module_16501.c +++ b/src/modules/module_16501.c @@ -31,7 +31,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_SELF_TEST_DISABLE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "secret"; -static const char *ST_HASH = "mojolicious=eyIyODY0NTk0MyI6Mzc4NzMyMzJ9ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ--d70a4d495a7eb5764cf7a7db95079bfb23280d33b67aa1589dd4e4f926be1f34"; +static const char *ST_HASH = "mojolicious=eyJleHBpcmVzIjoyMDAwMDAwMDAwLCAidXNlciI6ICJzdXBlcnVzZXIifVpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlo--9d32db342a1caa83910dc8db51ff387591c40144bc0dddfa437d03a7d65688da"; u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } diff --git a/tools/test_modules/m16501.pm b/tools/test_modules/m16501.pm index 09361d368..ee68f4565 100644 --- a/tools/test_modules/m16501.pm +++ b/tools/test_modules/m16501.pm @@ -8,7 +8,7 @@ use strict; use warnings; -use Digest::HMAC qw (hmac); +use Digest::SHA qw (hmac_sha256_hex); use MIME::Base64 qw (encode_base64url); use JSON qw (encode_json); @@ -19,11 +19,10 @@ sub module_generate_hash my $word = shift; my $salt = shift || get_random_mojolicious_salt (); - ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQ + ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQWlpaWlpaWlpaWlp(...)aWlpaWlpaWlpaWlpaWlpaWlpaWlp my ($name, $value) = split('=', $salt); - ## example is 102 chars in length, 1025-102 = so it gets 923 chars of "Z" padding, "--" separator and HMAC-SHA256 signature - ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQZZZZZZZ(...)ZZZZZZ--1bf346f55562ac2a08d1b86a28e87bf5aad357d7a92e816567271f5b420b93c1 + ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQWlpaWlpaWlpaWlp(...)aWlpaWlpaWlpaWlpaWlpaWlpaWlp--1bf346f55562ac2a08d1b86a28e87bf5aad357d7a92e816567271f5b420b93c1 my $hash = get_signed_cookie ($name, $value, $word); return $hash; @@ -59,6 +58,11 @@ sub module_verify_hash sub get_random_mojolicious_salt { + sub add_mojolicious_padding + { + return $_[0] . 'Z' x (1025 - length $_[0]); + } + my $random_key = random_number (1, 100000000); my $random_val = random_number (1, 100000000); @@ -68,8 +72,8 @@ sub get_random_mojolicious_salt }; my $payload_json = encode_json ($payload); - - my $payload_base64 = encode_base64url ($payload_json, ""); + my $payload_padded = add_mojolicious_padding ($payload_json); + my $payload_base64 = encode_base64url ($payload_padded, ""); return "mojolicious=$payload_base64"; } @@ -77,15 +81,9 @@ sub get_random_mojolicious_salt sub get_signed_cookie { my ($name, $value, $secret) = @_; + my $sum = Digest::SHA::hmac_sha256_hex("$name=$value", $secret); - sub add_mojolicious_padding { - return $_[0] . 'Z' x (1025 - length $_[0]); - } - - my $padded = add_mojolicious_padding $value; - - my $sum = Digest::SHA::hmac_sha256_hex("$name=$padded", $secret); - return "$name=$padded--$sum" + return "$name=$value--$sum" } 1; From a80d68731ef2b33cc1c4325d2581b26de712429f Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 31 Oct 2024 18:04:58 +0100 Subject: [PATCH 059/357] Kernel: Renamed multiple defines in CAST cipher to fit expected naming convention of the C++ language standard --- OpenCL/inc_cipher_cast.cl | 80 +++++++++++++++++++-------------------- OpenCL/inc_cipher_cast.h | 22 +++++------ docs/changes.txt | 1 + 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/OpenCL/inc_cipher_cast.cl b/OpenCL/inc_cipher_cast.cl index e2c5a6fb1..f37b09072 100644 --- a/OpenCL/inc_cipher_cast.cl +++ b/OpenCL/inc_cipher_cast.cl @@ -569,22 +569,22 @@ DECLSPEC void Cast5Encrypt (PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBloc u32 t; /* Do the work */ - _CAST_F1(l, r, 0, 16); - _CAST_F2(r, l, 1, 16); - _CAST_F3(l, r, 2, 16); - _CAST_F1(r, l, 3, 16); - _CAST_F2(l, r, 4, 16); - _CAST_F3(r, l, 5, 16); - _CAST_F1(l, r, 6, 16); - _CAST_F2(r, l, 7, 16); - _CAST_F3(l, r, 8, 16); - _CAST_F1(r, l, 9, 16); - _CAST_F2(l, r, 10, 16); - _CAST_F3(r, l, 11, 16); - _CAST_F1(l, r, 12, 16); - _CAST_F2(r, l, 13, 16); - _CAST_F3(l, r, 14, 16); - _CAST_F1(r, l, 15, 16); + CAST_F1(l, r, 0, 16); + CAST_F2(r, l, 1, 16); + CAST_F3(l, r, 2, 16); + CAST_F1(r, l, 3, 16); + CAST_F2(l, r, 4, 16); + CAST_F3(r, l, 5, 16); + CAST_F1(l, r, 6, 16); + CAST_F2(r, l, 7, 16); + CAST_F3(l, r, 8, 16); + CAST_F1(r, l, 9, 16); + CAST_F2(l, r, 10, 16); + CAST_F3(r, l, 11, 16); + CAST_F1(l, r, 12, 16); + CAST_F2(r, l, 13, 16); + CAST_F3(l, r, 14, 16); + CAST_F1(r, l, 15, 16); /* Put l,r into outblock */ PUT_UINT32BE(r, outBlock, 0); @@ -599,22 +599,22 @@ DECLSPEC void Cast5Decrypt (PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBloc u32 t; /* Only do full 16 rounds if key length > 80 bits */ - _CAST_F1(r, l, 15, 16); - _CAST_F3(l, r, 14, 16); - _CAST_F2(r, l, 13, 16); - _CAST_F1(l, r, 12, 16); - _CAST_F3(r, l, 11, 16); - _CAST_F2(l, r, 10, 16); - _CAST_F1(r, l, 9, 16); - _CAST_F3(l, r, 8, 16); - _CAST_F2(r, l, 7, 16); - _CAST_F1(l, r, 6, 16); - _CAST_F3(r, l, 5, 16); - _CAST_F2(l, r, 4, 16); - _CAST_F1(r, l, 3, 16); - _CAST_F3(l, r, 2, 16); - _CAST_F2(r, l, 1, 16); - _CAST_F1(l, r, 0, 16); + CAST_F1(r, l, 15, 16); + CAST_F3(l, r, 14, 16); + CAST_F2(r, l, 13, 16); + CAST_F1(l, r, 12, 16); + CAST_F3(r, l, 11, 16); + CAST_F2(l, r, 10, 16); + CAST_F1(r, l, 9, 16); + CAST_F3(l, r, 8, 16); + CAST_F2(r, l, 7, 16); + CAST_F1(l, r, 6, 16); + CAST_F3(r, l, 5, 16); + CAST_F2(l, r, 4, 16); + CAST_F1(r, l, 3, 16); + CAST_F3(l, r, 2, 16); + CAST_F2(r, l, 1, 16); + CAST_F1(l, r, 0, 16); /* Put l,r into outblock */ PUT_UINT32BE(r, outBlock, 0); PUT_UINT32BE(l, outBlock, 4); @@ -633,8 +633,8 @@ DECLSPEC void Cast5SetKey (PRIVATE_AS CAST_KEY *key, u32 keylength, PRIVATE_AS c GET_UINT32BE(X[2], userKey, 8); GET_UINT32BE(X[3], userKey, 12); - #define x(i) GETBYTE(X[i/4], 3-i%4) - #define z(i) GETBYTE(Z[i/4], 3-i%4) + #define x(i) GETBYTE(X[i/4], 3-i%4) + #define z(i) GETBYTE(Z[i/4], 3-i%4) for (i=0; i<=16; i+=16) { // this part is copied directly from RFC 2144 (with some search and replace) by Wei Dai @@ -673,11 +673,11 @@ DECLSPEC void Cast5SetKey (PRIVATE_AS CAST_KEY *key, u32 keylength, PRIVATE_AS c } u32 data[32]; - for (i = 0; i < 16; i++) { - data[i * 2] = K[i]; - data[i * 2 + 1] = ((K[i + 16]) + 16) & 0x1f; // here only the lowest 5 bits are set.. - } - for (i=16; i<32; i++) - K[i] &= 0x1f; + for (i = 0; i < 16; i++) { + data[i * 2] = K[i]; + data[i * 2 + 1] = ((K[i + 16]) + 16) & 0x1f; // here only the lowest 5 bits are set.. + } + + for (i=16; i<32; i++) K[i] &= 0x1f; } diff --git a/OpenCL/inc_cipher_cast.h b/OpenCL/inc_cipher_cast.h index 7b96dc558..46a511ec7 100644 --- a/OpenCL/inc_cipher_cast.h +++ b/OpenCL/inc_cipher_cast.h @@ -1,7 +1,5 @@ - - -#ifndef _OPENCL_CAST_H -#define _OPENCL_CAST_H +#ifndef INC_CIPHER_CAST_H +#define INC_CIPHER_CAST_H // #include "opencl_misc.h" #define GET_UINT32BE(n, b, i) \ @@ -32,28 +30,26 @@ typedef struct { #define U8d(x) GETBYTE(x,0) /* CAST uses three different round functions */ -#define _CAST_f1(l, r, km, kr) \ +#define CAST_f1(l, r, km, kr) \ t = hc_rotl32_S(km + r, kr); \ l ^= ((s_S[0][U8a(t)] ^ s_S[1][U8b(t)]) - \ s_S[2][U8c(t)]) + s_S[3][U8d(t)]; -#define _CAST_f2(l, r, km, kr) \ +#define CAST_f2(l, r, km, kr) \ t = hc_rotl32_S(km ^ r, kr); \ l ^= ((s_S[0][U8a(t)] - s_S[1][U8b(t)]) + \ s_S[2][U8c(t)]) ^ s_S[3][U8d(t)]; -#define _CAST_f3(l, r, km, kr) \ +#define CAST_f3(l, r, km, kr) \ t = hc_rotl32_S(km - r, kr); \ l ^= ((s_S[0][U8a(t)] + s_S[1][U8b(t)]) ^ \ s_S[2][U8c(t)]) - s_S[3][U8d(t)]; -#define _CAST_F1(l, r, i, j) _CAST_f1(l, r, K[i], K[i+j]) -#define _CAST_F2(l, r, i, j) _CAST_f2(l, r, K[i], K[i+j]) -#define _CAST_F3(l, r, i, j) _CAST_f3(l, r, K[i], K[i+j]) - +#define CAST_F1(l, r, i, j) CAST_f1(l, r, K[i], K[i+j]) +#define CAST_F2(l, r, i, j) CAST_f2(l, r, K[i], K[i+j]) +#define CAST_F3(l, r, i, j) CAST_f3(l, r, K[i], K[i+j]) /* OpenSSL API compatibility */ #define CAST_set_key(ckey, len, key) Cast5SetKey(ckey, len, key) #define CAST_ecb_encrypt(in, out, ckey) Cast5Encrypt(in, out, ckey) #define CAST_ecb_decrypt(in, out, ckey) Cast5Decrypt(in, out, ckey) - -#endif /* _OPENCL_CAST_H */ +#endif /* INC_CIPHER_CAST_H */ diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..aef8969c1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -134,6 +134,7 @@ - Help: show supported hash-modes only with -hh - Makefile: prevent make failure with Apple Silicon in case of partial rebuild - Rules: Rename best64.rule to best66.rule and remove the unknown section from it +- Kernel: Renamed multiple defines in CAST cipher to fit expected naming convention of the C++ language standard * changes v6.2.5 -> v6.2.6 From 5efbd2f435511fd055a648759a2d8d1aec47c9c6 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 31 Oct 2024 18:17:34 +0100 Subject: [PATCH 060/357] Fixed clang identification in src/Makefile --- docs/changes.txt | 1 + src/Makefile | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..96dd0e729 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -88,6 +88,7 @@ - Fixed build failed for 18600 with Apple Metal - Fixed build failed for 4410 with vector width > 1 - Fixed build failure for almost all hash modes that make use of hc_swap64 and/or hc_swap64_S with Apple Metal +- Fixed clang identification in src/Makefile - Fixed debug mode 5 by adding the missing colon between original-word and finding-rule - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 - Fixed incompatible pointer types (salt1 and salt2 buf) in 3730 a3 kernel diff --git a/src/Makefile b/src/Makefile index 1cd440645..786fb4b19 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,6 +37,8 @@ endif ifeq ($(DEBUG),1) $(info "## Detected Operating System : $(UNAME)") +$(info "## Detected CC : $(CC)") +$(info "## Detected CXX : $(CXX)") endif ## @@ -188,15 +190,17 @@ CFLAGS += -Wextra endif ## because LZMA SDK -ifeq ($(CC),clang) -#No longer supported in clang 10.0.0 -#CFLAGS += -Wno-enum-conversion +ifneq (,$(findstring clang, $(CC))) CFLAGS += -Wno-typedef-redefinition +else +ifeq ($(CC),cc) +CFLAGS += -Wno-typedef-redefinition +endif endif ifeq ($(USE_SYSTEM_LZMA),0) CFLAGS_LZMA += -D_7ZIP_ST -ifneq ($(CC),clang) +ifeq (,$(findstring clang, $(CC))) CFLAGS_LZMA += -Wno-misleading-indentation endif endif @@ -208,12 +212,15 @@ CFLAGS_ZLIB += -Wno-implicit-function-declaration CFLAGS_ZLIB += -Wno-unused-parameter CFLAGS_ZLIB += -DIOAPI_NO_64 CFLAGS_ZLIB += -DUNZ_BUFSIZE=262144 +ifneq (,$(findstring clang, $(CC))) +CFLAGS_ZLIB += -Wno-deprecated-non-prototype -Wno-unknown-warning-option +endif endif ## because UNRAR ifeq ($(ENABLE_UNRAR),1) ifeq ($(USE_SYSTEM_UNRAR),0) -ifneq ($(CC),clang) +ifeq (,$(findstring clang, $(CC))) CFLAGS_UNRAR += -Wno-class-memaccess CFLAGS_UNRAR += -Wno-misleading-indentation CFLAGS_UNRAR += -Wno-format-overflow From db814b583703a7f9ca3f3791f27a0b0f2637d4f9 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 31 Oct 2024 18:29:23 +0100 Subject: [PATCH 061/357] Update PR #3735 --- OpenCL/inc_common.cl | 4 ++-- docs/changes.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index 818b32e69..6976daed6 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -1317,7 +1317,7 @@ DECLSPEC u64x hc_swap64 (const u64x v) asm volatile ("mov.b64 %0, {%1, %2};" : "=l"(r.sf) : "r"(tr.sf), "r"(tl.sf)); #endif - #elif defined IS_METAL + #elif defined IS_METAL || defined IS_APPLE_SILICON const u32x a0 = h32_from_64 (v); const u32x a1 = l32_from_64 (v); @@ -1391,7 +1391,7 @@ DECLSPEC u64 hc_swap64_S (const u64 v) asm volatile ("mov.b64 %0, {%1, %2};" : "=l"(r) : "r"(tr), "r"(tl)); - #elif defined IS_METAL + #elif defined IS_METAL || defined IS_APPLE_SILICON const u32 v0 = h32_from_64_S (v); const u32 v1 = l32_from_64_S (v); diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..8e0579a0d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -87,7 +87,7 @@ - Fixed build failed for 18400 with Apple Metal - Fixed build failed for 18600 with Apple Metal - Fixed build failed for 4410 with vector width > 1 -- Fixed build failure for almost all hash modes that make use of hc_swap64 and/or hc_swap64_S with Apple Metal +- Fixed build failure for almost all hash modes that make use of hc_swap64 and/or hc_swap64_S with Apple Metal / Apple Silicon - Fixed debug mode 5 by adding the missing colon between original-word and finding-rule - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 - Fixed incompatible pointer types (salt1 and salt2 buf) in 3730 a3 kernel From d93d208ad8174cded81346a64c9a34340188c0f0 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 31 Oct 2024 18:43:35 +0100 Subject: [PATCH 062/357] Modules: Added module_unstable_warning for 22500, update module_unstable_warning for 10700 --- docs/changes.txt | 1 + src/modules/module_10700.c | 7 ++----- src/modules/module_22500.c | 13 ++++++++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..37d53e24d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -118,6 +118,7 @@ - Building: Support building windows binaries on macOS using MinGW - Dependencies: Updated OpenCL-Headers to v2023.04.17 - Documents: Updated BUILD.md and added BUILD_macOS.md (containing instructions for building windows binaries on macOS) +- Modules: Added module_unstable_warning for 22500, update module_unstable_warning for 10700 - Modules: Added support for non-zero IVs for -m 6800 (Lastpass). Also added `tools/lastpass2hashcat.py` - Open Document Format: Added support for small documents with content length < 1024 - Status Code: Add specific return code for self-test fail (-11) diff --git a/src/modules/module_10700.c b/src/modules/module_10700.c index 05be37b65..a28e79829 100644 --- a/src/modules/module_10700.c +++ b/src/modules/module_10700.c @@ -84,13 +84,10 @@ static const int ROUNDS_PDF17L8 = 64; bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // AppleM1, OpenCL, MTLCompilerService, createKernel never-end with pure kernel + // AppleM1, OpenCL, MTLCompilerService, createKernel never-end with pure kernel and newComputePipelineState failed with optimized kernel if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } + return true; } return false; diff --git a/src/modules/module_22500.c b/src/modules/module_22500.c index 534539b4e..9f47c6689 100644 --- a/src/modules/module_22500.c +++ b/src/modules/module_22500.c @@ -43,6 +43,17 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, static const char *SIGNATURE_MULTIBIT = "$multibit$"; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // AppleM1, OpenCL, MTLCompilerService never-end + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + return false; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); @@ -228,6 +239,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } From e5491828899d33eb196c2abd7afb8f19181807a3 Mon Sep 17 00:00:00 2001 From: magnum Date: Tue, 10 Sep 2024 00:12:21 +0200 Subject: [PATCH 063/357] Added m10510 for PDF 1.4 - 1.6 using RC4-40 Actually the key can be 40 to 128 bits in multiples of 4 according to the specification, but supporting arbitrary key length hits performance (and need for that should be extremely rare). Note: Self-test vector is a mockup but the format was first tested using a real document hash. --- OpenCL/m10510-pure.cl | 360 +++++++++++++++++++++++++ src/modules/module_10510.c | 539 +++++++++++++++++++++++++++++++++++++ 2 files changed, 899 insertions(+) create mode 100644 OpenCL/m10510-pure.cl create mode 100644 src/modules/module_10510.c diff --git a/OpenCL/m10510-pure.cl b/OpenCL/m10510-pure.cl new file mode 100644 index 000000000..2914d1360 --- /dev/null +++ b/OpenCL/m10510-pure.cl @@ -0,0 +1,360 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_cipher_rc4.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; + +} pdf_t; + +typedef struct pdf14_tmp +{ + u32 digest[4]; + u32 out[4]; + +} pdf14_tmp_t; + +KERNEL_FQ void m10510_init (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + //const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + const u32 pw_len = pws[gid].pw_len; + + /** + * U_buf + */ + + u32 o_buf[8]; + + o_buf[0] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[0]; + o_buf[1] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[1]; + o_buf[2] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[2]; + o_buf[3] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[3]; + o_buf[4] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[4]; + o_buf[5] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[5]; + o_buf[6] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[6]; + o_buf[7] = esalt_bufs[DIGESTS_OFFSET_HOST].o_buf[7]; + + u32 P = esalt_bufs[DIGESTS_OFFSET_HOST].P; + + u32 id_buf[12]; + + id_buf[ 0] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[0]; + id_buf[ 1] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[1]; + id_buf[ 2] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[2]; + id_buf[ 3] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[3]; + + id_buf[ 4] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[4]; + id_buf[ 5] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[5]; + id_buf[ 6] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[6]; + id_buf[ 7] = esalt_bufs[DIGESTS_OFFSET_HOST].id_buf[7]; + + id_buf[ 8] = 0; + id_buf[ 9] = 0; + id_buf[10] = 0; + id_buf[11] = 0; + + u32 id_len = esalt_bufs[DIGESTS_OFFSET_HOST].id_len; + u32 id_len4 = id_len / 4; + + u32 rc4data[2]; + + rc4data[0] = esalt_bufs[DIGESTS_OFFSET_HOST].rc4data[0]; + rc4data[1] = esalt_bufs[DIGESTS_OFFSET_HOST].rc4data[1]; + + u32 final_length = 68 + id_len; + + u32 w11 = 0x80; + u32 w12 = 0; + + if (esalt_bufs[DIGESTS_OFFSET_HOST].enc_md != 1) + { + w11 = 0xffffffff; + w12 = 0x80; + + final_length += 4; + } + + id_buf[id_len4 + 0] = w11; + id_buf[id_len4 + 1] = w12; + + /** + * main init + */ + + u32 w0_t[4]; + u32 w1_t[4]; + u32 w2_t[4]; + u32 w3_t[4]; + + // max length supported by pdf11 is 32 + + const u32 padding[8] = + { + 0x5e4ebf28, + 0x418a754e, + 0x564e0064, + 0x0801faff, + 0xb6002e2e, + 0x803e68d0, + 0xfea90c2f, + 0x7a695364 + }; + + w0_t[0] = padding[0]; + w0_t[1] = padding[1]; + w0_t[2] = padding[2]; + w0_t[3] = padding[3]; + w1_t[0] = padding[4]; + w1_t[1] = padding[5]; + w1_t[2] = padding[6]; + w1_t[3] = padding[7]; + w2_t[0] = 0; + w2_t[1] = 0; + w2_t[2] = 0; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 0; + w3_t[3] = 0; + + switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, pw_len); + + // add password + // truncate at 32 is wanted, not a bug! + // add o_buf + + w0_t[0] |= w0[0]; + w0_t[1] |= w0[1]; + w0_t[2] |= w0[2]; + w0_t[3] |= w0[3]; + w1_t[0] |= w1[0]; + w1_t[1] |= w1[1]; + w1_t[2] |= w1[2]; + w1_t[3] |= w1[3]; + w2_t[0] = o_buf[0]; + w2_t[1] = o_buf[1]; + w2_t[2] = o_buf[2]; + w2_t[3] = o_buf[3]; + w3_t[0] = o_buf[4]; + w3_t[1] = o_buf[5]; + w3_t[2] = o_buf[6]; + w3_t[3] = o_buf[7]; + + u32 digest[4]; + + digest[0] = MD5M_A; + digest[1] = MD5M_B; + digest[2] = MD5M_C; + digest[3] = MD5M_D; + + md5_transform (w0_t, w1_t, w2_t, w3_t, digest); + + w0_t[0] = P; + w0_t[1] = id_buf[ 0]; + w0_t[2] = id_buf[ 1]; + w0_t[3] = id_buf[ 2]; + w1_t[0] = id_buf[ 3]; + w1_t[1] = id_buf[ 4]; + w1_t[2] = id_buf[ 5]; + w1_t[3] = id_buf[ 6]; + w2_t[0] = id_buf[ 7]; + w2_t[1] = id_buf[ 8]; + w2_t[2] = id_buf[ 9]; + w2_t[3] = id_buf[10]; + w3_t[0] = id_buf[11]; + w3_t[1] = 0; + w3_t[2] = final_length * 8; + w3_t[3] = 0; + + md5_transform (w0_t, w1_t, w2_t, w3_t, digest); + + tmps[gid].digest[0] = digest[0]; + tmps[gid].digest[1] = digest[1]; + tmps[gid].digest[2] = digest[2]; + tmps[gid].digest[3] = digest[3]; + + tmps[gid].out[0] = rc4data[0]; + tmps[gid].out[1] = rc4data[1]; + tmps[gid].out[2] = 0; + tmps[gid].out[3] = 0; +} + +KERNEL_FQ void m10510_loop (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + /** + * shared + */ + + LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE]; + + /** + * loop + */ + + u32 digest[4]; + + digest[0] = tmps[gid].digest[0]; + digest[1] = tmps[gid].digest[1]; + digest[2] = tmps[gid].digest[2]; + digest[3] = tmps[gid].digest[3]; + + u32 out[4]; + + out[0] = tmps[gid].out[0]; + out[1] = tmps[gid].out[1]; + out[2] = tmps[gid].out[2]; + out[3] = tmps[gid].out[3]; + + for (u32 i = 0, j = LOOP_POS; i < LOOP_CNT; i++, j++) + { + if (j < 50) + { + u32 w0_t[4]; + u32 w1_t[4]; + u32 w2_t[4]; + u32 w3_t[4]; + + w0_t[0] = digest[0]; + w0_t[1] = 0x8000 + (digest[1] & 0xff); + w0_t[2] = 0; + w0_t[3] = 0; + w1_t[0] = 0; + w1_t[1] = 0; + w1_t[2] = 0; + w1_t[3] = 0; + w2_t[0] = 0; + w2_t[1] = 0; + w2_t[2] = 0; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 40; + w3_t[3] = 0; + + digest[0] = MD5M_A; + digest[1] = MD5M_B; + digest[2] = MD5M_C; + digest[3] = MD5M_D; + + md5_transform (w0_t, w1_t, w2_t, w3_t, digest); + } + else + { + const u32 x = j - 50; + + const u32 xv = x << 0 + | x << 8 + | x << 16 + | x << 24; + + u32 tmp[2]; + + tmp[0] = digest[0] ^ xv; + tmp[1] = (digest[1] ^ xv) & 0xff; + + rc4_init_40 (S, tmp, lid); + + rc4_next_16 (S, 0, 0, out, out, lid); + } + } + + tmps[gid].digest[0] = digest[0]; + tmps[gid].digest[1] = digest[1] & 0xff; + tmps[gid].digest[2] = 0; + tmps[gid].digest[3] = 0; + + tmps[gid].out[0] = out[0]; + tmps[gid].out[1] = out[1]; + tmps[gid].out[2] = out[2]; + tmps[gid].out[3] = out[3]; +} + +KERNEL_FQ void m10510_comp (KERN_ATTR_TMPS_ESALT (pdf14_tmp_t, pdf_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u64 lid = get_local_id (0); + + /** + * digest + */ + + const u32 r0 = tmps[gid].out[0]; + const u32 r1 = tmps[gid].out[1]; + const u32 r2 = 0; + const u32 r3 = 0; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/src/modules/module_10510.c b/src/modules/module_10510.c new file mode 100644 index 000000000..683253436 --- /dev/null +++ b/src/modules/module_10510.c @@ -0,0 +1,539 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_DOCUMENTS; +static const char *HASH_NAME = "PDF 1.3 - 1.6 (Acrobat 4 - 8) w/ RC4-40"; +static const u64 KERN_TYPE = 10510; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$pdf$1*3*40*-4*1*16*5e1f73575e1f73575e1f73575e1f7357*32*c0be424bef466277092f2a1ba0fbe506ebabe5c01db100dedc0ffeebabe5c01d*32*0ff1cedeadce110ff1cedeadce110ff1cedeadce110ff1cedeadce11babebabe"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct pdf +{ + int V; + int R; + int P; + + int enc_md; + + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; + + int id_len; + int o_len; + int u_len; + + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; + +} pdf_t; + +typedef struct pdf14_tmp +{ + u32 digest[4]; + u32 out[4]; + +} pdf14_tmp_t; + +static const char *SIGNATURE_PDF = "$pdf$"; + +static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len) +{ + // plain = u32 tmp_md5_buf[64] so this is compatible + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, plain, plain_len); + md5_final (&md5_ctx); + + digest[0] = md5_ctx.h[0]; + digest[1] = md5_ctx.h[1]; + digest[2] = md5_ctx.h[2]; + digest[3] = md5_ctx.h[3]; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + u32 native_threads = 0; + + if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) + { + native_threads = 1; + } + else if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) + { + #if defined (__APPLE__) + + native_threads = 32; + + #else + + if (device_param->device_local_mem_size < 49152) + { + native_threads = MIN (device_param->kernel_preferred_wgs_multiple, 32); // We can't just set 32, because Intel GPU need 8 + } + else + { + native_threads = device_param->kernel_preferred_wgs_multiple; + } + + #endif + } + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D _unroll", native_threads); + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pdf_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pdf14_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = 32; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pdf_t *pdf = (pdf_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 12; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_PDF; + + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '*'; + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[3] = '*'; + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[4] = '*'; + token.len_min[4] = 1; + token.len_max[4] = 11; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[5] = '*'; + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[6] = '*'; + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[7] = '*'; + token.len_min[7] = 32; + token.len_max[7] = 64; + token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[8] = '*'; + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[9] = '*'; + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[11] = '*'; + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *V_pos = token.buf[1]; + const u8 *R_pos = token.buf[2]; + const u8 *bits_pos = token.buf[3]; + const u8 *P_pos = token.buf[4]; + const u8 *enc_md_pos = token.buf[5]; + const u8 *id_len_pos = token.buf[6]; + const u8 *id_buf_pos = token.buf[7]; + const u8 *u_len_pos = token.buf[8]; + const u8 *u_buf_pos = token.buf[9]; + const u8 *o_len_pos = token.buf[10]; + const u8 *o_buf_pos = token.buf[11]; + + // validate data + + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + + const int V = strtol ((const char *) V_pos, NULL, 10); + const int R = strtol ((const char *) R_pos, NULL, 10); + const int P = strtol ((const char *) P_pos, NULL, 10); + + int vr_ok = 0; + + if ((V == 1 || V == 2) && (R == 3)) vr_ok = 1; + if ((V == 4) && (R == 4)) vr_ok = 1; + + if (vr_ok == 0) return (PARSER_SALT_VALUE); + + const int id_len = strtol ((const char *) id_len_pos, NULL, 10); + const int u_len = strtol ((const char *) u_len_pos, NULL, 10); + const int o_len = strtol ((const char *) o_len_pos, NULL, 10); + + if ((id_len != 16) && (id_len != 32)) return (PARSER_SALT_VALUE); + + if (u_len != 32) return (PARSER_SALT_VALUE); + if (o_len != 32) return (PARSER_SALT_VALUE); + + const int bits = strtol ((const char *) bits_pos, NULL, 10); + + if (bits != 40) return (PARSER_SALT_VALUE); + + int enc_md = 1; + + if (R >= 4) + { + enc_md = strtol ((const char *) enc_md_pos, NULL, 10); + } + + // copy data to esalt + + pdf->V = V; + pdf->R = R; + pdf->P = P; + + pdf->enc_md = enc_md; + + pdf->id_buf[0] = hex_to_u32 (id_buf_pos + 0); + pdf->id_buf[1] = hex_to_u32 (id_buf_pos + 8); + pdf->id_buf[2] = hex_to_u32 (id_buf_pos + 16); + pdf->id_buf[3] = hex_to_u32 (id_buf_pos + 24); + + if (id_len == 32) + { + pdf->id_buf[4] = hex_to_u32 (id_buf_pos + 32); + pdf->id_buf[5] = hex_to_u32 (id_buf_pos + 40); + pdf->id_buf[6] = hex_to_u32 (id_buf_pos + 48); + pdf->id_buf[7] = hex_to_u32 (id_buf_pos + 56); + } + + pdf->id_len = id_len; + + pdf->u_buf[0] = hex_to_u32 (u_buf_pos + 0); + pdf->u_buf[1] = hex_to_u32 (u_buf_pos + 8); + pdf->u_buf[2] = hex_to_u32 (u_buf_pos + 16); + pdf->u_buf[3] = hex_to_u32 (u_buf_pos + 24); + pdf->u_buf[4] = hex_to_u32 (u_buf_pos + 32); + pdf->u_buf[5] = hex_to_u32 (u_buf_pos + 40); + pdf->u_buf[6] = hex_to_u32 (u_buf_pos + 48); + pdf->u_buf[7] = hex_to_u32 (u_buf_pos + 56); + pdf->u_len = u_len; + + pdf->o_buf[0] = hex_to_u32 (o_buf_pos + 0); + pdf->o_buf[1] = hex_to_u32 (o_buf_pos + 8); + pdf->o_buf[2] = hex_to_u32 (o_buf_pos + 16); + pdf->o_buf[3] = hex_to_u32 (o_buf_pos + 24); + pdf->o_buf[4] = hex_to_u32 (o_buf_pos + 32); + pdf->o_buf[5] = hex_to_u32 (o_buf_pos + 40); + pdf->o_buf[6] = hex_to_u32 (o_buf_pos + 48); + pdf->o_buf[7] = hex_to_u32 (o_buf_pos + 56); + pdf->o_len = o_len; + + // precompute rc4 data for later use + + u32 padding[8] = + { + 0x5e4ebf28, + 0x418a754e, + 0x564e0064, + 0x0801faff, + 0xb6002e2e, + 0x803e68d0, + 0xfea90c2f, + 0x7a695364 + }; + + // md5 + + u32 salt_pc_block[32] = { 0 }; + + u8 *salt_pc_ptr = (u8 *) salt_pc_block; + + memcpy (salt_pc_ptr, padding, 32); + memcpy (salt_pc_ptr + 32, pdf->id_buf, pdf->id_len); + + u32 salt_pc_digest[4] = { 0 }; + + md5_complete_no_limit (salt_pc_digest, salt_pc_block, 32 + pdf->id_len); + + pdf->rc4data[0] = salt_pc_digest[0]; + pdf->rc4data[1] = salt_pc_digest[1]; + + // we use ID for salt, maybe needs to change, we will see... + + salt->salt_buf[0] = pdf->id_buf[0]; + salt->salt_buf[1] = pdf->id_buf[1]; + salt->salt_buf[2] = pdf->id_buf[2]; + salt->salt_buf[3] = pdf->id_buf[3]; + salt->salt_buf[4] = pdf->u_buf[0]; + salt->salt_buf[5] = pdf->u_buf[1]; + salt->salt_buf[6] = pdf->o_buf[0]; + salt->salt_buf[7] = pdf->o_buf[1]; + salt->salt_len = pdf->id_len + 16; + + salt->salt_iter = (50 + 20); + + digest[0] = pdf->u_buf[0]; + digest[1] = pdf->u_buf[1]; + digest[2] = 0; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const pdf_t *pdf = (const pdf_t *) esalt_buf; + + int line_len = 0; + + if (pdf->id_len == 32) + { + const char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, + pdf->V, + pdf->R, + 40, + pdf->P, + pdf->enc_md, + pdf->id_len, + byte_swap_32 (pdf->id_buf[0]), + byte_swap_32 (pdf->id_buf[1]), + byte_swap_32 (pdf->id_buf[2]), + byte_swap_32 (pdf->id_buf[3]), + byte_swap_32 (pdf->id_buf[4]), + byte_swap_32 (pdf->id_buf[5]), + byte_swap_32 (pdf->id_buf[6]), + byte_swap_32 (pdf->id_buf[7]), + pdf->u_len, + byte_swap_32 (pdf->u_buf[0]), + byte_swap_32 (pdf->u_buf[1]), + byte_swap_32 (pdf->u_buf[2]), + byte_swap_32 (pdf->u_buf[3]), + byte_swap_32 (pdf->u_buf[4]), + byte_swap_32 (pdf->u_buf[5]), + byte_swap_32 (pdf->u_buf[6]), + byte_swap_32 (pdf->u_buf[7]), + pdf->o_len, + byte_swap_32 (pdf->o_buf[0]), + byte_swap_32 (pdf->o_buf[1]), + byte_swap_32 (pdf->o_buf[2]), + byte_swap_32 (pdf->o_buf[3]), + byte_swap_32 (pdf->o_buf[4]), + byte_swap_32 (pdf->o_buf[5]), + byte_swap_32 (pdf->o_buf[6]), + byte_swap_32 (pdf->o_buf[7]) + ); + } + else + { + const char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, + pdf->V, + pdf->R, + 40, + pdf->P, + pdf->enc_md, + pdf->id_len, + byte_swap_32 (pdf->id_buf[0]), + byte_swap_32 (pdf->id_buf[1]), + byte_swap_32 (pdf->id_buf[2]), + byte_swap_32 (pdf->id_buf[3]), + pdf->u_len, + byte_swap_32 (pdf->u_buf[0]), + byte_swap_32 (pdf->u_buf[1]), + byte_swap_32 (pdf->u_buf[2]), + byte_swap_32 (pdf->u_buf[3]), + byte_swap_32 (pdf->u_buf[4]), + byte_swap_32 (pdf->u_buf[5]), + byte_swap_32 (pdf->u_buf[6]), + byte_swap_32 (pdf->u_buf[7]), + pdf->o_len, + byte_swap_32 (pdf->o_buf[0]), + byte_swap_32 (pdf->o_buf[1]), + byte_swap_32 (pdf->o_buf[2]), + byte_swap_32 (pdf->o_buf[3]), + byte_swap_32 (pdf->o_buf[4]), + byte_swap_32 (pdf->o_buf[5]), + byte_swap_32 (pdf->o_buf[6]), + byte_swap_32 (pdf->o_buf[7]) + ); + } + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} From 3a3453c9dd5300747b980e57e9c5bd38f3afd54f Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 3 Nov 2024 03:23:20 +0100 Subject: [PATCH 064/357] Added hash-mode: md5(md5(md5($pass.$salt1)).$salt2) --- OpenCL/m32800_a0-pure.cl | 335 +++++++++++++++++++++++++++++++++ OpenCL/m32800_a1-pure.cl | 329 ++++++++++++++++++++++++++++++++ OpenCL/m32800_a3-pure.cl | 355 +++++++++++++++++++++++++++++++++++ docs/changes.txt | 1 + docs/readme.txt | 1 + src/modules/module_32800.c | 275 +++++++++++++++++++++++++++ tools/test_modules/m32800.pm | 46 +++++ 7 files changed, 1342 insertions(+) create mode 100644 OpenCL/m32800_a0-pure.cl create mode 100644 OpenCL/m32800_a1-pure.cl create mode 100644 OpenCL/m32800_a3-pure.cl create mode 100644 src/modules/module_32800.c create mode 100644 tools/test_modules/m32800.pm diff --git a/OpenCL/m32800_a0-pure.cl b/OpenCL/m32800_a0-pure.cl new file mode 100644 index 000000000..9df5a7b80 --- /dev/null +++ b/OpenCL/m32800_a0-pure.cl @@ -0,0 +1,335 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m32800_mxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_update (&ctx0, salt1_buf, salt1_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_update (&ctx0, salt1_buf, salt1_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32800_a1-pure.cl b/OpenCL/m32800_a1-pure.cl new file mode 100644 index 000000000..756df73ab --- /dev/null +++ b/OpenCL/m32800_a1-pure.cl @@ -0,0 +1,329 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m32800_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx1, salt1_buf, salt1_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx1, salt1_buf, salt1_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32800_a3-pure.cl b/OpenCL/m32800_a3-pure.cl new file mode 100644 index 000000000..531785dde --- /dev/null +++ b/OpenCL/m32800_a3-pure.cl @@ -0,0 +1,355 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m32800_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_update_vector (&ctx0, salt1_buf, salt1_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32800_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_update_vector (&ctx0, salt1_buf, salt1_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/docs/changes.txt b/docs/changes.txt index 283e3c0d4..5cf5a62bc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -49,6 +49,7 @@ - Added hash-mode: md5(md5($salt).md5(md5($pass))) - Added hash-mode: Domain Cached Credentials 2 (DCC2), MS Cache 2, (NT) - Added hash-mode: Domain Cached Credentials (DCC), MS Cache (NT) +- Added hash-mode: md5(md5(md5($pass.$salt1)).$salt2) - Added hash-mode: md5(md5(md5($pass).$salt1).$salt2) - Added hash-mode: md5(md5(md5($pass)).$salt) - Added hash-mode: md5(sha1($pass.$salt)) diff --git a/docs/readme.txt b/docs/readme.txt index e5fd69f25..4a5bfa7a7 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -94,6 +94,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - md5(md5(md5($pass))) - md5(md5(md5($pass)).$salt) - md5(md5(md5($pass).$salt1).$salt2) +- md5(md5(md5($pass.$salt1)).$salt2) - md5(sha1($pass)) - md5(sha1($pass).$salt) - md5(sha1($pass).md5($pass).sha1($pass)) diff --git a/src/modules/module_32800.c b/src/modules/module_32800.c new file mode 100644 index 000000000..0d2469591 --- /dev/null +++ b/src/modules/module_32800.c @@ -0,0 +1,275 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(md5(md5($pass.$salt1)).$salt2)"; +static const u64 KERN_TYPE = 32800; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "2c749af6c65cf3e82e5837e3056727f5:59331674906582121215362940957615121466283616005471:17254656838978443692786064919357750120910718779182716907569266"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (md5_double_salt_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + md5_double_salt_t *md5_double_salt = (md5_double_salt_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = hashconfig->separator; + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = hashconfig->separator; + token.len_min[2] = SALT_MIN; + token.len_max[2] = SALT_MAX; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + + token.len_min[2] *= 2; + token.len_max[2] *= 2; + + token.attr[2] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const bool parse_rc1 = generic_salt_decode (hashconfig, token.buf[1], token.len[1], (u8 *) md5_double_salt->salt1_buf, &md5_double_salt->salt1_len); + + if (parse_rc1 == false) return (PARSER_SALT_LENGTH); + + const bool parse_rc2 = generic_salt_decode (hashconfig, token.buf[2], token.len[2], (u8 *) md5_double_salt->salt2_buf, &md5_double_salt->salt2_len); + + if (parse_rc2 == false) return (PARSER_SALT_LENGTH); + + // make salt sorter happy + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, md5_double_salt->salt1_buf, md5_double_salt->salt1_len); + md5_update (&md5_ctx, md5_double_salt->salt2_buf, md5_double_salt->salt2_len); + md5_final (&md5_ctx); + + salt->salt_buf[0] = md5_ctx.h[0]; + salt->salt_buf[1] = md5_ctx.h[1]; + salt->salt_buf[2] = md5_ctx.h[2]; + salt->salt_buf[3] = md5_ctx.h[3]; + + salt->salt_len = 16; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const md5_double_salt_t *md5_double_salt = (const md5_double_salt_t *) esalt_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_double_salt->salt1_buf, md5_double_salt->salt1_len, out_buf + out_len); + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_double_salt->salt2_buf, md5_double_salt->salt2_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/test_modules/m32800.pm b/tools/test_modules/m32800.pm new file mode 100644 index 000000000..e283dcafd --- /dev/null +++ b/tools/test_modules/m32800.pm @@ -0,0 +1,46 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 256], [0, 256], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt1 = shift; + my $salt2 = shift || random_numeric_string (random_number (1, 255)); + + my $digest = md5_hex (md5_hex (md5_hex ($word . $salt1)) . $salt2); + + my $hash = sprintf ("%s:%s:%s", $digest, $salt1, $salt2); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt1, $salt2, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt1; + return unless defined $salt2; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt1, $salt2); + + return ($new_hash, $word); +} + +1; From d6b50c7d0b495220e09fcbb079726af360fdf870 Mon Sep 17 00:00:00 2001 From: Nripesh Niketan Date: Wed, 6 Nov 2024 10:29:13 +0000 Subject: [PATCH 065/357] chore: update github workflow --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81990ba77..44fa387e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,13 +49,13 @@ jobs: name: Build Linux (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build env: SHARED: ${{ matrix.shared }} run: make - name: Generate artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: hashcat-linux-${{ matrix.shared == 0 && 'static' || 'shared' }} path: ${{ env.include_paths }} @@ -68,13 +68,13 @@ jobs: name: Build macOS (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build env: SHARED: ${{ matrix.shared }} run: make - name: Generate artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: hashcat-macos-${{ matrix.shared == 0 && 'static' || 'shared' }} path: ${{ env.include_paths }} @@ -97,14 +97,14 @@ jobs: libiconv libiconv-devel make - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build shell: msys2 {0} env: SHARED: ${{ matrix.shared }} run: make - name: Generate artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: hashcat-windows-${{ matrix.shared == 0 && 'static' || 'shared' }} path: ${{ env.include_paths }} From 620731c8e8d9269a9eea4d4b3345600ffdaa3bde Mon Sep 17 00:00:00 2001 From: Nripesh Niketan Date: Wed, 6 Nov 2024 10:31:15 +0000 Subject: [PATCH 066/357] Optimize github workflow --- .github/workflows/build.yml | 77 ++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44fa387e0..4dbbda26f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,53 +41,36 @@ on: - '.github/workflows/build.yml' jobs: - build-linux: + build: strategy: fail-fast: false matrix: - shared: [0, 1] - name: Build Linux (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) - runs-on: ubuntu-latest + include: + - os: ubuntu-latest + os_name: linux + shared: 0 + - os: ubuntu-latest + os_name: linux + shared: 1 + - os: macos-latest + os_name: macos + shared: 0 + - os: macos-latest + os_name: macos + shared: 1 + - os: windows-latest + os_name: windows + shared: 0 + - os: windows-latest + os_name: windows + shared: 1 + name: Build ${{ matrix.os_name }} (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Build - env: - SHARED: ${{ matrix.shared }} - run: make - - name: Generate artifacts - uses: actions/upload-artifact@v4 - with: - name: hashcat-linux-${{ matrix.shared == 0 && 'static' || 'shared' }} - path: ${{ env.include_paths }} - build-macos: - strategy: - fail-fast: false - matrix: - shared: [0, 1] - name: Build macOS (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - name: Build - env: - SHARED: ${{ matrix.shared }} - run: make - - name: Generate artifacts - uses: actions/upload-artifact@v4 - with: - name: hashcat-macos-${{ matrix.shared == 0 && 'static' || 'shared' }} - path: ${{ env.include_paths }} - - build-windows: - strategy: - fail-fast: false - matrix: - shared: [0, 1] - name: Build Windows (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) - runs-on: windows-latest - steps: - - name: Install libiconv + - name: Install dependencies (Windows only) + if: matrix.os_name == 'windows' uses: msys2/setup-msys2@v2 with: update: true @@ -97,14 +80,22 @@ jobs: libiconv libiconv-devel make - - uses: actions/checkout@v4 + - name: Build + if: matrix.os_name == 'windows' shell: msys2 {0} env: SHARED: ${{ matrix.shared }} run: make + + - name: Build + if: matrix.os_name != 'windows' + env: + SHARED: ${{ matrix.shared }} + run: make + - name: Generate artifacts uses: actions/upload-artifact@v4 with: - name: hashcat-windows-${{ matrix.shared == 0 && 'static' || 'shared' }} + name: hashcat-${{ matrix.os_name }}-${{ matrix.shared == 0 && 'static' || 'shared' }} path: ${{ env.include_paths }} From 0ba76629c0164e9c5b077fc0f5f06e3c7bbb873e Mon Sep 17 00:00:00 2001 From: wizardsd Date: Thu, 7 Nov 2024 12:47:36 +0300 Subject: [PATCH 067/357] Fixed a host buffer overflow bug when copying rules from host to device --- src/backend.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..59b287cdc 100644 --- a/src/backend.c +++ b/src/backend.c @@ -9817,8 +9817,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) u32 aligned_rules_cnt = MAX (MAX (straight_ctx->kernel_rules_cnt, device_param->kernel_loops_min), KERNEL_RULES); - u64 size_rules = (u64) aligned_rules_cnt * sizeof (kernel_rule_t); - u64 size_rules_c = (u64) KERNEL_RULES * sizeof (kernel_rule_t); + u64 size_rules = (u64) aligned_rules_cnt * sizeof (kernel_rule_t); + u64 size_rules_src = (u64) straight_ctx->kernel_rules_cnt * sizeof (kernel_rule_t); // size of source rules buffer can be less than aligned_rules_cnt + u64 size_rules_c = (u64) KERNEL_RULES * sizeof (kernel_rule_t); device_param->size_rules = size_rules; device_param->size_rules_c = size_rules_c; @@ -10872,7 +10873,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_cuMemAlloc (hashcat_ctx, &device_param->cuda_d_rules_c, size_rules_c) == -1) return -1; } - if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_rules, straight_ctx->kernel_rules_buf, size_rules, device_param->cuda_stream) == -1) return -1; + if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_rules, straight_ctx->kernel_rules_buf, size_rules_src, device_param->cuda_stream) == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { @@ -10983,7 +10984,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_hipMemAlloc (hashcat_ctx, &device_param->hip_d_rules_c, size_rules_c) == -1) return -1; } - if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_rules, straight_ctx->kernel_rules_buf, size_rules, device_param->hip_stream) == -1) return -1; + if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_rules, straight_ctx->kernel_rules_buf, size_rules_src, device_param->hip_stream) == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { @@ -11100,7 +11101,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_rules, NULL, &device_param->metal_d_rules) == -1) return -1; if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_rules_c, NULL, &device_param->metal_d_rules_c) == -1) return -1; - if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_rules, 0, straight_ctx->kernel_rules_buf, size_rules) == -1) return -1; + if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_rules, 0, straight_ctx->kernel_rules_buf, size_rules_src) == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { @@ -11194,7 +11195,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_clCreateBuffer (hashcat_ctx, device_param->opencl_context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->opencl_d_rules) == -1) return -1; if (hc_clCreateBuffer (hashcat_ctx, device_param->opencl_context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->opencl_d_rules_c) == -1) return -1; - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_rules, CL_FALSE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL) == -1) return -1; + if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_rules, CL_FALSE, 0, size_rules_src, straight_ctx->kernel_rules_buf, 0, NULL, NULL) == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { From ebf2c154c2786c65d32e5dfb10047f3c55205066 Mon Sep 17 00:00:00 2001 From: Stig Palmquist Date: Thu, 21 Nov 2024 18:04:31 +0100 Subject: [PATCH 068/357] Fix problems with Mojolicious "paWlpaWl" module This commit fixes issues with the 16501 module for Mojolicious cookies. - Fix parsing of message: The base64 encoded message has '=' characters replaced with '-' meaning that three such characters can be encountered at the end of the message. This commit sets a fixed size for the message and doesnt use a `sep` to parse it. - Update self-test with real-world mojolicious cookie. - Update the test module to reflect what's actually happening when Mojolicious generates a signed cookie. --- src/modules/module_16501.c | 39 ++++++++++++++++++------------------ tools/test_modules/m16501.pm | 18 +++++------------ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/modules/module_16501.c b/src/modules/module_16501.c index 06b8f7e37..36ddd6e4c 100644 --- a/src/modules/module_16501.c +++ b/src/modules/module_16501.c @@ -30,8 +30,8 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_SELF_TEST_DISABLE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; -static const char *ST_PASS = "secret"; -static const char *ST_HASH = "mojolicious=eyJleHBpcmVzIjoyMDAwMDAwMDAwLCAidXNlciI6ICJzdXBlcnVzZXIifVpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlo--9d32db342a1caa83910dc8db51ff387591c40144bc0dddfa437d03a7d65688da"; +static const char *ST_PASS = "foobar"; +static const char *ST_HASH = "mojolicious=eyJiYXIiOiJhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmNhYmMiLCJleHBpcmVzIjoxNzMyMTYyOTMyLCJmb29vIjoxfVpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlo---113312f6f43e8f53e4e5eddb3d1603613fcd5073d947935ff7e08b2f79d921f8"; u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } @@ -97,7 +97,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE memset (&token, 0, sizeof (hc_token_t)); - token.token_cnt = 4; + token.token_cnt = 5; // total = max 4096 characters // name=value = max 4030 characters @@ -105,17 +105,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // cookie name token.sep[0] = '='; token.len_min[0] = 1; - token.len_max[0] = 3005; // what's left of max cookie length + token.len_max[0] = 128; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - // '=' as separator - - // cookie value - token.sep[1] = '-'; - token.len_min[1] = 1024; // if there's no padding, it's not new cookie - token.len_max[1] = 4030; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_BASE64A; + // cookie value: uses a fixed length as the value is padded to 1025 + // bytes with 'Z' characters before being base64 encoded. Note that + // '=' is replaced with '-' in the base64 output. + token.len[1] = 1368; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // '--' as separator token.sep[2] = '-'; @@ -123,12 +120,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_max[2] = 0; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; - - // signature = 64 characters + // '--' as separator token.sep[3] = '-'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = 0; + token.len_min[3] = 0; + token.len_max[3] = 0; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; + + // signature: hmac_sha256 hex encoded + token.len_min[4] = 64; + token.len_max[4] = 64; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -136,7 +137,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const int name_len = token.len[0]; const int payload_len = token.len[1]; - mojolicious->signature_len = token.len[3]; + mojolicious->signature_len = token.len[4]; // esalt @@ -183,7 +184,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_len = 16; - const u8 *hash_pos = token.buf[3]; + const u8 *hash_pos = token.buf[4]; u32 *digest = (u32 *) digest_buf; digest[0] = hex_to_u32 (hash_pos + 0); diff --git a/tools/test_modules/m16501.pm b/tools/test_modules/m16501.pm index ee68f4565..c0fd3e1ea 100644 --- a/tools/test_modules/m16501.pm +++ b/tools/test_modules/m16501.pm @@ -9,7 +9,7 @@ use strict; use warnings; use Digest::SHA qw (hmac_sha256_hex); -use MIME::Base64 qw (encode_base64url); +use MIME::Base64 qw (encode_base64); use JSON qw (encode_json); sub module_constraints { [[0, 64], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } @@ -19,12 +19,9 @@ sub module_generate_hash my $word = shift; my $salt = shift || get_random_mojolicious_salt (); - ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQWlpaWlpaWlpaWlp(...)aWlpaWlpaWlpaWlpaWlpaWlpaWlp my ($name, $value) = split('=', $salt); - ## mojolicious=eyJleHBpcmVzIjoxMTEyNDcwNjIwLCJuZXdfZmxhc2giOnsibWVzc2FnZSI6IkhlbGxvIHRoZXJlLiJ9LCJ1c2VyIjoiYWxpY2UifQWlpaWlpaWlpaWlp(...)aWlpaWlpaWlpaWlpaWlpaWlpaWlp--1bf346f55562ac2a08d1b86a28e87bf5aad357d7a92e816567271f5b420b93c1 my $hash = get_signed_cookie ($name, $value, $word); - return $hash; } @@ -43,7 +40,7 @@ sub module_verify_hash my ($padded_cookie, $signature) = @data; - my $unpadded_cookie = $padded_cookie =~ s/\}\KZ*$//r; + my $unpadded_cookie = $padded_cookie =~ s/Z*$//; my ($cookie_name, $cookie_value) = split('=', $unpadded_cookie); @@ -58,11 +55,6 @@ sub module_verify_hash sub get_random_mojolicious_salt { - sub add_mojolicious_padding - { - return $_[0] . 'Z' x (1025 - length $_[0]); - } - my $random_key = random_number (1, 100000000); my $random_val = random_number (1, 100000000); @@ -72,8 +64,9 @@ sub get_random_mojolicious_salt }; my $payload_json = encode_json ($payload); - my $payload_padded = add_mojolicious_padding ($payload_json); - my $payload_base64 = encode_base64url ($payload_padded, ""); + my $payload_padded = $payload_json . 'Z' x (1025 - length $payload_json); + my $payload_base64 = encode_base64 ($payload_padded, ""); + $payload_base64 =~ y/=/-/; return "mojolicious=$payload_base64"; } @@ -82,7 +75,6 @@ sub get_signed_cookie { my ($name, $value, $secret) = @_; my $sum = Digest::SHA::hmac_sha256_hex("$name=$value", $secret); - return "$name=$value--$sum" } From 3e10c363dedbe3d1630c607e79287a2df919b12b Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 26 Nov 2024 00:08:26 +0000 Subject: [PATCH 069/357] Check additional blocks for safety --- OpenCL/m26610-pure.cl | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OpenCL/m26610-pure.cl b/OpenCL/m26610-pure.cl index abd476395..cb02840f6 100644 --- a/OpenCL/m26610-pure.cl +++ b/OpenCL/m26610-pure.cl @@ -368,7 +368,7 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh AES_GCM_decrypt (key, J0, ct, 32, pt, s_te0, s_te1, s_te2, s_te3, s_te4); - const int correct = is_valid_printable_32 (pt[0]) + int correct = is_valid_printable_32 (pt[0]) + is_valid_printable_32 (pt[1]) + is_valid_printable_32 (pt[2]) + is_valid_printable_32 (pt[3]) @@ -379,6 +379,37 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh if (correct != 8) return; + u32 ct2[8]; + + ct2[0] = pbkdf2_sha256_aes_gcm->ct_buf[8]; // third block of ciphertext + ct2[1] = pbkdf2_sha256_aes_gcm->ct_buf[9]; + ct2[2] = pbkdf2_sha256_aes_gcm->ct_buf[10]; + ct2[3] = pbkdf2_sha256_aes_gcm->ct_buf[11]; + ct2[4] = pbkdf2_sha256_aes_gcm->ct_buf[12]; // fourth block of ciphertext + ct2[5] = pbkdf2_sha256_aes_gcm->ct_buf[13]; + ct2[6] = pbkdf2_sha256_aes_gcm->ct_buf[14]; + ct2[7] = pbkdf2_sha256_aes_gcm->ct_buf[15]; + + // Only a single increment as the previous AES_GCM_DECRYPT already does one for us + J0[3]++; + + u32 pt2[8] = { 0 }; + + AES_GCM_decrypt (key, J0, ct2, 32, pt2, s_te0, s_te1, s_te2, s_te3, s_te4); + + correct = is_valid_printable_32 (pt2[0]) + + is_valid_printable_32 (pt2[1]) + + is_valid_printable_32 (pt2[2]) + + is_valid_printable_32 (pt2[3]) + + is_valid_printable_32 (pt2[4]) + + is_valid_printable_32 (pt2[5]) + + is_valid_printable_32 (pt2[6]) + + is_valid_printable_32 (pt2[7]); + + // We need to check a second and third block to avoid extremely rare false-positives. See: + // https://github.com/hashcat/hashcat/issues/4121 + if (correct != 8) return; + /* const int pt_len = 28; // not using 32 byte but 28 because our UTF8 allows up to 4 byte per character and since we decrypt 32 byte // only we can't guarantee it is not in the middle of a UTF8 byte stream at that point From dcfa17100ea13b27f5bd18c8ed2bf1b99ce276e4 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 26 Nov 2024 00:09:53 +0000 Subject: [PATCH 070/357] Minor typo fix --- OpenCL/m26610-pure.cl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenCL/m26610-pure.cl b/OpenCL/m26610-pure.cl index cb02840f6..9815eb8dd 100644 --- a/OpenCL/m26610-pure.cl +++ b/OpenCL/m26610-pure.cl @@ -406,7 +406,7 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh + is_valid_printable_32 (pt2[6]) + is_valid_printable_32 (pt2[7]); - // We need to check a second and third block to avoid extremely rare false-positives. See: + // We need to check a third and fourth block to avoid extremely rare false-positives. See: // https://github.com/hashcat/hashcat/issues/4121 if (correct != 8) return; From 5b26392adb7d26f67961bfd8856d788b1287b2c6 Mon Sep 17 00:00:00 2001 From: Code Curiously <67614186+codecuriously@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:20:26 +0000 Subject: [PATCH 071/357] Fix RAM usage bug for Linux Apple Silicon #4125 --- src/backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..088cb40cb 100644 --- a/src/backend.c +++ b/src/backend.c @@ -8035,7 +8035,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->device_available_mem = device_param->device_global_mem - MAX_ALLOC_CHECKS_SIZE; - if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && ((device_param->opencl_platform_vendor_id != VENDOR_ID_INTEL_SDK) || (device_param->device_host_unified_memory == 0))) + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && + (((device_param->opencl_platform_vendor_id != VENDOR_ID_INTEL_SDK) && (device_param->opencl_platform_vendor_id != VENDOR_ID_GENERIC)) || (device_param->device_host_unified_memory == 0))) { // OK, so the problem here is the following: // There's just CL_DEVICE_GLOBAL_MEM_SIZE to ask OpenCL about the total memory on the device, From 731aad106deb08af70b14a5f7d0ae42ef1adb8b8 Mon Sep 17 00:00:00 2001 From: Nripesh Niketan Date: Wed, 4 Dec 2024 17:45:51 +0000 Subject: [PATCH 072/357] Updated workflow as requested --- .github/workflows/build.yml | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4dbbda26f..aace6f77b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,32 +45,24 @@ jobs: strategy: fail-fast: false matrix: + shared: [0, 1] include: - os: ubuntu-latest - os_name: linux - shared: 0 - - os: ubuntu-latest - os_name: linux - shared: 1 + os_name: Linux + os_name_lowercase: linux - os: macos-latest - os_name: macos - shared: 0 - - os: macos-latest - os_name: macos - shared: 1 + os_name: MacOS + os_name_lowercase: macos - os: windows-latest - os_name: windows - shared: 0 - - os: windows-latest - os_name: windows - shared: 1 + os_name: Windows + os_name_lowercase: windows name: Build ${{ matrix.os_name }} (${{ matrix.shared == 0 && 'Static' || 'Shared' }}) runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Install dependencies (Windows only) - if: matrix.os_name == 'windows' + if: matrix.os_name_lowercase == 'windows' uses: msys2/setup-msys2@v2 with: update: true @@ -82,14 +74,14 @@ jobs: make - name: Build - if: matrix.os_name == 'windows' + if: matrix.os_name_lowercase == 'windows' shell: msys2 {0} env: SHARED: ${{ matrix.shared }} run: make - name: Build - if: matrix.os_name != 'windows' + if: matrix.os_name_lowercase != 'windows' env: SHARED: ${{ matrix.shared }} run: make @@ -97,5 +89,5 @@ jobs: - name: Generate artifacts uses: actions/upload-artifact@v4 with: - name: hashcat-${{ matrix.os_name }}-${{ matrix.shared == 0 && 'static' || 'shared' }} + name: hashcat-${{ matrix.os_name_lowercase }}-${{ matrix.shared == 0 && 'static' || 'shared' }} path: ${{ env.include_paths }} From 475512a80e81b3c83ffe912a12e342424fd6f81c Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Fri, 6 Dec 2024 05:43:10 +0000 Subject: [PATCH 073/357] Add [b] [c] and [f] functionality in pause state Add the ability to [b]ypass, [c]heckpoint and [f]inish an attack while paused. I'm not too sure why it was limited to only [r]unning states but have not found any bugs in testing --- src/status.c | 16 ++++++++++++++-- src/thread.c | 6 ------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/status.c b/src/status.c index 4e964fd3b..be64a0743 100644 --- a/src/status.c +++ b/src/status.c @@ -35,6 +35,8 @@ static const char *const ST_0013 = "Error"; static const char *const ST_0014 = "Aborted (Finish)"; static const char *const ST_0015 = "Running (Quit after attack requested)"; static const char *const ST_0016 = "Autodetect"; +static const char *const ST_0017 = "Paused (Checkpoint Quit requested)"; +static const char *const ST_0018 = "Paused (Quit after attack requested)"; static const char *const ST_9999 = "Unknown! Bug!"; static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; @@ -262,8 +264,6 @@ const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) const int devices_status = status_ctx->devices_status; - // special case: running but checkpoint quit requested - if (devices_status == STATUS_RUNNING) { if (status_ctx->checkpoint_shutdown == true) @@ -276,6 +276,18 @@ const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) return ST_0015; } } + else if (devices_status == STATUS_PAUSED) + { + if (status_ctx->checkpoint_shutdown == true) + { + return ST_0017; + } + + if (status_ctx->finish_shutdown == true) + { + return ST_0018; + } + } switch (devices_status) { diff --git a/src/thread.c b/src/thread.c index c33d25b8d..bfad64c38 100644 --- a/src/thread.c +++ b/src/thread.c @@ -214,8 +214,6 @@ int bypass (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status != STATUS_RUNNING) return -1; - status_ctx->devices_status = STATUS_BYPASS; status_ctx->run_main_level1 = true; @@ -262,8 +260,6 @@ int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status != STATUS_RUNNING) return -1; - // this feature only makes sense if --restore-disable was not specified restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; @@ -305,8 +301,6 @@ int finish_after_attack (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status != STATUS_RUNNING) return -1; - // Enable or Disable if (status_ctx->finish_shutdown == false) From 3617df2f2516688617c6267f53fb8d09c491cdf3 Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 10 Dec 2024 07:57:41 +0000 Subject: [PATCH 074/357] Gracefully handle corrupt .gz archives --- src/combinator.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ src/filehandling.c | 11 +++++++++ src/straight.c | 35 ++++++++++++++++++++++++++++ src/wordlist.c | 21 +++++++++++++---- 4 files changed, 121 insertions(+), 4 deletions(-) diff --git a/src/combinator.c b/src/combinator.c index 654ada03f..5ff52d8ac 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -96,6 +96,16 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc1 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile1); + + hc_fclose (&fp1); + hc_fclose (&fp2); + + return -1; + } + if (words1_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); @@ -122,6 +132,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc2 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile2); + + return -1; + } + if (words2_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); @@ -199,6 +216,16 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc1 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile1); + + hc_fclose (&fp1); + hc_fclose (&fp2); + + return -1; + } + if (words1_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); @@ -225,6 +252,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc2 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile2); + + return -1; + } + if (words2_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); @@ -330,6 +364,16 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc1 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile1); + + hc_fclose (&fp1); + hc_fclose (&fp2); + + return -1; + } + if (words1_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); @@ -356,6 +400,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc2 == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile2); + + return -1; + } + if (words2_cnt == 0) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); @@ -412,6 +463,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", dictfile); + + return -1; + } + combinator_ctx->combs_cnt = words_cnt; combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; } diff --git a/src/filehandling.c b/src/filehandling.c index 9a2d0ea39..712ccdb66 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -410,6 +410,17 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) else if (fp->gfp) { n = gzfread (ptr, size, nmemb, fp->gfp); + + // Double check to make sure that it successfully read 0 bytes instead of erroring + if (n == 0) + { + int errnum; + gzerror (fp->gfp, &errnum); + if (errnum != Z_OK) + { + return (size_t) -1; + } + } } else if (fp->ufp) { diff --git a/src/straight.c b/src/straight.c index 36d3a8eb8..7a75a7d66 100644 --- a/src/straight.c +++ b/src/straight.c @@ -91,6 +91,13 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", straight_ctx->dict); + + return -1; + } + if (status_ctx->words_cnt == 0) { logfile_sub_msg ("STOP"); @@ -125,6 +132,13 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", combinator_ctx->dict1); + + return -1; + } } else if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT) { @@ -147,6 +161,13 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", combinator_ctx->dict2); + + return -1; + } } if (status_ctx->words_cnt == 0) @@ -194,6 +215,13 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", straight_ctx->dict); + + return -1; + } + if (status_ctx->words_cnt == 0) { logfile_sub_msg ("STOP"); @@ -234,6 +262,13 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + if (rc == -2) + { + event_log_error (hashcat_ctx, "Error reading wordlist: %s", straight_ctx->dict); + + return -1; + } + if ((status_ctx->words_cnt / straight_ctx->kernel_rules_cnt) != hashes->salts_cnt) { event_log_error (hashcat_ctx, "Number of words in wordlist '%s' is not in sync with number of unique salts", straight_ctx->dict); diff --git a/src/wordlist.c b/src/wordlist.c index 1776b4885..0511381b6 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -60,6 +60,11 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp) wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fp); + if (wl_data->cnt == (size_t) -1) + { + return -1; + } + wl_data->buf[wl_data->cnt] = 0; if (wl_data->cnt == 0) return 0; @@ -339,7 +344,12 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, char **out_buf, u32 return; } - load_segment (hashcat_ctx, fp); + if (load_segment (hashcat_ctx, fp) == -1) + { + event_log_error (hashcat_ctx, "Error reading file!\n"); + + return; + } get_next_word (hashcat_ctx, fp, out_buf, out_len); } @@ -559,9 +569,12 @@ int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const char *dictfile, u u64 cnt2 = 0; while (!hc_feof (fp)) - { - load_segment (hashcat_ctx, fp); - + { + if (load_segment (hashcat_ctx, fp) == -1) + { + return -2; + } + comp += wl_data->cnt; u64 i = 0; From 4395d1467812918a8b0ec0019a7b154d9a47dbfa Mon Sep 17 00:00:00 2001 From: Romke van Dijk Date: Sun, 22 Dec 2024 19:27:19 +0100 Subject: [PATCH 075/357] Adding keybag2hashcat --- tools/keybag2hashcat.py | 171 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 tools/keybag2hashcat.py diff --git a/tools/keybag2hashcat.py b/tools/keybag2hashcat.py new file mode 100644 index 000000000..83da25c5e --- /dev/null +++ b/tools/keybag2hashcat.py @@ -0,0 +1,171 @@ +import argparse +import logging +import sys + +__VERSION__ = '1.0.0' + +# Set up logging +logger = logging.getLogger("keybag_logger") +handler = logging.StreamHandler() +formatter = logging.Formatter('%(message)s') +handler.setFormatter(formatter) +logger.addHandler(handler) + +class Keybag: + def __init__(self, file_obj): + self.size = 0 + self.uuid = '' + self.version = 0 + self.type = 0 + self.hmackey = '' + self.wrap = 0 + self.salt = '' + self.iterations = 0 + + + self._read_header(file_obj) + self.class_keys = self._read_class_keys(file_obj) + + def _read_header(self, file_obj): + while True: + tag = file_obj.read(4).decode('ascii') + if tag == 'DATA': # DATA + self.size = int.from_bytes(file_obj.read(4), byteorder='big') + else: + length = int.from_bytes(file_obj.read(4), byteorder='big') + data = file_obj.read(length) + + if tag == 'VERS': # VERS + self.version = int.from_bytes(data, byteorder='big') + elif tag == 'TYPE': + self.type = int.from_bytes(data, byteorder='big') + elif tag == 'UUID': + if not self.uuid: + self.uuid = data.hex() + else: + file_obj.seek(-length - 8, 1) + break + elif tag == 'HMCK': + self.hmackey = data.hex() + elif tag == 'WRAP': + self.wrap = int.from_bytes(data, byteorder='big') + elif tag == 'SALT': + self.salt = data.hex() + elif tag == 'ITER': + self.iterations = int.from_bytes(data, byteorder='big') + + def _read_class_keys(self, file_obj): + class_keys = {} + + for x in range(0, 10): + stop = False + while stop != True: + tag = file_obj.read(4).decode('ascii') + length = int.from_bytes(file_obj.read(4), byteorder='big') + data = file_obj.read(length) + # new class key + if tag == 'UUID': + if class_keys.get(x): + if class_keys[x].get('UUID'): + file_obj.seek(-length - 8, 1) + stop = True + else: + class_keys[x] = {} + else: + class_keys[x] = {} + if tag == 'WRAP' or tag == 'CLAS' or tag == 'KTYP': + class_keys[x][tag] = int.from_bytes(data, byteorder='big') + else: + class_keys[x][tag] = data.hex() + if file_obj.tell() > self.size: + stop = True + return class_keys + + + def print_keybag(self): + logger.debug(f'SIZE: {self.size}') + logger.debug(f'VERSION: {self.version}') + logger.debug(f'TYPE: {self.type}') + logger.debug(f'UUID: {self.uuid}') + logger.debug(f'HMACKEY: {self.hmackey}') + logger.debug(f'SALT: {self.salt}') + logger.debug(f'ITERATIONS: {self.iterations}') + for x, class_key in self.class_keys.items(): + logger.debug(f'{x}:') + for key, value in class_key.items(): + logger.debug(f' {key}: {value}') + +def main(): + # Create the argument parser + parser = argparse.ArgumentParser(description="Process a keybag file with a specified UID.") + + # Add the UID argument + parser.add_argument( + '--uid', + type=str, + required=True, + help="Specify the device UID." + ) + + # Add the keybag file argument + parser.add_argument( + 'keybag', + type=str, + help="Path to the keybag file." + ) + + # Add the debug flag + parser.add_argument( + '--debug', + action='store_true', + help="Enable debug logging." + ) + + # Parse the arguments + args = parser.parse_args() + + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.WARNING) + + # Access the arguments + uid = args.uid[0:32] + keybag_path = args.keybag + + logger.debug(f'keybag2hashcat - version {__VERSION__}') + + with open(keybag_path, 'br') as keybag_file: + kb = Keybag(keybag_file) + kb.print_keybag() + if not kb.version: + logger.error('Unable to detect version of keybag, exiting.') + sys.exit(1) + if not kb.salt: + logger.error('Unable to detect salt, exiting.') + sys.exit(1) + if not kb.iterations: + logger.error('Unable to detect iterations, exiting.') + sys.exit(1) + if not kb.version in [3, 4]: + logger.error(f'This script has not been tested with version {kb.version}.') + sys.exit(1) + if not kb.class_keys: + logger.error(f'Unable to parse class keys, exiting.') + sys.exit(1) + classkey1 = 0 + for x, class_key in kb.class_keys.items(): + if class_key.get('WRAP') == 3: + class_type = class_key.get('CLAS') + if class_type == 1 or class_type == 33: + classkey1 = class_key.get('WPKY') + + if not classkey1: + logger.error(f'Unable to find a classkey of class NSFileProtectionComplete.') + logger.error(f'You could try to get another class key, make sure it is ktyp 0 and wrap 3.') + exit(1) + print(f'$uido${uid}${kb.salt}${kb.iterations}${classkey1}') + + +if __name__ == "__main__": + main() From 9e4e7c1c60c6c6a968e2b05fd3da61f227491866 Mon Sep 17 00:00:00 2001 From: Borys Kabakov Date: Tue, 24 Dec 2024 16:53:31 +0200 Subject: [PATCH 076/357] Colorize cracked hashes for non windows Make cracked hashes cyan in stdout, if program compiled on non _WIN os partially solves: - https://github.com/hashcat/hashcat/issues/3158 - https://github.com/hashcat/hashcat/issues/3515 --- src/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.c b/src/main.c index 085ce38b4..fffaa3ef1 100644 --- a/src/main.c +++ b/src/main.c @@ -352,8 +352,16 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx); } + #if defined (_WIN) fwrite (buf, len, 1, stdout); fwrite (EOL, strlen (EOL), 1, stdout); + #else + // make cracked hash output in cyan + fputs("\033[36m", stdout); + fwrite (buf, len, 1, stdout); + fwrite("\033[0m", 4, 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); + #endif if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { From 29259ff97315ef0899cdf52bc8ec3c16b124f67b Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Tue, 7 Jan 2025 02:43:31 +0000 Subject: [PATCH 077/357] Improve salt length reporting in hashconfig Increase the amount of hash modes that will have their salt min/max length showed by including SALT_TYPE_GENERIC --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 085ce38b4..9158698a9 100644 --- a/src/main.c +++ b/src/main.c @@ -996,7 +996,7 @@ static void main_hashconfig_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE if (hashconfig->is_salted == true) { - if (hashconfig->opti_type & OPTI_TYPE_RAW_HASH) + if (hashconfig->opti_type & OPTI_TYPE_RAW_HASH || hashconfig->salt_type & SALT_TYPE_GENERIC) { event_log_info (hashcat_ctx, "Minimum salt length supported by kernel: %u", hashconfig->salt_min); event_log_info (hashcat_ctx, "Maximum salt length supported by kernel: %u", hashconfig->salt_max); From c1459cd2d6bbdd9efc9ee7c400a3eacb8365cac9 Mon Sep 17 00:00:00 2001 From: banderlog Date: Fri, 17 Jan 2025 11:54:39 +0200 Subject: [PATCH 078/357] color cracked hash as an option --- include/types.h | 9 +++++++++ src/main.c | 11 +++-------- src/usage.c | 3 +++ src/user_options.c | 9 +++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/types.h b/include/types.h index e6ea946f9..e193d77e6 100644 --- a/include/types.h +++ b/include/types.h @@ -636,6 +636,9 @@ typedef enum user_options_defaults BRAIN_SERVER = false, BRAIN_SESSION = 0, #endif + #if !defined(_WIN) + COLOR = false, + #endif DEBUG_MODE = 0, DEPRECATED_CHECK = true, DYNAMIC_X = false, @@ -750,6 +753,9 @@ typedef enum user_options_map IDX_BRAIN_SESSION = 0xff0f, IDX_BRAIN_SESSION_WHITELIST = 0xff10, #endif + #if !defined(_WIN) + IDX_COLOR = 0xff56, + #endif IDX_CPU_AFFINITY = 0xff11, IDX_CUSTOM_CHARSET_1 = '1', IDX_CUSTOM_CHARSET_2 = '2', @@ -2340,6 +2346,9 @@ typedef struct user_options bool brain_client; bool brain_server; #endif + #if !defined(_WIN) + bool color; + #endif bool force; bool deprecated_check; bool dynamic_x; diff --git a/src/main.c b/src/main.c index fffaa3ef1..d6c213093 100644 --- a/src/main.c +++ b/src/main.c @@ -352,16 +352,11 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx); } - #if defined (_WIN) + // cyan color for cracked hashes + if (user_options->color == true) fputs("\033[0;36m", stdout); fwrite (buf, len, 1, stdout); + if (user_options->color == true) fwrite("\033[0m", 4, 1, stdout); fwrite (EOL, strlen (EOL), 1, stdout); - #else - // make cracked hash output in cyan - fputs("\033[36m", stdout); - fwrite (buf, len, 1, stdout); - fwrite("\033[0m", 4, 1, stdout); - fwrite (EOL, strlen (EOL), 1, stdout); - #endif if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { diff --git a/src/usage.c b/src/usage.c index 7cbf22348..7864086ae 100644 --- a/src/usage.c +++ b/src/usage.c @@ -146,6 +146,9 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --brain-session | Hex | Overrides automatically calculated brain session | --brain-session=0x2ae611db", " --brain-session-whitelist | Hex | Allow given sessions only, separated with commas | --brain-session-whitelist=0x2ae611db", #endif + #if !defined(_WIN) + " --color | | Enables color output for cracked hashes |", + #endif "", NULL }; diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..4d5676226 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -154,6 +154,9 @@ static const struct option long_options[] = {"brain-session", required_argument, NULL, IDX_BRAIN_SESSION}, {"brain-session-whitelist", required_argument, NULL, IDX_BRAIN_SESSION_WHITELIST}, #endif + #if !defined(_WIN) + {"color", no_argument, NULL, IDX_COLOR}, + #endif {NULL, 0, NULL, 0 } }; @@ -198,6 +201,9 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->brain_session = BRAIN_SESSION; user_options->brain_session_whitelist = NULL; #endif + #if !defined(_WIN) + user_options->color = COLOR; + #endif user_options->cpu_affinity = NULL; user_options->custom_charset_1 = NULL; user_options->custom_charset_2 = NULL; @@ -548,6 +554,9 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BRAIN_SESSION: user_options->brain_session = hc_strtoul (optarg, NULL, 16); break; case IDX_BRAIN_SESSION_WHITELIST: user_options->brain_session_whitelist = optarg; break; #endif + #if !defined(_WIN) + case IDX_COLOR: user_options->color = true; break; + #endif } } From 4e6077ad5c11f66a44f54c370fe106b396920279 Mon Sep 17 00:00:00 2001 From: banderlog Date: Sat, 18 Jan 2025 03:26:25 +0200 Subject: [PATCH 079/357] bugfix: prevent crashing when building on win --- src/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index d6c213093..bdc71563d 100644 --- a/src/main.c +++ b/src/main.c @@ -352,11 +352,16 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx); } - // cyan color for cracked hashes + #if defined (_WIN) + fwrite (buf, len, 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); + #else + // color option for cracked hashes on non win if (user_options->color == true) fputs("\033[0;36m", stdout); fwrite (buf, len, 1, stdout); if (user_options->color == true) fwrite("\033[0m", 4, 1, stdout); fwrite (EOL, strlen (EOL), 1, stdout); + #endif if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { From ab77b8f5bafa86460d1a0eba2f28831ac19cd833 Mon Sep 17 00:00:00 2001 From: sc00bz Date: Mon, 3 Feb 2025 10:35:05 -0600 Subject: [PATCH 080/357] Added support for multiple TOTP codes --- OpenCL/m18100_a0-pure.cl | 277 +++++++++++++------ OpenCL/m18100_a1-pure.cl | 441 +++++++++++++++++++++++-------- OpenCL/m18100_a3-pure.cl | 529 +++++++++++++++++++++++-------------- src/modules/module_18100.c | 152 +++++++---- 4 files changed, 953 insertions(+), 446 deletions(-) diff --git a/OpenCL/m18100_a0-pure.cl b/OpenCL/m18100_a0-pure.cl index 9c8f047a9..396d896bc 100644 --- a/OpenCL/m18100_a0-pure.cl +++ b/OpenCL/m18100_a0-pure.cl @@ -16,6 +16,47 @@ #include M2S(INCLUDE_PATH/inc_hash_sha1.cl) #endif +DECLSPEC void _totp_calculate (PRIVATE_AS u32 *code, PRIVATE_AS const u32 *w, const u32 pw_len, PRIVATE_AS const u32 *s, const u32 salt_len) +{ + sha1_hmac_ctx_t ctx; + + sha1_hmac_init_swap (&ctx, w, pw_len); + + sha1_hmac_update (&ctx, s, salt_len); + + sha1_hmac_final (&ctx); + + // initialize a buffer for the otp code + u32 otp_code = 0; + + // grab 4 consecutive bytes of the hash, starting at offset + switch (ctx.opad.h[4] & 15) + { + case 0: otp_code = ctx.opad.h[0]; break; + case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; + case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; + case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; + case 4: otp_code = ctx.opad.h[1]; break; + case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; + case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; + case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; + case 8: otp_code = ctx.opad.h[2]; break; + case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; + case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; + case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; + case 12: otp_code = ctx.opad.h[3]; break; + case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; + case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; + case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + } + + // take only the lower 31 bits + otp_code &= 0x7fffffff; + + // we want to generate only 6 digits of code + *code = otp_code % 1000000; +} + KERNEL_FQ void m18100_mxx (KERN_ATTR_RULES ()) { /** @@ -33,63 +74,85 @@ KERNEL_FQ void m18100_mxx (KERN_ATTR_RULES ()) COPY_PW (pws[gid]); - const u32 salt_len = 8; + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; u32 s[64] = { 0 }; - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + for (u32 i = 0; i < count; i += 1) { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); } /** * loop */ - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + if (count == 1) { - pw_t tmp = PASTE_PW; - - tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - - sha1_hmac_ctx_t ctx; - - sha1_hmac_init_swap (&ctx, tmp.i, tmp.pw_len); - - sha1_hmac_update (&ctx, s, salt_len); - - sha1_hmac_final (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s, 8); + + COMPARE_M_SCALAR (otp_code0, 0, 0, 0); } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; - // take only the lower 31 bits - otp_code &= 0x7fffffff; - // we want to generate only 6 digits of code - otp_code %= 1000000; + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - COMPARE_M_SCALAR (otp_code, 0, 0, 0); + u32 otp_code0, otp_code1; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s + 0, 8); + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, 0, 0); + } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s + 0, 8); + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + _totp_calculate (&otp_code2, tmp.i, tmp.pw_len, s + 32, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, otp_code2, 0); + } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s + 0, 8); + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + _totp_calculate (&otp_code2, tmp.i, tmp.pw_len, s + 32, 8); + _totp_calculate (&otp_code3, tmp.i, tmp.pw_len, s + 48, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, otp_code2, otp_code3); + } } } @@ -122,62 +185,108 @@ KERNEL_FQ void m18100_sxx (KERN_ATTR_RULES ()) COPY_PW (pws[gid]); - const u32 salt_len = 8; + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; u32 s[64] = { 0 }; - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + for (u32 i = 0; i < count; i += 1) { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); } /** * loop */ - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + if (count == 1) { - pw_t tmp = PASTE_PW; - - tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - - sha1_hmac_ctx_t ctx; - - sha1_hmac_init_swap (&ctx, tmp.i, tmp.pw_len); - - sha1_hmac_update (&ctx, s, salt_len); - - sha1_hmac_final (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s, 8); + + COMPARE_S_SCALAR (otp_code0, 0, 0, 0); } + } + else if (count == 2) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; - // take only the lower 31 bits - otp_code &= 0x7fffffff; - // we want to generate only 6 digits of code - otp_code %= 1000000; + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); - COMPARE_S_SCALAR (otp_code, 0, 0, 0); + u32 otp_code0, otp_code1; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, 0, 0); + } + } + } + else if (count == 3) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + + if (otp_code1 == search[1]) + { + _totp_calculate (&otp_code2, tmp.i, tmp.pw_len, s + 32, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, otp_code2, 0); + } + } + } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, tmp.i, tmp.pw_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, tmp.i, tmp.pw_len, s + 16, 8); + + if (otp_code1 == search[1]) + { + _totp_calculate (&otp_code2, tmp.i, tmp.pw_len, s + 32, 8); + + if (otp_code2 == search[2]) + { + _totp_calculate (&otp_code3, tmp.i, tmp.pw_len, s + 48, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, otp_code2, otp_code3); + } + } + } + } } } diff --git a/OpenCL/m18100_a1-pure.cl b/OpenCL/m18100_a1-pure.cl index a596894ca..4eefd1fdc 100644 --- a/OpenCL/m18100_a1-pure.cl +++ b/OpenCL/m18100_a1-pure.cl @@ -14,6 +14,47 @@ #include M2S(INCLUDE_PATH/inc_hash_sha1.cl) #endif +DECLSPEC void _totp_calculate (PRIVATE_AS u32 *code, PRIVATE_AS const u32 *w, const u32 pw_len, PRIVATE_AS const u32 *s, const u32 salt_len) +{ + sha1_hmac_ctx_t ctx; + + sha1_hmac_init (&ctx, w, pw_len); + + sha1_hmac_update (&ctx, s, salt_len); + + sha1_hmac_final (&ctx); + + // initialize a buffer for the otp code + u32 otp_code = 0; + + // grab 4 consecutive bytes of the hash, starting at offset + switch (ctx.opad.h[4] & 15) + { + case 0: otp_code = ctx.opad.h[0]; break; + case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; + case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; + case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; + case 4: otp_code = ctx.opad.h[1]; break; + case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; + case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; + case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; + case 8: otp_code = ctx.opad.h[2]; break; + case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; + case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; + case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; + case 12: otp_code = ctx.opad.h[3]; break; + case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; + case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; + case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + } + + // take only the lower 31 bits + otp_code &= 0x7fffffff; + + // we want to generate only 6 digits of code + *code = otp_code % 1000000; +} + KERNEL_FQ void m18100_mxx (KERN_ATTR_BASIC ()) { /** @@ -38,81 +79,157 @@ KERNEL_FQ void m18100_mxx (KERN_ATTR_BASIC ()) w[idx] = hc_swap32_S (pws[gid].i[idx]); } - const u32 salt_len = 8; + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; u32 s[64] = { 0 }; - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + for (u32 i = 0; i < count; i += 1) { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); } /** * loop */ - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + if (count == 1) { - const u32 comb_len = combs_buf[il_pos].pw_len; - - u32 c[64]; - - #ifdef _unroll - #pragma unroll - #endif - for (int idx = 0; idx < 64; idx++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s, 8); + + COMPARE_M_SCALAR (otp_code0, 0, 0, 0); } - - switch_buffer_by_offset_1x64_be_S (c, pw_len); - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 64; i++) + } + else if (count == 2) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - c[i] |= w[i]; + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s + 0, 8); + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, 0, 0); } - - sha1_hmac_ctx_t ctx; - - sha1_hmac_init (&ctx, c, pw_len + comb_len); - - sha1_hmac_update (&ctx, s, salt_len); - - sha1_hmac_final (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) + } + else if (count == 3) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s + 0, 8); + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + _totp_calculate (&otp_code2, c, pw_len + comb_len, s + 32, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, otp_code2, 0); } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + const u32 comb_len = combs_buf[il_pos].pw_len; - // take only the lower 31 bits - otp_code &= 0x7fffffff; - // we want to generate only 6 digits of code - otp_code %= 1000000; + u32 c[64]; - COMPARE_M_SCALAR (otp_code, 0, 0, 0); + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s + 0, 8); + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + _totp_calculate (&otp_code2, c, pw_len + comb_len, s + 32, 8); + _totp_calculate (&otp_code3, c, pw_len + comb_len, s + 48, 8); + + COMPARE_M_SCALAR (otp_code0, otp_code1, otp_code2, otp_code3); + } } } @@ -152,80 +269,180 @@ KERNEL_FQ void m18100_sxx (KERN_ATTR_BASIC ()) w[idx] = hc_swap32_S (pws[gid].i[idx]); } - const u32 salt_len = 8; + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; u32 s[64] = { 0 }; - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + for (u32 i = 0; i < count; i += 1) { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); } /** * loop */ - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + if (count == 1) { - const u32 comb_len = combs_buf[il_pos].pw_len; - - u32 c[64]; - - #ifdef _unroll - #pragma unroll - #endif - for (int idx = 0; idx < 64; idx++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s, 8); + + COMPARE_S_SCALAR (otp_code0, 0, 0, 0); } - - switch_buffer_by_offset_1x64_be_S (c, pw_len); - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 64; i++) + } + else if (count == 2) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - c[i] |= w[i]; + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, 0, 0); + } } - - sha1_hmac_ctx_t ctx; - - sha1_hmac_init (&ctx, c, pw_len + comb_len); - - sha1_hmac_update (&ctx, s, salt_len); - - sha1_hmac_final (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) + } + else if (count == 3) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + + if (otp_code1 == search[1]) + { + _totp_calculate (&otp_code2, c, pw_len + comb_len, s + 32, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, otp_code2, 0); + } + } } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + const u32 comb_len = combs_buf[il_pos].pw_len; - // take only the lower 31 bits - otp_code &= 0x7fffffff; - // we want to generate only 6 digits of code - otp_code %= 1000000; + u32 c[64]; - COMPARE_S_SCALAR (otp_code, 0, 0, 0); + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = hc_swap32_S (combs_buf[il_pos].i[idx]); + } + + switch_buffer_by_offset_1x64_be_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + u32 otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, c, pw_len + comb_len, s, 8); + + if (otp_code0 == search[0]) + { + _totp_calculate (&otp_code1, c, pw_len + comb_len, s + 16, 8); + + if (otp_code1 == search[1]) + { + _totp_calculate (&otp_code2, c, pw_len + comb_len, s + 32, 8); + + if (otp_code2 == search[2]) + { + _totp_calculate (&otp_code3, c, pw_len + comb_len, s + 48, 8); + + COMPARE_S_SCALAR (otp_code0, otp_code1, otp_code2, otp_code3); + } + } + } + } } } diff --git a/OpenCL/m18100_a3-pure.cl b/OpenCL/m18100_a3-pure.cl index 70235ce95..2dd68ffdf 100644 --- a/OpenCL/m18100_a3-pure.cl +++ b/OpenCL/m18100_a3-pure.cl @@ -1,205 +1,324 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -//#define NEW_SIMD_CODE - -#ifdef KERNEL_STATIC -#include M2S(INCLUDE_PATH/inc_vendor.h) -#include M2S(INCLUDE_PATH/inc_types.h) -#include M2S(INCLUDE_PATH/inc_platform.cl) -#include M2S(INCLUDE_PATH/inc_common.cl) -#include M2S(INCLUDE_PATH/inc_simd.cl) -#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) -#endif - -KERNEL_FQ void m18100_mxx (KERN_ATTR_VECTOR ()) -{ - /** - * modifier - */ - - const u64 lid = get_local_id (0); - const u64 gid = get_global_id (0); - - if (gid >= GID_CNT) return; - - /** - * base - */ - - const u32 pw_len = pws[gid].pw_len; - - u32x w[64] = { 0 }; - - for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) - { - w[idx] = pws[gid].i[idx]; - } - - const u32 salt_len = 8; - - u32x s[64] = { 0 }; - - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) - { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); - } - - /** - * loop - */ - - u32x w0l = w[0]; - - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) - { - const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; - - const u32x w0 = w0l | w0r; - - w[0] = w0; - - sha1_hmac_ctx_vector_t ctx; - - sha1_hmac_init_vector (&ctx, w, pw_len); - - sha1_hmac_update_vector (&ctx, s, salt_len); - - sha1_hmac_final_vector (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) - { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; - } - - // take only the lower 31 bits - otp_code &= 0x7fffffff; - - // we want to generate only 6 digits of code - otp_code %= 1000000; - - COMPARE_M_SIMD (otp_code, 0, 0, 0); - } -} - -KERNEL_FQ void m18100_sxx (KERN_ATTR_VECTOR ()) -{ - /** - * modifier - */ - - const u64 lid = get_local_id (0); - const u64 gid = get_global_id (0); - - if (gid >= GID_CNT) return; - - /** - * digest - */ - - const u32 search[4] = - { - digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], - digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], - digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], - digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] - }; - - /** - * base - */ - - const u32 pw_len = pws[gid].pw_len; - - u32x w[64] = { 0 }; - - for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) - { - w[idx] = pws[gid].i[idx]; - } - - const u32 salt_len = 8; - - u32x s[64] = { 0 }; - - for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) - { - s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); - } - - /** - * loop - */ - - u32x w0l = w[0]; - - for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) - { - const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; - - const u32x w0 = w0l | w0r; - - w[0] = w0; - - sha1_hmac_ctx_vector_t ctx; - - sha1_hmac_init_vector (&ctx, w, pw_len); - - sha1_hmac_update_vector (&ctx, s, salt_len); - - sha1_hmac_final_vector (&ctx); - - // initialize a buffer for the otp code - u32 otp_code = 0; - - // grab 4 consecutive bytes of the hash, starting at offset - switch (ctx.opad.h[4] & 15) - { - case 0: otp_code = ctx.opad.h[0]; break; - case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; - case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; - case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; - case 4: otp_code = ctx.opad.h[1]; break; - case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; - case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; - case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; - case 8: otp_code = ctx.opad.h[2]; break; - case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; - case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; - case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; - case 12: otp_code = ctx.opad.h[3]; break; - case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; - case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; - case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; - } - - // take only the lower 31 bits - otp_code &= 0x7fffffff; - - // we want to generate only 6 digits of code - otp_code %= 1000000; - - COMPARE_S_SIMD (otp_code, 0, 0, 0); - } -} +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +DECLSPEC void _totp_calculate (PRIVATE_AS u32x *code, PRIVATE_AS const u32x *w, const u32 pw_len, PRIVATE_AS const u32x *s, const u32 salt_len) +{ + sha1_hmac_ctx_vector_t ctx; + + sha1_hmac_init_vector (&ctx, w, pw_len); + + sha1_hmac_update_vector (&ctx, s, salt_len); + + sha1_hmac_final_vector (&ctx); + + // initialize a buffer for the otp code + u32x otp_code = 0; + + // grab 4 consecutive bytes of the hash, starting at offset + switch (ctx.opad.h[4] & 15) + { + case 0: otp_code = ctx.opad.h[0]; break; + case 1: otp_code = ctx.opad.h[0] << 8 | ctx.opad.h[1] >> 24; break; + case 2: otp_code = ctx.opad.h[0] << 16 | ctx.opad.h[1] >> 16; break; + case 3: otp_code = ctx.opad.h[0] << 24 | ctx.opad.h[1] >> 8; break; + case 4: otp_code = ctx.opad.h[1]; break; + case 5: otp_code = ctx.opad.h[1] << 8 | ctx.opad.h[2] >> 24; break; + case 6: otp_code = ctx.opad.h[1] << 16 | ctx.opad.h[2] >> 16; break; + case 7: otp_code = ctx.opad.h[1] << 24 | ctx.opad.h[2] >> 8; break; + case 8: otp_code = ctx.opad.h[2]; break; + case 9: otp_code = ctx.opad.h[2] << 8 | ctx.opad.h[3] >> 24; break; + case 10: otp_code = ctx.opad.h[2] << 16 | ctx.opad.h[3] >> 16; break; + case 11: otp_code = ctx.opad.h[2] << 24 | ctx.opad.h[3] >> 8; break; + case 12: otp_code = ctx.opad.h[3]; break; + case 13: otp_code = ctx.opad.h[3] << 8 | ctx.opad.h[4] >> 24; break; + case 14: otp_code = ctx.opad.h[3] << 16 | ctx.opad.h[4] >> 16; break; + case 15: otp_code = ctx.opad.h[3] << 24 | ctx.opad.h[4] >> 8; break; + } + + // take only the lower 31 bits + otp_code &= 0x7fffffff; + + // we want to generate only 6 digits of code + *code = otp_code % 1000000; +} + +KERNEL_FQ void m18100_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; + + u32x s[64] = { 0 }; + + for (u32 i = 0; i < count; i += 1) + { + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + if (count == 1) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0; + + _totp_calculate (&otp_code0, w, pw_len, s, 8); + + COMPARE_M_SIMD (otp_code0, 0, 0, 0); + } + } + else if (count == 2) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1; + + _totp_calculate (&otp_code0, w, pw_len, s + 0, 8); + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + + COMPARE_M_SIMD (otp_code0, otp_code1, 0, 0); + } + } + else if (count == 3) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, w, pw_len, s + 0, 8); + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + _totp_calculate (&otp_code2, w, pw_len, s + 32, 8); + + COMPARE_M_SIMD (otp_code0, otp_code1, otp_code2, 0); + } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, w, pw_len, s + 0, 8); + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + _totp_calculate (&otp_code2, w, pw_len, s + 32, 8); + _totp_calculate (&otp_code3, w, pw_len, s + 48, 8); + + COMPARE_M_SIMD (otp_code0, otp_code1, otp_code2, otp_code3); + } + } +} + +KERNEL_FQ void m18100_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 count = salt_bufs[SALT_POS_HOST].salt_len / 16; + + u32x s[64] = { 0 }; + + for (u32 i = 0; i < count; i += 1) + { + s[16 * i + 0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 0]); + s[16 * i + 1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[4 * i + 1]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + if (count == 1) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0; + + _totp_calculate (&otp_code0, w, pw_len, s, 8); + + COMPARE_S_SIMD (otp_code0, 0, 0, 0); + } + } + else if (count == 2) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1; + + _totp_calculate (&otp_code0, w, pw_len, s, 8); + + if (MATCHES_ONE_VS(otp_code0, search[0])) + { + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + + COMPARE_S_SIMD (otp_code0, otp_code1, 0, 0); + } + } + } + else if (count == 3) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1, otp_code2; + + _totp_calculate (&otp_code0, w, pw_len, s, 8); + + if (MATCHES_ONE_VS(otp_code0, search[0])) + { + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + + if (MATCHES_ONE_VS(otp_code1, search[1])) + { + _totp_calculate (&otp_code2, w, pw_len, s + 32, 8); + + COMPARE_S_SIMD (otp_code0, otp_code1, otp_code2, 0); + } + } + } + } + else if (count == 4) + { + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + u32x otp_code0, otp_code1, otp_code2, otp_code3; + + _totp_calculate (&otp_code0, w, pw_len, s, 8); + + if (MATCHES_ONE_VS(otp_code0, search[0])) + { + _totp_calculate (&otp_code1, w, pw_len, s + 16, 8); + + if (MATCHES_ONE_VS(otp_code1, search[1])) + { + _totp_calculate (&otp_code2, w, pw_len, s + 32, 8); + + if (MATCHES_ONE_VS(otp_code2, search[2])) + { + _totp_calculate (&otp_code3, w, pw_len, s + 48, 8); + + COMPARE_S_SIMD (otp_code0, otp_code1, otp_code2, otp_code3); + } + } + } + } + } +} diff --git a/src/modules/module_18100.c b/src/modules/module_18100.c index 37a8ef2e7..54b12a68e 100644 --- a/src/modules/module_18100.c +++ b/src/modules/module_18100.c @@ -29,7 +29,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; -static const char *ST_HASH = "597056:3600"; +static const char *ST_HASH = "597056:3600:613004:1234567890:322664:9876543210"; u32 module_attack_exec (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 ATTACK_EXEC; } u32 module_dgst_pos0 (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 DGST_POS0; } @@ -57,54 +57,92 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; - memset (&token, 0, sizeof (hc_token_t)); - - token.token_cnt = 2; - - token.sep[0] = hashconfig->separator; - token.len[0] = 6; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.len_min[1] = SALT_MIN; - token.len_max[1] = SALT_MAX; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; - - if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + // 1 to 4 TOTP codes + // 597056:3600 + // 597056:3600:613004:1234567890 + // 597056:3600:613004:1234567890:322664:9876543210 + // 597056:3600:613004:1234567890:322664:9876543210:068798:111222333 + int count; + for (count = 8; count > 0; count -= 2) { - token.len_min[1] *= 2; - token.len_max[1] *= 2; + memset (&token, 0, sizeof (hc_token_t)); - token.attr[1] |= TOKEN_ATTR_VERIFY_DIGIT; + token.token_cnt = count; + + for (int i = 0; i < count; i += 2) + { + token.sep[i + 0] = hashconfig->separator; + token.len[i + 0] = 6; + token.attr[i + 0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // 0 to 18446744073709551616 + token.sep[i + 1] = hashconfig->separator; + token.len_min[i + 1] = 1; + token.len_max[i + 1] = 20; + token.attr[i + 1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[i + 1] *= 2; + token.len_max[i + 1] *= 2; + token.attr[i + 1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer == PARSER_OK) break; + + // failed all tokenizers + if (count == 2) return (rc_tokenizer); + } + count /= 2; + + for (int i = 0; i < count; i += 1) + { + // now we need to reduce our hash into a token + int otp_code = hc_strtoul ((const char *) token.buf[2 * i + 0], NULL, 10); + + digest[i] = otp_code; + + const u8 *salt_pos = token.buf[2 * i + 1]; + + // convert ascii timestamp to ulong timestamp + u64 timestamp = hc_strtoull ((const char *) salt_pos, NULL, 10); + + // store the original salt value. Step division will destroy granularity for output + salt->salt_buf[4 * i + 3] = ((u32) (timestamp >> 0)); + salt->salt_buf[4 * i + 2] = ((u32) (timestamp >> 32)); + + // divide our timestamp by our step. We will use the RFC 6238 default of 30 for now + timestamp /= 30; + + // convert counter to 8-byte salt + salt->salt_buf[4 * i + 1] = byte_swap_32 ((u32) (timestamp >> 0)); + salt->salt_buf[4 * i + 0] = byte_swap_32 ((u32) (timestamp >> 32)); } - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + // verify unique salts + for (int i = 0; i < count; i += 1) + { + u32 s0 = salt->salt_buf[4 * i + 0]; + u32 s1 = salt->salt_buf[4 * i + 1]; - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - // now we need to reduce our hash into a token - int otp_code = hc_strtoul (line_buf, NULL, 10); - - digest[0] = otp_code; - - const u8 *salt_pos = token.buf[1]; - - // convert ascii timestamp to ulong timestamp - u64 timestamp = hc_strtoull ((const char *) salt_pos, NULL, 10); - - // store the original salt value. Step division will destroy granularity for output - salt->salt_buf[3] = ((u32) (timestamp >> 0)); - salt->salt_buf[2] = ((u32) (timestamp >> 32)); - - // divide our timestamp by our step. We will use the RFC 6238 default of 30 for now - timestamp /= 30; - - // convert counter to 8-byte salt - salt->salt_buf[1] = byte_swap_32 ((u32) (timestamp >> 0)); - salt->salt_buf[0] = byte_swap_32 ((u32) (timestamp >> 32)); + for (int j = i + 1; j < count; j += 1) + { + if (salt->salt_buf[4 * j + 0] == s0 && + salt->salt_buf[4 * j + 1] == s1) + { + return (PARSER_SALT_VALUE); + } + } + } // our salt will always be 8 bytes, but we are going to cheat and store it twice, so... - salt->salt_len = 16; + salt->salt_len = 16 * count; return (PARSER_OK); } @@ -113,13 +151,37 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const u32 *digest = (const u32 *) digest_buf; - // salt_buf[1] holds our 32 bit value. salt_buf[0] and salt_buf[1] would be 64 bits. + // salt_buf[4 * i + 1] holds our 32 bit value. salt_buf[4 * i + 0] and salt_buf[4 * i + 1] would be 64 bits. // we also need to multiply salt by our step to see the floor of our original timestamp range. // again, we will use the default RFC 6238 step of 30. - const u64 tmp_salt_buf = (((u64) (salt->salt_buf[2])) << 32) | ((u64) (salt->salt_buf[3])); + int count = salt->salt_len / 16; - const int line_len = snprintf (line_buf, line_size, "%06d%c%" PRIu64, digest[0], hashconfig->separator, tmp_salt_buf); + // all but the last TOTP code + int i = 0, line_len = 0; + for (; i < count - 1; i += 1) + { + const u64 tmp_salt_buf = (((u64) (salt->salt_buf[4 * i + 2])) << 32) | ((u64) (salt->salt_buf[4 * i + 3])); + const int ret = snprintf (line_buf + line_len, line_size - line_len, "%06d%c%" PRIu64 "%c", digest[i], hashconfig->separator, tmp_salt_buf, hashconfig->separator); + line_len += ret; + + // error + if (ret < 0) + { + return ret; + } + } + + // the last TOTP code + const u64 tmp_salt_buf = (((u64) (salt->salt_buf[4 * i + 2])) << 32) | ((u64) (salt->salt_buf[4 * i + 3])); + const int ret = snprintf (line_buf + line_len, line_size - line_len, "%06d%c%" PRIu64, digest[i], hashconfig->separator, tmp_salt_buf); + line_len += ret; + + // error + if (ret < 0) + { + return ret; + } return line_len; } From 08514edd22c10d21ba329317b0985753a695396f Mon Sep 17 00:00:00 2001 From: unix-ninja Date: Sat, 15 Feb 2025 22:29:38 -0500 Subject: [PATCH 081/357] Ignore .DS_Store files. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d8ff600bb..f7d1967e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.DS_Store +*/.DS_Store *.exe *.bin *.app From faa680fbab803723d77449b7107c1c985a6b7981 Mon Sep 17 00:00:00 2001 From: unix-ninja Date: Sat, 15 Feb 2025 22:30:05 -0500 Subject: [PATCH 082/357] Add gitea2hashcat.py --- tools/gitea2hashcat.py | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 tools/gitea2hashcat.py diff --git a/tools/gitea2hashcat.py b/tools/gitea2hashcat.py new file mode 100755 index 000000000..ac1c539d2 --- /dev/null +++ b/tools/gitea2hashcat.py @@ -0,0 +1,75 @@ +#!/usr/bin/python3 +# Converts gitea PBKDF2-HMAC-SHA256 hashes into a format hashcat can use +# written by unix-ninja + +import argparse +import base64 +import sys + +def convert_hash(hash_string): + """Converts a SALT+HASH string to a hashcat compatible format, + ensuring the smaller input is treated as the salt. + Use : or | as delimeters. + """ + hash_string = hash_string.replace('|', ':') + try: + part1, part2 = hash_string.split(":") + except ValueError: + print(f"[-] Invalid input format: {hash_string}") + return None + + try: + bytes1 = bytes.fromhex(part1) + bytes2 = bytes.fromhex(part2) + except ValueError: + print(f"[-] Invalid hex input: {hash_string}") + return None + + # If lengths are equal, we will maintain the original order + if len(bytes1) > len(bytes2): + salt_bytes = bytes2 + hash_bytes = bytes1 + else: + salt_bytes = bytes1 + hash_bytes = bytes2 + + + salt_b64 = base64.b64encode(salt_bytes).decode('utf-8') + hash_b64 = base64.b64encode(hash_bytes).decode('utf-8') + + return f"sha256:50000:{salt_b64}:{hash_b64}" + + +def main(): + parser = argparse.ArgumentParser(description="Convert Gitea SALT+HASH strings to a hashcat-compatible format.", + formatter_class=argparse.RawTextHelpFormatter, + epilog="""Example: + gitea2hashcat.py : | ... or pipe input from stdin. + + You can also dump output straight from sqlite into this script: + sqlite3 gitea.db 'select salt,passwd from user;' | gitea2hashcat.py""") + parser.add_argument('hashes', nargs='*', help='SALT+HASH strings to convert') + args = parser.parse_args() + + # ... (rest of the main function remains the same) + print("[+] Run the output hashes through hashcat mode 10900 (PBKDF2-HMAC-SHA256)") + print() + + if args.hashes: + # Process command-line arguments + for hash_string in args.hashes: + converted_hash = convert_hash(hash_string) + if converted_hash: + print(converted_hash) + + else: + # Process input from stdin + for line in sys.stdin: + hash_string = line.strip() # Remove leading/trailing whitespace + converted_hash = convert_hash(hash_string) + if converted_hash: + print(converted_hash) + + +if __name__ == "__main__": + main() From 3188f1a64d8e7bbeab771360cbf01a9f326d1afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dosko=C4=8Dil?= <30779172+Dook97@users.noreply.github.com> Date: Wed, 19 Feb 2025 12:56:59 +0100 Subject: [PATCH 083/357] mod 8300 (NSEC3): support salt length up to what the standard allows --- src/modules/module_08300.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module_08300.c b/src/modules/module_08300.c index 74bb19823..e51d30313 100644 --- a/src/modules/module_08300.c +++ b/src/modules/module_08300.c @@ -64,7 +64,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[2] = ':'; token.len_min[2] = 0; - token.len_max[2] = 32; + token.len_max[2] = 510; // max salt length is 255B, human readable repr is hex so 2 chars per byte token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[3] = ':'; From 7509c6f70abcbf55fa35e17e8608ae2779fd9760 Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:03:42 +0000 Subject: [PATCH 084/357] Add apfs2hashcat.py --- tools/apfs2hashcat.py | 434 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 434 insertions(+) create mode 100644 tools/apfs2hashcat.py diff --git a/tools/apfs2hashcat.py b/tools/apfs2hashcat.py new file mode 100644 index 000000000..d310dd43e --- /dev/null +++ b/tools/apfs2hashcat.py @@ -0,0 +1,434 @@ +#!/usr/bin/env python3 + +# For extracting APFS hashes to be cracked by hashcat modes 18300 ($fvde$2$) or 16700 ($fvde$1$). +# Usage: `python3 apfs2hashcat.py -o <_apfs_container_offset>` +# The argument -o is optional. The script will attempt to read the partition table to find the location of APFS container(s). In the case that the partition table is missing or you want to specify a particular APFS container, use -o to provide the offset to the start of the container. + +import argparse +from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes + +# KNOWN_RECOVERY_HASHES = ['ebc6c064000011aaaa1100306543ecac', 'ec1c2ad9b6184ed6bd8d50f361c27507'] +KNOWN_RECOVERY_HASHES = ['64C0C6EB-0000-AA11-AA11-00306543ECAC', 'D92A1CEC-18B6-D64E-BD8D-50F361C27507'] +TAG_DICT = {'unk_80' : {'tag' : b'\x80', 'expected_len' : 1}, + 'uuid' : {'tag' : b'\x81', 'expected_len' : 0x10}, + 'unk_82' : {'tag' : b'\x82'}, + 'wrapped_kek' : {'tag' : b'\x83', 'expected_len' : 0x28}, + 'iterations' : {'tag' : b'\x84'}, + 'salt' : {'tag' : b'\x85', 'expected_len' : 0x10}} +# HEX_APFS_CONTAINER_GUID = 'ef57347c0000aa11aa1100306543ecac' +HEX_APFS_CONTAINER_GUID = '7C3457EF-0000-11AA-AA11-00306543ECAC' +AES_XTS_SECTOR_SIZE = 512 +EFI_PARTITION_HEADER = b'EFI PART' + +def uint_to_int(b): + return int(b[::-1].hex(), 16) + + +def findall(p, s): + i = s.find(p) + while i != -1: + yield i + i = s.find(p, i+1) + + +def hex_to_guid(hex_str): + + guid_parts = [0] * 5 + guid_parts[0] = hex_str[0:8] + guid_parts[1] = hex_str[8:12] + guid_parts[2] = hex_str[12:16] + guid_parts[3] = hex_str[16:20] + guid_parts[4] = hex_str[20:] + + guid = ''.join([guid_parts[0][i:i+2] for i in range(0, len(guid_parts[0]), 2)][::-1]) + guid += '-' + guid += ''.join([guid_parts[1][i:i+2] for i in range(0, len(guid_parts[1]), 2)][::-1]) + guid += '-' + guid += ''.join([guid_parts[2][i:i+2] for i in range(0, len(guid_parts[2]), 2)][::-1]) + guid += '-' + guid += guid_parts[3] + guid += '-' + guid += guid_parts[4] + + return guid.upper() + + +def parse_partition_entry(partition_entry): + type_GUID = partition_entry[0:0x10] + part_GUID = partition_entry[0x10:0x20] + start_LBA = partition_entry[0x20:0x28] + # end_LBA = partition_entry[0x28:0x30] + return part_GUID, type_GUID, start_LBA + + +# get main_start by multiplying apfs partition start lba by block size +def parse_partition_table(fp): + + # determine whether sector size is 0x200 or 0x1000 + sector_size = 0x0 + + # look for EFI PART at start of sector 1 + fp.seek(0x200) + signature = fp.read(0x8) + if signature == EFI_PARTITION_HEADER: + sector_size = 0x200 + + else: + fp.seek(0x1000) + signature = fp.read(0x8) + if signature == EFI_PARTITION_HEADER: + sector_size = 0x1000 + + print("[+] Identified sector size:", sector_size) + + if not sector_size: + print(f"[!] Invalid sector size {sector_size} (not 512 or 4096 bytes). Exiting.") + + fp.seek(2 * sector_size) # go to sector 2 + partitions = [] + partition_entry = b'1' + while any(partition_entry): + partition_entry = fp.read(0x80) + if any(partition_entry): + partitions.append(partition_entry) + + partition_dict = {} + for p in partitions: + part_GUID, type_GUID, start = parse_partition_entry(p) + starting_pos = uint_to_int(start) * sector_size + partition_dict[part_GUID.hex()] = {'start':starting_pos, 'partition_type':type_GUID.hex()} + + return partition_dict + + +def AES_XTS_decrypt_sector(uuid, tweak, ct): + + decryptor = Cipher( + algorithms.AES(key=uuid+uuid), + modes.XTS(tweak=tweak), + ).decryptor() + pt = decryptor.update(ct) + decryptor.finalize() + + return pt + + +def AES_decrypt(data, start_offset, block_size, uuid): + cs_factor = block_size // 0x200 # = 8 for block_size=4096 + uno = start_offset * cs_factor + pt = b'' + for offset in range(0, block_size, AES_XTS_SECTOR_SIZE): + ct = data[offset:offset + AES_XTS_SECTOR_SIZE] + tweak = hex(uno)[2:].zfill(32) # 32 so that the key is the correct length (16 bytes) + tweak = bytearray.fromhex(tweak)[::-1] + pt += AES_XTS_decrypt_sector(uuid, tweak, ct) + uno += 1 + + return pt + + +def TLV(full_kek_blob, tag, starting_index): + # expected tag should follow if this is the correct TLV) + if full_kek_blob[starting_index:starting_index+1] != TAG_DICT[tag]['tag']: + return -1, starting_index + # check for expected len for further confirmation + length = uint_to_int(full_kek_blob[starting_index+1:starting_index+2]) + expected_len = TAG_DICT[tag].get('expected_len') # use .get() since not all tags have an expected len + if expected_len: + if length != expected_len: + return -1, starting_index + next_starting_index = starting_index+2+length + value = full_kek_blob[starting_index+2:next_starting_index] + + return value, next_starting_index + + +def TLV_iterate(starting_index, pt, hash_set, volume_uuid): + for tag in TAG_DICT: + value, starting_index = TLV(pt, tag, starting_index) + + # i.e. if fails length check + if value == -1: + return starting_index + 1, hash_set + TAG_DICT[tag]['value'] = value + + aes_type = TAG_DICT['unk_82']['value'] + wrapped_kek = TAG_DICT['wrapped_kek']['value'] + iterations = TAG_DICT['iterations']['value'] + salt = TAG_DICT['salt']['value'] + + aes_type = uint_to_int(aes_type[0:4]) + + # FVDE - AES128 + if aes_type == 2: + aes_hash_value = 1 + wrapped_kek = wrapped_kek[:0x18] # shorter kek value, this removes zeros + + # APFS - AES256 + elif aes_type == 16 or aes_type == 0: + aes_hash_value = 2 + + else: + print("[!] AES type not recognised, continuing...") + return + + password_hash = f"$fvde${aes_hash_value}${len(salt)}${salt.hex()}${int(iterations.hex(),16)}${wrapped_kek.hex()}" + hash_set.add(password_hash) + print(f"\nFound password hash: {password_hash} (vol uuid: {volume_uuid.hex()})") + + kek_uuid = hex_to_guid(TAG_DICT['uuid']['value'].hex()) + if kek_uuid in KNOWN_RECOVERY_HASHES: + print(f"[!] Warning! Recognised UUID {kek_uuid}... possible recovery hash\n") + + return starting_index, hash_set + + +def parse_block(block): + nx_xid = uint_to_int(block[16:24]) + obj_type = uint_to_int(block[24:26]) + magic = block[0x20:0x24] + + return nx_xid, obj_type, magic + + +def parse_apsb_block(block): + obj_type = uint_to_int(block[24:26]) + magic = block[0x20:0x24] + uuid = block[240:256] + encryption = uint_to_int(block[264:272]) + name = block[704:960] + + return obj_type, magic, uuid, encryption, name + + +def parse_keybag_entry(uuid, pt): + uuid_iterator = findall(uuid, pt) + for starting_pos in uuid_iterator: + ke_uuid, ke_tag, ke_keylen = pt[starting_pos:starting_pos+16], uint_to_int(pt[starting_pos + 16:starting_pos + 18]), uint_to_int(pt[starting_pos + 18:starting_pos + 20]) + padding = pt[starting_pos + 20:starting_pos + 24] + keydata = pt[starting_pos + 24: starting_pos + 24 + ke_keylen] + + # only tag 3 is needed for constructing the hash + if ke_tag == 3: + assert padding == b'\x00\x00\x00\x00' + volume_unlock_record = keydata + return volume_unlock_record + + return None + + +def get_fs_oids(csb_body): + max_file_systems = uint_to_int(csb_body[0x94:0x98]) + fs_oids = set() + for fs_entry in range(max_file_systems): + oid_start = 0x98 + 8 * fs_entry + fs_oid = uint_to_int(csb_body[oid_start:oid_start + 8]) + if not fs_oid: + continue + fs_oids.add(fs_oid) + + return fs_oids + + +def parse_csb(csb): + csb_body = csb[0x20:0x568] + + header = csb_body[:4] # 'NXSB' + assert header == b'NXSB' + block_size = uint_to_int(csb_body[4:8]) # default is 4096 + uuid = csb_body[0x28:0x38] # used as key for unwrapping + omap_oid = uint_to_int(csb_body[0x80:0x88]) # omap_oid to locate the omap to find volume offsets + fs_oids = get_fs_oids(csb_body) + + # locate container's keybag using nx_keylocker field + keylocker_paddr = uint_to_int(csb_body[0x4f0:0x4f8]) + + # block info for iterating to find most recent csb + xp_desc_blocks = uint_to_int(csb_body[0x48:0x4b]) + xp_desc_base = uint_to_int(csb_body[0x50:0x54]) + + return block_size, uuid, keylocker_paddr, omap_oid, fs_oids, xp_desc_base, xp_desc_blocks + + +def get_offset_from_oid(oid, apfs_start, block_size): + return apfs_start + oid * block_size + + +def parse_tree(tree, fs_oids, block_size): + + volume_addresses = [] + + # get key data from TOC: + table_space_offset = uint_to_int(tree[0x28:0x2a]) + table_space_len = uint_to_int(tree[0x2a:0x2c]) + start_of_key_area = table_space_offset + table_space_len + 0x38 # 0x38 = header + entries + + # b-tree structure is header (0x20 bytes) -> ToC -> keys -> free space -> values -> btree_info (0x28 bytes) + end_of_value_area = block_size - 0x28 + + tree_data = tree[0x38:] + for m in range(len(fs_oids)): + data_start = m * 4 + key_offset = uint_to_int(tree_data[data_start:data_start + 2]) # key offset is from the start of the key area downwards + data_offset = uint_to_int(tree_data[data_start + 2:data_start + 4]) # data offset is from the end of the data area upwards + + # get to key area + key_start = key_offset + start_of_key_area + key_oid = uint_to_int(tree[key_start:key_start + 0x8]) + + if key_oid not in fs_oids: + print(f"Found key_oid {key_oid} in omap but not present in fs map. Skipping this volume") + + else: + val_end = end_of_value_area - data_offset + data_paddr = uint_to_int(tree[val_end + 0x8:val_end + 0x10]) + volume_addresses.append(data_paddr) + + return volume_addresses + + +def get_volumes(fp, block_size, apfs_start, tree, fs_oids): + volume_addresses = parse_tree(tree, fs_oids, block_size) + volumes_dict = dict() + for v in volume_addresses: + fp.seek(apfs_start + block_size * v) + block_start = fp.read(block_size) + obj_type, magic, uuid, encryption, name = parse_apsb_block(block_start) + if obj_type == 13 and magic == b'APSB': + volumes_dict[uuid] = {'start':v, 'name':name} + print() + print("[+] The following volumes are present:") + for u in volumes_dict: + print(f"{u.hex()} ({volumes_dict[u]['name'].decode()}) at {hex(volumes_dict[u]['start'] * block_size + apfs_start)}") + + return volumes_dict + + +def decrypt_volume_keybag(fp, volume_keybag_addr, block_size, apfs_struct_start, volume_uuid): + volume_keybag_addr = volume_keybag_addr[:4].hex().zfill(8) + volume_keybag_addr = bytearray.fromhex(volume_keybag_addr)[::-1] + volume_keybag_addr = int(volume_keybag_addr.hex(),16) + + offset = block_size * volume_keybag_addr + apfs_struct_start + fp.seek(offset) + encrypted_keybag = fp.read(block_size) + pt = AES_decrypt(encrypted_keybag, volume_keybag_addr, block_size, volume_uuid) + + return pt + + +def get_apfs_containers(fp): + partition_dict = parse_partition_table(fp) + apfs_containers = [] + for d in partition_dict: + if hex_to_guid(partition_dict[d]['partition_type']) == HEX_APFS_CONTAINER_GUID: + apfs_containers.append(partition_dict[d]['start']) + + return apfs_containers + + +def get_tree(fp, omap_oid, apfs_struct_start, block_size): + omap_offset = get_offset_from_oid(omap_oid, apfs_struct_start, block_size) + fp.seek(omap_offset + 0x30) # location for tree_oid + tree_oid = fp.read(0x10) + tree_oid = uint_to_int(tree_oid) + tree_offset = get_offset_from_oid(tree_oid, apfs_struct_start, block_size) + + fp.seek(tree_offset) + tree = fp.read(0x1000) + + return tree + + +def get_container_keybag(fp, apfs_struct_start, block_size, keylocker_paddr): + # calculate offset to read from + offs = block_size * keylocker_paddr + apfs_struct_start + fp.seek(offs) + data = fp.read(block_size) + + return data + + +def find_valid_csb(fp, block_size, xp_desc_base, xp_desc_blocks, apfs_start): + max_xid = 0 + max_xid_paddr = 0 + + for paddr in range(xp_desc_base, xp_desc_base + xp_desc_blocks): + offs = block_size * paddr + apfs_start + fp.seek(offs + 0x10) + csb_xid = uint_to_int(fp.read(0x8)) + if csb_xid >= max_xid: + max_xid = csb_xid + max_xid_paddr = paddr + + print(f"[+] Found valid csb with xid {max_xid} at {hex(max_xid_paddr)}") + return max_xid_paddr + + +def main(): + + p = argparse.ArgumentParser() + p.add_argument('filename') + p.add_argument('-o', '--offset', help='[OPTIONAL] offset for APFS volume - may be necessary if partition table is not present') + args = p.parse_args() + + filename = args.filename + with open(filename, 'rb') as fp: + + if args.offset: + apfs_offset = int(args.offset) + apfs_containers = [apfs_offset] + + else: + apfs_containers = get_apfs_containers(fp) + + if apfs_containers == []: + print("[!] APFS volume GUID not found, exiting.") + exit() + + for apfs_struct_start in apfs_containers: + print(f"[+] APFS container starts at {hex(apfs_struct_start)}") + fp.seek(apfs_struct_start) + csb = fp.read(0x568) + + # read the first csb for initial info - then use this to iterate through all csbs and find the most recent one + block_size, uuid, keylocker_paddr, omap_oid, fs_oids, xp_desc_base, xp_desc_blocks = parse_csb(csb) + valid_csb_paddr = find_valid_csb(fp, block_size, xp_desc_base, xp_desc_blocks, apfs_struct_start) + + fp.seek(valid_csb_paddr * block_size + apfs_struct_start) + valid_csb = fp.read(block_size) + block_size, uuid, keylocker_paddr, omap_oid, fs_oids, xp_desc_base, xp_desc_blocks = parse_csb(valid_csb) + + encrypted_keybag = get_container_keybag(fp, apfs_struct_start, block_size, keylocker_paddr) + # Unwrap container keybag using AES-XTS with container UUID as key + starting_pt = AES_decrypt(encrypted_keybag, keylocker_paddr, block_size, uuid) + + # find all volumes to iterate through + tree = get_tree(fp, omap_oid, apfs_struct_start, block_size) + + volumes_dict = get_volumes(fp, block_size, apfs_struct_start, tree, fs_oids) + + hash_set = set() + for volume_uuid in volumes_dict: + + # find entry in container's keybag matching volume UUID and has KB_TAG_VOLUME_UNLOCK_RECORDS = 3. Its keydata is location of volume keybag. + volume_keybag_addr = parse_keybag_entry(volume_uuid, starting_pt) + + # continue if encrypted keybag not found + if not volume_keybag_addr: + continue + + # unwrap volume keybag using volume uuid AES-XTS + pt = decrypt_volume_keybag(fp, volume_keybag_addr, block_size, apfs_struct_start, volume_uuid) + + # parse TLV for 80 first + index_iterator = findall(TAG_DICT['unk_80']['tag'], pt) + for starting_index in index_iterator: + starting_index, hash_set = TLV_iterate(starting_index, pt, hash_set, volume_uuid) + + print() + print("[+] All hashes found.") + + return + +if __name__ == "__main__": + main() From a8e0c8b213aea5211aa459d90af6922f40831428 Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:06:29 +0000 Subject: [PATCH 085/357] Update apfs2hashcat.py Remove hex version of known UUIDs --- tools/apfs2hashcat.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/apfs2hashcat.py b/tools/apfs2hashcat.py index d310dd43e..a0cc6a5da 100644 --- a/tools/apfs2hashcat.py +++ b/tools/apfs2hashcat.py @@ -7,7 +7,6 @@ import argparse from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes -# KNOWN_RECOVERY_HASHES = ['ebc6c064000011aaaa1100306543ecac', 'ec1c2ad9b6184ed6bd8d50f361c27507'] KNOWN_RECOVERY_HASHES = ['64C0C6EB-0000-AA11-AA11-00306543ECAC', 'D92A1CEC-18B6-D64E-BD8D-50F361C27507'] TAG_DICT = {'unk_80' : {'tag' : b'\x80', 'expected_len' : 1}, 'uuid' : {'tag' : b'\x81', 'expected_len' : 0x10}, @@ -15,7 +14,6 @@ TAG_DICT = {'unk_80' : {'tag' : b'\x80', 'expected_len' : 1}, 'wrapped_kek' : {'tag' : b'\x83', 'expected_len' : 0x28}, 'iterations' : {'tag' : b'\x84'}, 'salt' : {'tag' : b'\x85', 'expected_len' : 0x10}} -# HEX_APFS_CONTAINER_GUID = 'ef57347c0000aa11aa1100306543ecac' HEX_APFS_CONTAINER_GUID = '7C3457EF-0000-11AA-AA11-00306543ECAC' AES_XTS_SECTOR_SIZE = 512 EFI_PARTITION_HEADER = b'EFI PART' From b2c846135dbc7cd0e5e226d9217f8716eb5f3a95 Mon Sep 17 00:00:00 2001 From: magnum Date: Tue, 25 Feb 2025 15:10:33 +0100 Subject: [PATCH 086/357] Recover from (rare) non-fatal file locking problems --- src/locking.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/locking.c b/src/locking.c index 8918101a2..492350bab 100644 --- a/src/locking.c +++ b/src/locking.c @@ -20,9 +20,18 @@ int hc_lockfile (HCFILE *fp) lock.l_type = F_WRLCK; - /* Needs this loop because a signal may interrupt a wait for lock */ while (fcntl (fp->fd, F_SETLKW, &lock)) { + // These shouldn't happen with F_SETLKW yet are (rarely) seen IRL. Recoverable! + if (errno == EAGAIN || errno == ENOLCK) + { + struct timeval tv = { .tv_sec = 0, .tv_usec = 10000 }; + select (0, NULL, NULL, NULL, &tv); + + continue; + } + + // A signal may interrupt a wait for lock with EINTR. Anything else is fatal if (errno != EINTR) return -1; } From 9b9a7a519a19fe56d5d53fba255f6cb879daee6a Mon Sep 17 00:00:00 2001 From: PenguinKeeper7 Date: Sat, 5 Apr 2025 19:10:12 +0100 Subject: [PATCH 087/357] Recommend --keep-guessing on -m 20510 --- src/modules/module_20510.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/module_20510.c b/src/modules/module_20510.c index d96f57b6e..4172c1fda 100644 --- a/src/modules/module_20510.c +++ b/src/modules/module_20510.c @@ -81,7 +81,8 @@ static const u32 OPTI_TYPE = 0; static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_COPY_TMPS | OPTS_TYPE_MAXIMUM_THREADS - | OPTS_TYPE_AUTODETECT_DISABLE; + | OPTS_TYPE_AUTODETECT_DISABLE + | OPTS_TYPE_SUGGEST_KG; static const u32 SALT_TYPE = SALT_TYPE_NONE; static const char *ST_PASS = "t"; // actually "hashcat" static const char *ST_HASH = "f1eff5c0368d10311dcfc419"; From d2e9eacca8fa540e4d18f34258a72307aca8c30c Mon Sep 17 00:00:00 2001 From: holly-o <128481388+holly-o@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:11:20 +0100 Subject: [PATCH 088/357] Added OpenCL files for plugin 67890 --- OpenCL/inc_hash_blake2s.cl | 664 ++++++++++++++++++++++++++++++++++++- OpenCL/inc_hash_blake2s.h | 37 +++ OpenCL/m67890_a0-pure.cl | 135 ++++++++ OpenCL/m67890_a1-pure.cl | 183 ++++++++++ OpenCL/m67890_a3-pure.cl | 156 +++++++++ 5 files changed, 1172 insertions(+), 3 deletions(-) create mode 100644 OpenCL/m67890_a0-pure.cl create mode 100644 OpenCL/m67890_a1-pure.cl create mode 100644 OpenCL/m67890_a3-pure.cl diff --git a/OpenCL/inc_hash_blake2s.cl b/OpenCL/inc_hash_blake2s.cl index 5fb60f979..77ecc02fb 100644 --- a/OpenCL/inc_hash_blake2s.cl +++ b/OpenCL/inc_hash_blake2s.cl @@ -9,6 +9,7 @@ #include "inc_common.h" #include "inc_hash_blake2s.h" + DECLSPEC u32 blake2s_rot16_S (const u32 a) { vconv32_t in; @@ -217,7 +218,7 @@ DECLSPEC void blake2s_update_64 (PRIVATE_AS blake2s_ctx_t *ctx, PRIVATE_AS u32 * if (pos == 0) { - if (ctx->len > 0) // if new block (pos == 0) AND the (old) len is not zero => transform + if (ctx->len > 0) { blake2s_transform (ctx->h, ctx->m, ctx->len, BLAKE2S_UPDATE); } @@ -288,8 +289,6 @@ DECLSPEC void blake2s_update_64 (PRIVATE_AS blake2s_ctx_t *ctx, PRIVATE_AS u32 * ctx->m[14] |= w3[2]; ctx->m[15] |= w3[3]; - // len must be a multiple of 64 (not ctx->len) for BLAKE2S_UPDATE: - const u32 cur_len = ((ctx->len + len) / 64) * 64; blake2s_transform (ctx->h, ctx->m, cur_len, BLAKE2S_UPDATE); @@ -424,11 +423,520 @@ DECLSPEC void blake2s_update_global (PRIVATE_AS blake2s_ctx_t *ctx, GLOBAL_AS co blake2s_update_64 (ctx, w0, w1, w2, w3, len - (u32) pos1); } +DECLSPEC void blake2s_update_swap (PRIVATE_AS blake2s_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + int pos1; + int pos4; + + for (pos1 = 0, pos4 = 0; pos1 < len - 64; pos1 += 64, pos4 += 16) + { + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + + blake2s_update_64 (ctx, w0, w1, w2, w3, 64); + } + + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + + blake2s_update_64 (ctx, w0, w1, w2, w3, len - pos1); +} + +DECLSPEC void blake2s_update_global_swap (PRIVATE_AS blake2s_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + const int limit = (const int) len - 64; // int type needed, could be negative + + int pos1; + int pos4; + + for (pos1 = 0, pos4 = 0; pos1 < limit; pos1 += 64, pos4 += 16) + { + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + + blake2s_update_64 (ctx, w0, w1, w2, w3, 64); + } + + w0[0] = w[pos4 + 0]; + w0[1] = w[pos4 + 1]; + w0[2] = w[pos4 + 2]; + w0[3] = w[pos4 + 3]; + w1[0] = w[pos4 + 4]; + w1[1] = w[pos4 + 5]; + w1[2] = w[pos4 + 6]; + w1[3] = w[pos4 + 7]; + w2[0] = w[pos4 + 8]; + w2[1] = w[pos4 + 9]; + w2[2] = w[pos4 + 10]; + w2[3] = w[pos4 + 11]; + w3[0] = w[pos4 + 12]; + w3[1] = w[pos4 + 13]; + w3[2] = w[pos4 + 14]; + w3[3] = w[pos4 + 15]; + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + + blake2s_update_64 (ctx, w0, w1, w2, w3, len - (u32) pos1); +} + + DECLSPEC void blake2s_final (PRIVATE_AS blake2s_ctx_t *ctx) { blake2s_transform (ctx->h, ctx->m, ctx->len, BLAKE2S_FINAL); } + +DECLSPEC void blake2s_hmac_init_64 (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1, PRIVATE_AS const u32 *w2, PRIVATE_AS const u32 *w3) +{ + u32 a0[4]; + u32 a1[4]; + u32 a2[4]; + u32 a3[4]; + + // ipad + + a0[0] = w0[0] ^ 0x36363636; + a0[1] = w0[1] ^ 0x36363636; + a0[2] = w0[2] ^ 0x36363636; + a0[3] = w0[3] ^ 0x36363636; + a1[0] = w1[0] ^ 0x36363636; + a1[1] = w1[1] ^ 0x36363636; + a1[2] = w1[2] ^ 0x36363636; + a1[3] = w1[3] ^ 0x36363636; + a2[0] = w2[0] ^ 0x36363636; + a2[1] = w2[1] ^ 0x36363636; + a2[2] = w2[2] ^ 0x36363636; + a2[3] = w2[3] ^ 0x36363636; + a3[0] = w3[0] ^ 0x36363636; + a3[1] = w3[1] ^ 0x36363636; + a3[2] = w3[2] ^ 0x36363636; + a3[3] = w3[3] ^ 0x36363636; + + blake2s_init (&ctx->ipad); + + blake2s_update_64 (&ctx->ipad, a0, a1, a2, a3, 64); + + // opad + + u32 b0[4]; + u32 b1[4]; + u32 b2[4]; + u32 b3[4]; + + b0[0] = w0[0] ^ 0x5c5c5c5c; + b0[1] = w0[1] ^ 0x5c5c5c5c; + b0[2] = w0[2] ^ 0x5c5c5c5c; + b0[3] = w0[3] ^ 0x5c5c5c5c; + b1[0] = w1[0] ^ 0x5c5c5c5c; + b1[1] = w1[1] ^ 0x5c5c5c5c; + b1[2] = w1[2] ^ 0x5c5c5c5c; + b1[3] = w1[3] ^ 0x5c5c5c5c; + b2[0] = w2[0] ^ 0x5c5c5c5c; + b2[1] = w2[1] ^ 0x5c5c5c5c; + b2[2] = w2[2] ^ 0x5c5c5c5c; + b2[3] = w2[3] ^ 0x5c5c5c5c; + b3[0] = w3[0] ^ 0x5c5c5c5c; + b3[1] = w3[1] ^ 0x5c5c5c5c; + b3[2] = w3[2] ^ 0x5c5c5c5c; + b3[3] = w3[3] ^ 0x5c5c5c5c; + + blake2s_init (&ctx->opad); + + blake2s_update_64 (&ctx->opad, b0, b1, b2, b3, 64); +} + +DECLSPEC void blake2s_hmac_init (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + if (len > 64) + { + blake2s_ctx_t tmp; + + blake2s_init (&tmp); + + blake2s_update (&tmp, w, len); + + blake2s_final (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = tmp.h[5]; + w1[2] = tmp.h[6]; + w1[3] = tmp.h[7]; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } + else + { + w0[0] = w[ 0]; + w0[1] = w[ 1]; + w0[2] = w[ 2]; + w0[3] = w[ 3]; + w1[0] = w[ 4]; + w1[1] = w[ 5]; + w1[2] = w[ 6]; + w1[3] = w[ 7]; + w2[0] = w[ 8]; + w2[1] = w[ 9]; + w2[2] = w[10]; + w2[3] = w[11]; + w3[0] = w[12]; + w3[1] = w[13]; + w3[2] = w[14]; + w3[3] = w[15]; + } + + blake2s_hmac_init_64 (ctx, w0, w1, w2, w3); +} + +DECLSPEC void blake2s_hmac_init_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + if (len > 64) + { + blake2s_ctx_t tmp; + + blake2s_init (&tmp); + + blake2s_update_swap (&tmp, w, len); + + blake2s_final (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = tmp.h[5]; + w1[2] = tmp.h[6]; + w1[3] = tmp.h[7]; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } + else + { + w0[0] = hc_swap32_S (w[ 0]); + w0[1] = hc_swap32_S (w[ 1]); + w0[2] = hc_swap32_S (w[ 2]); + w0[3] = hc_swap32_S (w[ 3]); + w1[0] = hc_swap32_S (w[ 4]); + w1[1] = hc_swap32_S (w[ 5]); + w1[2] = hc_swap32_S (w[ 6]); + w1[3] = hc_swap32_S (w[ 7]); + w2[0] = hc_swap32_S (w[ 8]); + w2[1] = hc_swap32_S (w[ 9]); + w2[2] = hc_swap32_S (w[10]); + w2[3] = hc_swap32_S (w[11]); + w3[0] = hc_swap32_S (w[12]); + w3[1] = hc_swap32_S (w[13]); + w3[2] = hc_swap32_S (w[14]); + w3[3] = hc_swap32_S (w[15]); + } + + blake2s_hmac_init_64 (ctx, w0, w1, w2, w3); +} + +DECLSPEC void blake2s_hmac_init_global (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + if (len > 64) + { + blake2s_ctx_t tmp; + + blake2s_init (&tmp); + + blake2s_update_global (&tmp, w, len); + + blake2s_final (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = tmp.h[5]; + w1[2] = tmp.h[6]; + w1[3] = tmp.h[7]; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } + else + { + w0[0] = w[ 0]; + w0[1] = w[ 1]; + w0[2] = w[ 2]; + w0[3] = w[ 3]; + w1[0] = w[ 4]; + w1[1] = w[ 5]; + w1[2] = w[ 6]; + w1[3] = w[ 7]; + w2[0] = w[ 8]; + w2[1] = w[ 9]; + w2[2] = w[10]; + w2[3] = w[11]; + w3[0] = w[12]; + w3[1] = w[13]; + w3[2] = w[14]; + w3[3] = w[15]; + } + + blake2s_hmac_init_64 (ctx, w0, w1, w2, w3); +} + +DECLSPEC void blake2s_hmac_init_global_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + if (len > 64) + { + blake2s_ctx_t tmp; + + blake2s_init (&tmp); + + blake2s_update_global_swap (&tmp, w, len); + + blake2s_final (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = tmp.h[5]; + w1[2] = tmp.h[6]; + w1[3] = tmp.h[7]; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } + else + { + w0[0] = hc_swap32_S (w[ 0]); + w0[1] = hc_swap32_S (w[ 1]); + w0[2] = hc_swap32_S (w[ 2]); + w0[3] = hc_swap32_S (w[ 3]); + w1[0] = hc_swap32_S (w[ 4]); + w1[1] = hc_swap32_S (w[ 5]); + w1[2] = hc_swap32_S (w[ 6]); + w1[3] = hc_swap32_S (w[ 7]); + w2[0] = hc_swap32_S (w[ 8]); + w2[1] = hc_swap32_S (w[ 9]); + w2[2] = hc_swap32_S (w[10]); + w2[3] = hc_swap32_S (w[11]); + w3[0] = hc_swap32_S (w[12]); + w3[1] = hc_swap32_S (w[13]); + w3[2] = hc_swap32_S (w[14]); + w3[3] = hc_swap32_S (w[15]); + } + + blake2s_hmac_init_64 (ctx, w0, w1, w2, w3); +} + +DECLSPEC void blake2s_hmac_update_64 (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const int len) +{ + blake2s_update_64 (&ctx->ipad, w0, w1, w2, w3, len); +} + +DECLSPEC void blake2s_hmac_update (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len) +{ + blake2s_update (&ctx->ipad, w, len); +} + +DECLSPEC void blake2s_hmac_update_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len) +{ + blake2s_update_swap (&ctx->ipad, w, len); +} + +DECLSPEC void blake2s_hmac_update_global (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len) +{ + blake2s_update_global (&ctx->ipad, w, len); +} + +DECLSPEC void blake2s_hmac_update_global_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len) +{ + blake2s_update_global_swap (&ctx->ipad, w, len); +} + +DECLSPEC void blake2s_hmac_final (PRIVATE_AS blake2s_hmac_ctx_t *ctx) +{ + blake2s_final (&ctx->ipad); + + for (int n = 0; n < 8; n += 1) + { + blake2s_update(&ctx->opad, &ctx->ipad.h[n], 4); + } + + ctx->opad.m[8] = 0; + ctx->opad.m[9] = 0; + ctx->opad.m[10]= 0; + ctx->opad.m[11]= 0; + ctx->opad.m[12]= 0; + ctx->opad.m[13]= 0; + ctx->opad.m[14]= 0; + ctx->opad.m[15]= 0; + + blake2s_final (&ctx->opad); +} + DECLSPEC void blake2s_transform_vector (PRIVATE_AS u32x *h, PRIVATE_AS const u32x *m, const u32x len, const u32 f0) { const u32x t0 = len; @@ -452,6 +960,7 @@ DECLSPEC void blake2s_transform_vector (PRIVATE_AS u32x *h, PRIVATE_AS const u32 v[14] = BLAKE2S_IV_06 ^ f0; v[15] = BLAKE2S_IV_07; // ^ f1; + BLAKE2S_ROUND_VECTOR ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); BLAKE2S_ROUND_VECTOR (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); BLAKE2S_ROUND_VECTOR (11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4); @@ -700,3 +1209,152 @@ DECLSPEC void blake2s_final_vector (PRIVATE_AS blake2s_ctx_vector_t *ctx) { blake2s_transform_vector (ctx->h, ctx->m, (u32x) ctx->len, BLAKE2S_FINAL); } + +DECLSPEC void blake2s_hmac_init_vector_64 (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w0, PRIVATE_AS const u32x *w1, PRIVATE_AS const u32x *w2, PRIVATE_AS const u32x *w3) +{ + u32x a0[4]; + u32x a1[4]; + u32x a2[4]; + u32x a3[4]; + + // ipad + + a0[0] = w0[0] ^ 0x36363636; + a0[1] = w0[1] ^ 0x36363636; + a0[2] = w0[2] ^ 0x36363636; + a0[3] = w0[3] ^ 0x36363636; + a1[0] = w1[0] ^ 0x36363636; + a1[1] = w1[1] ^ 0x36363636; + a1[2] = w1[2] ^ 0x36363636; + a1[3] = w1[3] ^ 0x36363636; + a2[0] = w2[0] ^ 0x36363636; + a2[1] = w2[1] ^ 0x36363636; + a2[2] = w2[2] ^ 0x36363636; + a2[3] = w2[3] ^ 0x36363636; + a3[0] = w3[0] ^ 0x36363636; + a3[1] = w3[1] ^ 0x36363636; + a3[2] = w3[2] ^ 0x36363636; + a3[3] = w3[3] ^ 0x36363636; + + blake2s_init_vector (&ctx->ipad); + + blake2s_update_vector_64 (&ctx->ipad, a0, a1, a2, a3, 64); + + // opad + + u32x b0[4]; + u32x b1[4]; + u32x b2[4]; + u32x b3[4]; + + b0[0] = w0[0] ^ 0x5c5c5c5c; + b0[1] = w0[1] ^ 0x5c5c5c5c; + b0[2] = w0[2] ^ 0x5c5c5c5c; + b0[3] = w0[3] ^ 0x5c5c5c5c; + b1[0] = w1[0] ^ 0x5c5c5c5c; + b1[1] = w1[1] ^ 0x5c5c5c5c; + b1[2] = w1[2] ^ 0x5c5c5c5c; + b1[3] = w1[3] ^ 0x5c5c5c5c; + b2[0] = w2[0] ^ 0x5c5c5c5c; + b2[1] = w2[1] ^ 0x5c5c5c5c; + b2[2] = w2[2] ^ 0x5c5c5c5c; + b2[3] = w2[3] ^ 0x5c5c5c5c; + b3[0] = w3[0] ^ 0x5c5c5c5c; + b3[1] = w3[1] ^ 0x5c5c5c5c; + b3[2] = w3[2] ^ 0x5c5c5c5c; + b3[3] = w3[3] ^ 0x5c5c5c5c; + + blake2s_init_vector (&ctx->opad); + + blake2s_update_vector_64 (&ctx->opad, b0, b1, b2, b3, 64); +} + + +DECLSPEC void blake2s_hmac_init_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w, const int len) +{ + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + if (len > 64) + { + blake2s_ctx_vector_t tmp; + + blake2s_init_vector (&tmp); + + blake2s_update_vector (&tmp, w, len); + + blake2s_final_vector (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = tmp.h[5]; + w1[2] = tmp.h[6]; + w1[3] = tmp.h[7]; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } + else + { + w0[0] = w[ 0]; + w0[1] = w[ 1]; + w0[2] = w[ 2]; + w0[3] = w[ 3]; + w1[0] = w[ 4]; + w1[1] = w[ 5]; + w1[2] = w[ 6]; + w1[3] = w[ 7]; + w2[0] = w[ 8]; + w2[1] = w[ 9]; + w2[2] = w[10]; + w2[3] = w[11]; + w3[0] = w[12]; + w3[1] = w[13]; + w3[2] = w[14]; + w3[3] = w[15]; + } + + blake2s_hmac_init_vector_64 (ctx, w0, w1, w2, w3); +} + +DECLSPEC void blake2s_hmac_update_vector_64 (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, const int len) +{ + blake2s_update_vector_64 (&ctx->ipad, w0, w1, w2, w3, len); +} + +DECLSPEC void blake2s_hmac_update_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w, const int len) +{ + blake2s_update_vector (&ctx->ipad, w, len); +} + +DECLSPEC void blake2s_hmac_final_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx) +{ + + blake2s_final_vector (&ctx->ipad); + + for (int n = 0; n < 8; n += 1) + { + blake2s_update_vector(&ctx->opad, &ctx->ipad.h[n], 4); + } + + ctx->opad.m[8] = 0; + ctx->opad.m[9] = 0; + ctx->opad.m[10]= 0; + ctx->opad.m[11]= 0; + ctx->opad.m[12]= 0; + ctx->opad.m[13]= 0; + ctx->opad.m[14]= 0; + ctx->opad.m[15]= 0; + + blake2s_final_vector (&ctx->opad); +} diff --git a/OpenCL/inc_hash_blake2s.h b/OpenCL/inc_hash_blake2s.h index 63f2942f1..9a13a59c7 100644 --- a/OpenCL/inc_hash_blake2s.h +++ b/OpenCL/inc_hash_blake2s.h @@ -72,6 +72,14 @@ typedef struct blake2s_ctx } blake2s_ctx_t; +typedef struct blake2s_hmac_ctx +{ + blake2s_ctx_t ipad; + blake2s_ctx_t opad; + +} blake2s_hmac_ctx_t; + + typedef struct blake2s_ctx_vector { u32x m[16]; // buffer @@ -81,16 +89,45 @@ typedef struct blake2s_ctx_vector } blake2s_ctx_vector_t; +typedef struct blake2s_hmac_ctx_vector +{ + blake2s_ctx_vector_t ipad; + blake2s_ctx_vector_t opad; + +} blake2s_hmac_ctx_vector_t; + + + + DECLSPEC void blake2s_transform (PRIVATE_AS u32 *h, PRIVATE_AS const u32 *m, const int len, const u32 f0); DECLSPEC void blake2s_init (PRIVATE_AS blake2s_ctx_t *ctx); DECLSPEC void blake2s_update (PRIVATE_AS blake2s_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len); DECLSPEC void blake2s_update_global (PRIVATE_AS blake2s_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); +DECLSPEC void blake2s_update_global_swap (PRIVATE_AS blake2s_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); DECLSPEC void blake2s_final (PRIVATE_AS blake2s_ctx_t *ctx); +DECLSPEC void blake2s_hmac_init_64 (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1, PRIVATE_AS const u32 *w2, PRIVATE_AS const u32 *w3); +DECLSPEC void blake2s_hmac_init (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_init_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_init_global (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_init_global_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_update_64 (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const int len); +DECLSPEC void blake2s_hmac_update (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_update_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, PRIVATE_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_update_global (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_update_global_swap (PRIVATE_AS blake2s_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); +DECLSPEC void blake2s_hmac_final (PRIVATE_AS blake2s_hmac_ctx_t *ctx); + DECLSPEC void blake2s_transform_vector (PRIVATE_AS u32x *h, PRIVATE_AS const u32x *m, const u32x len, const u32 f0); DECLSPEC void blake2s_init_vector (PRIVATE_AS blake2s_ctx_vector_t *ctx); DECLSPEC void blake2s_init_vector_from_scalar (PRIVATE_AS blake2s_ctx_vector_t *ctx, PRIVATE_AS blake2s_ctx_t *ctx0); DECLSPEC void blake2s_update_vector (PRIVATE_AS blake2s_ctx_vector_t *ctx, PRIVATE_AS const u32x *w, const int len); DECLSPEC void blake2s_final_vector (PRIVATE_AS blake2s_ctx_vector_t *ctx); +DECLSPEC void blake2s_hmac_init_vector_64 (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w0, PRIVATE_AS const u32x *w1, PRIVATE_AS const u32x *w2, PRIVATE_AS const u32x *w3); +DECLSPEC void blake2s_hmac_init_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w, const int len); +DECLSPEC void blake2s_hmac_update_vector_64 (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, const int len); +DECLSPEC void blake2s_hmac_update_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx, PRIVATE_AS const u32x *w, const int len); +DECLSPEC void blake2s_hmac_final_vector (PRIVATE_AS blake2s_hmac_ctx_vector_t *ctx); + #endif // INC_HASH_BLAKE2S_H diff --git a/OpenCL/m67890_a0-pure.cl b/OpenCL/m67890_a0-pure.cl new file mode 100644 index 000000000..b32d7a7cf --- /dev/null +++ b/OpenCL/m67890_a0-pure.cl @@ -0,0 +1,135 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_blake2s.cl) +#endif + +KERNEL_FQ void m67890_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + blake2s_hmac_ctx_t ctx; + + blake2s_hmac_init (&ctx, tmp.i, tmp.pw_len); + + blake2s_hmac_update (&ctx, s, salt_len); + + blake2s_hmac_final (&ctx); + + const u32 r0 = ctx.opad.h[DGST_R0]; + const u32 r1 = ctx.opad.h[DGST_R1]; + const u32 r2 = ctx.opad.h[DGST_R2]; + const u32 r3 = ctx.opad.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m67890_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + blake2s_hmac_ctx_t ctx; + + blake2s_hmac_init (&ctx, tmp.i, tmp.pw_len); + + blake2s_hmac_update (&ctx, s, salt_len); + + blake2s_hmac_final (&ctx); + + const u32 r0 = ctx.opad.h[DGST_R0]; + const u32 r1 = ctx.opad.h[DGST_R1]; + const u32 r2 = ctx.opad.h[DGST_R2]; + const u32 r3 = ctx.opad.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m67890_a1-pure.cl b/OpenCL/m67890_a1-pure.cl new file mode 100644 index 000000000..04f023d61 --- /dev/null +++ b/OpenCL/m67890_a1-pure.cl @@ -0,0 +1,183 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_blake2s.cl) +#endif + +KERNEL_FQ void m67890_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32 w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = combs_buf[il_pos].i[idx]; + } + + switch_buffer_by_offset_1x64_le_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + blake2s_hmac_ctx_t ctx; + + blake2s_hmac_init (&ctx, c, pw_len + comb_len); + + blake2s_hmac_update (&ctx, s, salt_len); + + blake2s_hmac_final (&ctx); + + const u32 r0 = ctx.opad.h[DGST_R0]; + const u32 r1 = ctx.opad.h[DGST_R1]; + const u32 r2 = ctx.opad.h[DGST_R2]; + const u32 r3 = ctx.opad.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m67890_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32 w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + const u32 comb_len = combs_buf[il_pos].pw_len; + + u32 c[64]; + + #ifdef _unroll + #pragma unroll + #endif + for (int idx = 0; idx < 64; idx++) + { + c[idx] = combs_buf[il_pos].i[idx]; + } + + switch_buffer_by_offset_1x64_le_S (c, pw_len); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 64; i++) + { + c[i] |= w[i]; + } + + blake2s_hmac_ctx_t ctx; + + blake2s_hmac_init (&ctx, c, pw_len + comb_len); + + blake2s_hmac_update (&ctx, s, salt_len); + + blake2s_hmac_final (&ctx); + + const u32 r0 = ctx.opad.h[DGST_R0]; + const u32 r1 = ctx.opad.h[DGST_R1]; + const u32 r2 = ctx.opad.h[DGST_R2]; + const u32 r3 = ctx.opad.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m67890_a3-pure.cl b/OpenCL/m67890_a3-pure.cl new file mode 100644 index 000000000..8e39f0a60 --- /dev/null +++ b/OpenCL/m67890_a3-pure.cl @@ -0,0 +1,156 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_blake2s.cl) +#endif + +KERNEL_FQ void m67890_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + blake2s_hmac_ctx_vector_t ctx; + + blake2s_hmac_init_vector (&ctx, w, pw_len); + + blake2s_hmac_update_vector (&ctx, s, salt_len); + + blake2s_hmac_final_vector (&ctx); + + const u32x r0 = ctx.opad.h[DGST_R0]; + const u32x r1 = ctx.opad.h[DGST_R1]; + const u32x r2 = ctx.opad.h[DGST_R2]; + const u32x r3 = ctx.opad.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m67890_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + blake2s_hmac_ctx_vector_t ctx; + + blake2s_hmac_init_vector (&ctx, w, pw_len); + + blake2s_hmac_update_vector (&ctx, s, salt_len); + + blake2s_hmac_final_vector (&ctx); + + const u32x r0 = ctx.opad.h[DGST_R0]; + const u32x r1 = ctx.opad.h[DGST_R1]; + const u32x r2 = ctx.opad.h[DGST_R2]; + const u32x r3 = ctx.opad.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } + +} From 3268b58e2417b1e240743f47bc355a91b8e2b562 Mon Sep 17 00:00:00 2001 From: Andreas Vikerup Date: Tue, 15 Apr 2025 16:25:53 +0200 Subject: [PATCH 089/357] add module 20713 - sha256(sha256(pass+salt)) --- OpenCL/m20713_a0-pure.cl | 253 +++++++++++++++++++++++++++++++++ OpenCL/m20713_a1-pure.cl | 257 +++++++++++++++++++++++++++++++++ OpenCL/m20713_a3-pure.cl | 283 +++++++++++++++++++++++++++++++++++++ src/modules/module_20713.c | 260 ++++++++++++++++++++++++++++++++++ 4 files changed, 1053 insertions(+) create mode 100644 OpenCL/m20713_a0-pure.cl create mode 100644 OpenCL/m20713_a1-pure.cl create mode 100644 OpenCL/m20713_a3-pure.cl create mode 100644 src/modules/module_20713.c diff --git a/OpenCL/m20713_a0-pure.cl b/OpenCL/m20713_a0-pure.cl new file mode 100644 index 000000000..f0929bc49 --- /dev/null +++ b/OpenCL/m20713_a0-pure.cl @@ -0,0 +1,253 @@ +/** + * Author......: Andreas Vikerup @ Shelltrail + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20713_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx0; + sha256_init (&ctx0); + sha256_update_swap (&ctx0, tmp.i, tmp.pw_len); + sha256_update (&ctx0, s, salt_len); + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20713_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx0; + sha256_init (&ctx0); + sha256_update_swap (&ctx0, tmp.i, tmp.pw_len); + sha256_update (&ctx0, s, salt_len); + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m20713_a1-pure.cl b/OpenCL/m20713_a1-pure.cl new file mode 100644 index 000000000..97482e3f9 --- /dev/null +++ b/OpenCL/m20713_a1-pure.cl @@ -0,0 +1,257 @@ +/** + * Author......: Andreas Vikerup @ Shelltrail + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20713_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 s[64] = { 0 }; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha256_ctx_t ctx1; + + sha256_init (&ctx1); + + sha256_update_global_swap (&ctx1, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha256_ctx_t ctx0 = ctx1; + + sha256_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + sha256_update (&ctx0, s, salt_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20713_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha256_ctx_t ctx1; + + sha256_init (&ctx1); + + sha256_update_global_swap (&ctx1, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha256_ctx_t ctx0 = ctx1; + + sha256_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + sha256_update (&ctx0, s, salt_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m20713_a3-pure.cl b/OpenCL/m20713_a3-pure.cl new file mode 100644 index 000000000..988d063cd --- /dev/null +++ b/OpenCL/m20713_a3-pure.cl @@ -0,0 +1,283 @@ +/** + * Author......: Andreas Vikerup @ Shelltrail + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20713_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx0; + + sha256_init_vector (&ctx0); + + sha256_update_vector (&ctx0, w, pw_len); + sha256_update_vector (&ctx0, s, salt_len); + + sha256_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + const u32x f = ctx0.h[5]; + const u32x g = ctx0.h[6]; + const u32x h = ctx0.h[7]; + + sha256_ctx_vector_t ctx; + + sha256_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + _w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + _w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + _w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + _w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + _w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + _w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + _w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + _w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + _w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + _w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + _w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + _w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + _w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + _w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + _w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 64); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20713_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx0; + + sha256_init_vector (&ctx0); + + sha256_update_vector (&ctx0, w, pw_len); + sha256_update_vector (&ctx0, s, salt_len); + + sha256_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + const u32x f = ctx0.h[5]; + const u32x g = ctx0.h[6]; + const u32x h = ctx0.h[7]; + + sha256_ctx_vector_t ctx; + + sha256_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + _w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + _w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + _w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + _w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + _w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + _w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + _w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + _w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + _w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + _w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + _w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + _w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + _w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + _w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + _w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 64); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/src/modules/module_20713.c b/src/modules/module_20713.c new file mode 100644 index 000000000..f3ce41883 --- /dev/null +++ b/src/modules/module_20713.c @@ -0,0 +1,260 @@ +/** + * Author......: Andreas Vikerup @ Shelltrail + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "sha256(sha256($pass.$salt))"; +static const u64 KERN_TYPE = 20713; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "ad66bdc0841d7e08d96c03de271ce14e77de078746b535adbf9d4b6ccbf2a517:7218532375810603"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_size (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 DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +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; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + u32 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); + tmp[7] = byte_swap_32 (tmp[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[4], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[5], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[6], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[7], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} From 6568c5988b9aef2c60fb3e87afc96c7de1c96d9f Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 18 Apr 2025 14:17:21 +0200 Subject: [PATCH 090/357] fix #3914 --- src/backend.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend.c b/src/backend.c index f7c916e1d..28361cca2 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1462,11 +1462,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, device_param->kernel_param.loop_pos = loops_pos; device_param->kernel_param.loop_cnt = loops_cnt; + int aux_cnt = 0; + if (hashconfig->opts_type & OPTS_TYPE_AUX1) { if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX1, pws_pos, pws_cnt, false, 0) == -1) return -1; if (status_ctx->run_thread_level2 == false) break; + + aux_cnt++; } if (hashconfig->opts_type & OPTS_TYPE_AUX2) @@ -1474,6 +1478,8 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX2, pws_pos, pws_cnt, false, 0) == -1) return -1; if (status_ctx->run_thread_level2 == false) break; + + aux_cnt++; } if (hashconfig->opts_type & OPTS_TYPE_AUX3) @@ -1481,6 +1487,8 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX3, pws_pos, pws_cnt, false, 0) == -1) return -1; if (status_ctx->run_thread_level2 == false) break; + + aux_cnt++; } if (hashconfig->opts_type & OPTS_TYPE_AUX4) @@ -1488,6 +1496,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX4, pws_pos, pws_cnt, false, 0) == -1) return -1; if (status_ctx->run_thread_level2 == false) break; + + aux_cnt++; + } + + if (aux_cnt == 0) + { + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_pos, pws_cnt, false, 0) == -1) return -1; + + if (status_ctx->run_thread_level2 == false) break; } } } From 16d117d47080b83b553a4575eadaa2a554bd9a7f Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 18 Apr 2025 14:53:52 +0200 Subject: [PATCH 091/357] update zlib to 1.3.1, commit 5a82f71 --- deps/zlib/.cmake-format.yaml | 245 + deps/zlib/.github/workflows/c-std.yml | 230 + deps/zlib/.github/workflows/cmake.yml | 112 + deps/zlib/.github/workflows/configure.yml | 136 + deps/zlib/.github/workflows/fuzz.yml | 25 + deps/zlib/.github/workflows/msys-cygwin.yml | 77 + deps/zlib/.gitignore | 51 + deps/zlib/BUILD.bazel | 134 + deps/zlib/CMakeLists.txt | 443 +- deps/zlib/ChangeLog | 218 +- deps/zlib/FAQ | 7 +- deps/zlib/LICENSE | 22 + deps/zlib/MODULE.bazel | 9 + deps/zlib/Makefile.in | 89 +- deps/zlib/README | 26 +- deps/zlib/README-cmake.md | 83 + deps/zlib/adler32.c | 32 +- deps/zlib/compress.c | 21 +- deps/zlib/configure | 227 +- deps/zlib/contrib/README.contrib | 23 +- deps/zlib/contrib/ada/readme.txt | 6 +- deps/zlib/contrib/ada/test.adb | 4 +- deps/zlib/contrib/ada/zlib-streams.ads | 2 +- deps/zlib/contrib/ada/zlib-thin.adb | 3 +- deps/zlib/contrib/ada/zlib.adb | 2 +- deps/zlib/contrib/ada/zlib.ads | 2 +- deps/zlib/contrib/amd64/amd64-match.S | 452 - deps/zlib/contrib/asm686/README.686 | 51 - deps/zlib/contrib/asm686/match.S | 357 - deps/zlib/contrib/blast/blast.h | 2 +- deps/zlib/contrib/delphi/ZLib.pas | 2 +- .../contrib/dotzlib/DotZLib/ChecksumImpl.cs | 4 +- .../zlib/contrib/dotzlib/DotZLib/CodecBase.cs | 4 +- .../contrib/dotzlib/DotZLib/GZipStream.cs | 6 +- .../zlib/contrib/dotzlib/DotZLib/UnitTests.cs | 2 +- deps/zlib/contrib/dotzlib/readme.txt | 2 +- deps/zlib/contrib/gcc_gvmat64/gvmat64.S | 1148 +- deps/zlib/contrib/infback9/infback9.c | 48 +- deps/zlib/contrib/infback9/infback9.h | 16 +- deps/zlib/contrib/infback9/inftree9.c | 17 +- deps/zlib/contrib/infback9/inftree9.h | 12 +- deps/zlib/contrib/inflate86/inffas86.c | 1157 -- deps/zlib/contrib/inflate86/inffast.S | 1368 --- deps/zlib/contrib/iostream3/zfstream.h | 4 +- deps/zlib/contrib/masmx64/bld_ml64.bat | 2 - deps/zlib/contrib/masmx64/gvmat64.asm | 553 - deps/zlib/contrib/masmx64/inffas8664.c | 186 - deps/zlib/contrib/masmx64/inffasx64.asm | 396 - deps/zlib/contrib/masmx64/readme.txt | 31 - deps/zlib/contrib/masmx86/bld_ml32.bat | 2 - deps/zlib/contrib/masmx86/inffas32.asm | 1080 -- deps/zlib/contrib/masmx86/match686.asm | 479 - deps/zlib/contrib/masmx86/readme.txt | 27 - deps/zlib/contrib/minizip/CMakeLists.txt | 380 + deps/zlib/contrib/minizip/Makefile | 28 +- .../contrib/minizip/MiniZip64_Changes.txt | 2 +- deps/zlib/contrib/minizip/configure.ac | 4 +- deps/zlib/contrib/minizip/crypt.h | 29 +- deps/zlib/contrib/minizip/ints.h | 57 + deps/zlib/contrib/minizip/ioapi.c | 80 +- deps/zlib/contrib/minizip/ioapi.h | 81 +- deps/zlib/contrib/minizip/iowin32.c | 88 +- deps/zlib/contrib/minizip/iowin32.h | 8 +- deps/zlib/contrib/minizip/make_vms.com | 2 +- deps/zlib/contrib/minizip/miniunz.c | 117 +- deps/zlib/contrib/minizip/minizip.c | 98 +- deps/zlib/contrib/minizip/minizip.pc.in | 2 +- deps/zlib/contrib/minizip/minizip.pc.txt | 13 + .../contrib/minizip/minizipConfig.cmake.in | 35 + deps/zlib/contrib/minizip/mztools.c | 73 +- deps/zlib/contrib/minizip/skipset.h | 361 + deps/zlib/contrib/minizip/test/CMakeLists.txt | 121 + .../add_subdirectory_exclude_test.cmake.in | 29 + .../test/add_subdirectory_test.cmake.in | 28 + .../minizip/test/find_package_test.cmake.in | 25 + deps/zlib/contrib/minizip/test/test_helper.cm | 32 + deps/zlib/contrib/minizip/unzip.c | 580 +- deps/zlib/contrib/minizip/unzip.h | 152 +- deps/zlib/contrib/minizip/zip.c | 690 +- deps/zlib/contrib/minizip/zip.h | 322 +- deps/zlib/contrib/nuget/nuget.csproj | 43 + deps/zlib/contrib/nuget/nuget.sln | 22 + deps/zlib/contrib/pascal/zlibpas.pas | 2 +- deps/zlib/contrib/puff/README | 2 +- deps/zlib/contrib/puff/puff.c | 12 +- deps/zlib/contrib/puff/pufftest.c | 6 +- deps/zlib/contrib/testzlib/testzlib.c | 2 +- deps/zlib/contrib/untgz/untgz.c | 63 +- deps/zlib/contrib/vstudio/readme.txt | 159 +- .../vstudio/vc10/miniunz.vcxproj.filters | 2 +- .../vstudio/vc10/minizip.vcxproj.filters | 2 +- .../contrib/vstudio/vc10/testzlib.vcxproj | 24 +- .../vstudio/vc10/testzlib.vcxproj.filters | 5 +- .../vstudio/vc10/testzlibdll.vcxproj.filters | 2 +- deps/zlib/contrib/vstudio/vc10/zlib.rc | 8 +- .../contrib/vstudio/vc10/zlibstat.vcxproj | 50 +- .../vstudio/vc10/zlibstat.vcxproj.filters | 3 - deps/zlib/contrib/vstudio/vc10/zlibvc.def | 10 +- deps/zlib/contrib/vstudio/vc10/zlibvc.vcxproj | 58 +- .../vstudio/vc10/zlibvc.vcxproj.filters | 3 - .../contrib/vstudio/vc11/testzlib.vcxproj | 24 +- deps/zlib/contrib/vstudio/vc11/zlib.rc | 8 +- .../contrib/vstudio/vc11/zlibstat.vcxproj | 34 +- deps/zlib/contrib/vstudio/vc11/zlibvc.def | 10 +- deps/zlib/contrib/vstudio/vc11/zlibvc.vcxproj | 58 +- .../contrib/vstudio/vc12/testzlib.vcxproj | 24 +- deps/zlib/contrib/vstudio/vc12/zlib.rc | 8 +- .../contrib/vstudio/vc12/zlibstat.vcxproj | 34 +- deps/zlib/contrib/vstudio/vc12/zlibvc.def | 10 +- deps/zlib/contrib/vstudio/vc12/zlibvc.vcxproj | 58 +- .../contrib/vstudio/vc14/testzlib.vcxproj | 24 +- deps/zlib/contrib/vstudio/vc14/zlib.rc | 8 +- .../contrib/vstudio/vc14/zlibstat.vcxproj | 34 +- deps/zlib/contrib/vstudio/vc14/zlibvc.def | 10 +- deps/zlib/contrib/vstudio/vc14/zlibvc.vcxproj | 58 +- .../zlib/contrib/vstudio/vc17/miniunz.vcxproj | 409 + .../zlib/contrib/vstudio/vc17/minizip.vcxproj | 405 + .../contrib/vstudio/vc17/testzlib.vcxproj | 473 + .../contrib/vstudio/vc17/testzlibdll.vcxproj | 409 + deps/zlib/contrib/vstudio/vc17/zlib.rc | 32 + .../contrib/vstudio/vc17/zlibstat.vcxproj | 602 + deps/zlib/contrib/vstudio/vc17/zlibvc.def | 161 + deps/zlib/contrib/vstudio/vc17/zlibvc.sln | 179 + deps/zlib/contrib/vstudio/vc17/zlibvc.vcxproj | 875 ++ deps/zlib/contrib/vstudio/vc9/miniunz.vcproj | 2 +- deps/zlib/contrib/vstudio/vc9/minizip.vcproj | 2 +- deps/zlib/contrib/vstudio/vc9/testzlib.vcproj | 66 +- .../contrib/vstudio/vc9/testzlibdll.vcproj | 2 +- deps/zlib/contrib/vstudio/vc9/zlib.rc | 8 +- deps/zlib/contrib/vstudio/vc9/zlibstat.vcproj | 76 +- deps/zlib/contrib/vstudio/vc9/zlibvc.def | 10 +- deps/zlib/contrib/vstudio/vc9/zlibvc.vcproj | 82 +- deps/zlib/crc32.c | 1283 ++- deps/zlib/crc32.h | 9877 ++++++++++++++++- deps/zlib/deflate.c | 909 +- deps/zlib/deflate.h | 77 +- deps/zlib/doc/algorithm.txt | 2 +- deps/zlib/doc/crc-doc.1.0.pdf | Bin 0 -> 776142 bytes deps/zlib/doc/txtvsbin.txt | 12 +- deps/zlib/examples/README.examples | 5 + deps/zlib/examples/enough.c | 735 +- deps/zlib/examples/fitblk.c | 6 +- deps/zlib/examples/gun.c | 20 +- deps/zlib/examples/gzappend.c | 6 +- deps/zlib/examples/gzlog.c | 13 +- deps/zlib/examples/gzlog.h | 2 +- deps/zlib/examples/gznorm.c | 474 + deps/zlib/examples/zlib_how.html | 26 +- deps/zlib/examples/zpipe.c | 4 + deps/zlib/examples/zran.c | 775 +- deps/zlib/examples/zran.h | 53 + deps/zlib/gzclose.c | 4 +- deps/zlib/gzguts.h | 91 +- deps/zlib/gzlib.c | 146 +- deps/zlib/gzread.c | 109 +- deps/zlib/gzwrite.c | 118 +- deps/zlib/infback.c | 76 +- deps/zlib/inffast.c | 41 +- deps/zlib/inffast.h | 2 +- deps/zlib/inflate.c | 229 +- deps/zlib/inflate.h | 7 +- deps/zlib/inftrees.c | 17 +- deps/zlib/inftrees.h | 12 +- deps/zlib/make_vms.com | 4 +- deps/zlib/msdos/Makefile.dj2 | 2 +- deps/zlib/old/Makefile.riscos | 2 +- deps/zlib/old/visual-basic.txt | 2 +- deps/zlib/os400/README400 | 6 +- deps/zlib/os400/bndsrc | 14 + deps/zlib/os400/zlib.inc | 14 +- deps/zlib/qnx/package.qpg | 12 +- deps/zlib/test/CMakeLists.txt | 265 + .../add_subdirectory_exclude_test.cmake.in | 29 + deps/zlib/test/add_subdirectory_test.cmake.in | 28 + deps/zlib/test/example.c | 120 +- deps/zlib/test/find_package_test.cmake.in | 26 + deps/zlib/test/infcover.c | 15 +- deps/zlib/test/minigzip.c | 253 +- deps/zlib/treebuild.xml | 4 +- deps/zlib/trees.c | 678 +- deps/zlib/uncompr.c | 16 +- deps/zlib/win32/DLL_FAQ.txt | 22 +- deps/zlib/win32/Makefile.bor | 1 - deps/zlib/win32/Makefile.gcc | 7 +- deps/zlib/win32/Makefile.msc | 4 - deps/zlib/win32/README-WIN32.txt | 8 +- deps/zlib/win32/zlib.def | 4 + deps/zlib/win32/zlib1.rc | 7 +- deps/zlib/zconf.h | 60 +- deps/zlib/zconf.h.cmakein | 536 - deps/zlib/zconf.h.in | 60 +- deps/zlib/zlib.3 | 8 +- deps/zlib/zlib.3.pdf | Bin 19318 -> 25523 bytes deps/zlib/zlib.h | 641 +- deps/zlib/zlib.map | 198 +- deps/zlib/zlib.pc.cmakein | 8 +- deps/zlib/zlib2ansi | 152 - deps/zlib/zlibConfig.cmake.in | 26 + deps/zlib/zutil.c | 66 +- deps/zlib/zutil.h | 76 +- 200 files changed, 22714 insertions(+), 13538 deletions(-) create mode 100644 deps/zlib/.cmake-format.yaml create mode 100644 deps/zlib/.github/workflows/c-std.yml create mode 100644 deps/zlib/.github/workflows/cmake.yml create mode 100644 deps/zlib/.github/workflows/configure.yml create mode 100644 deps/zlib/.github/workflows/fuzz.yml create mode 100644 deps/zlib/.github/workflows/msys-cygwin.yml create mode 100644 deps/zlib/.gitignore create mode 100644 deps/zlib/BUILD.bazel create mode 100644 deps/zlib/LICENSE create mode 100644 deps/zlib/MODULE.bazel create mode 100644 deps/zlib/README-cmake.md delete mode 100644 deps/zlib/contrib/amd64/amd64-match.S delete mode 100644 deps/zlib/contrib/asm686/README.686 delete mode 100644 deps/zlib/contrib/asm686/match.S delete mode 100644 deps/zlib/contrib/inflate86/inffas86.c delete mode 100644 deps/zlib/contrib/inflate86/inffast.S delete mode 100644 deps/zlib/contrib/masmx64/bld_ml64.bat delete mode 100644 deps/zlib/contrib/masmx64/gvmat64.asm delete mode 100644 deps/zlib/contrib/masmx64/inffas8664.c delete mode 100644 deps/zlib/contrib/masmx64/inffasx64.asm delete mode 100644 deps/zlib/contrib/masmx64/readme.txt delete mode 100644 deps/zlib/contrib/masmx86/bld_ml32.bat delete mode 100644 deps/zlib/contrib/masmx86/inffas32.asm delete mode 100644 deps/zlib/contrib/masmx86/match686.asm delete mode 100644 deps/zlib/contrib/masmx86/readme.txt create mode 100644 deps/zlib/contrib/minizip/CMakeLists.txt create mode 100644 deps/zlib/contrib/minizip/ints.h create mode 100644 deps/zlib/contrib/minizip/minizip.pc.txt create mode 100644 deps/zlib/contrib/minizip/minizipConfig.cmake.in create mode 100644 deps/zlib/contrib/minizip/skipset.h create mode 100644 deps/zlib/contrib/minizip/test/CMakeLists.txt create mode 100644 deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in create mode 100644 deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in create mode 100644 deps/zlib/contrib/minizip/test/find_package_test.cmake.in create mode 100644 deps/zlib/contrib/minizip/test/test_helper.cm create mode 100644 deps/zlib/contrib/nuget/nuget.csproj create mode 100644 deps/zlib/contrib/nuget/nuget.sln create mode 100644 deps/zlib/contrib/vstudio/vc17/miniunz.vcxproj create mode 100644 deps/zlib/contrib/vstudio/vc17/minizip.vcxproj create mode 100644 deps/zlib/contrib/vstudio/vc17/testzlib.vcxproj create mode 100644 deps/zlib/contrib/vstudio/vc17/testzlibdll.vcxproj create mode 100644 deps/zlib/contrib/vstudio/vc17/zlib.rc create mode 100644 deps/zlib/contrib/vstudio/vc17/zlibstat.vcxproj create mode 100644 deps/zlib/contrib/vstudio/vc17/zlibvc.def create mode 100644 deps/zlib/contrib/vstudio/vc17/zlibvc.sln create mode 100644 deps/zlib/contrib/vstudio/vc17/zlibvc.vcxproj create mode 100644 deps/zlib/doc/crc-doc.1.0.pdf create mode 100644 deps/zlib/examples/gznorm.c create mode 100644 deps/zlib/examples/zran.h create mode 100644 deps/zlib/test/CMakeLists.txt create mode 100644 deps/zlib/test/add_subdirectory_exclude_test.cmake.in create mode 100644 deps/zlib/test/add_subdirectory_test.cmake.in create mode 100644 deps/zlib/test/find_package_test.cmake.in delete mode 100644 deps/zlib/zconf.h.cmakein delete mode 100755 deps/zlib/zlib2ansi create mode 100644 deps/zlib/zlibConfig.cmake.in diff --git a/deps/zlib/.cmake-format.yaml b/deps/zlib/.cmake-format.yaml new file mode 100644 index 000000000..9c554da15 --- /dev/null +++ b/deps/zlib/.cmake-format.yaml @@ -0,0 +1,245 @@ +_help_parse: Options affecting listfile parsing +parse: + _help_additional_commands: + - Specify structure for custom cmake functions + additional_commands: + foo: + flags: + - BAR + - BAZ + kwargs: + HEADERS: '*' + SOURCES: '*' + DEPENDS: '*' + _help_override_spec: + - Override configurations per-command where available + override_spec: {} + _help_vartags: + - Specify variable tags. + vartags: [] + _help_proptags: + - Specify property tags. + proptags: [] +_help_format: Options affecting formatting. +format: + _help_disable: + - Disable formatting entirely, making cmake-format a no-op + disable: false + _help_line_width: + - How wide to allow formatted cmake files + line_width: 80 + _help_tab_size: + - How many spaces to tab for indent + tab_size: 4 + _help_use_tabchars: + - If true, lines are indented using tab characters (utf-8 + - 0x09) instead of space characters (utf-8 0x20). + - In cases where the layout would require a fractional tab + - character, the behavior of the fractional indentation is + - governed by + use_tabchars: false + _help_fractional_tab_policy: + - If is True, then the value of this variable + - indicates how fractional indentions are handled during + - whitespace replacement. If set to 'use-space', fractional + - indentation is left as spaces (utf-8 0x20). If set to + - '`round-up` fractional indentation is replaced with a single' + - tab character (utf-8 0x09) effectively shifting the column + - to the next tabstop + fractional_tab_policy: use-space + _help_max_subgroups_hwrap: + - If an argument group contains more than this many sub-groups + - (parg or kwarg groups) then force it to a vertical layout. + max_subgroups_hwrap: 2 + _help_max_pargs_hwrap: + - If a positional argument group contains more than this many + - arguments, then force it to a vertical layout. + max_pargs_hwrap: 6 + _help_max_rows_cmdline: + - If a cmdline positional group consumes more than this many + - lines without nesting, then invalidate the layout (and nest) + max_rows_cmdline: 2 + _help_separate_ctrl_name_with_space: + - If true, separate flow control names from their parentheses + - with a space + separate_ctrl_name_with_space: false + _help_separate_fn_name_with_space: + - If true, separate function names from parentheses with a + - space + separate_fn_name_with_space: false + _help_dangle_parens: + - If a statement is wrapped to more than one line, than dangle + - the closing parenthesis on its own line. + dangle_parens: false + _help_dangle_align: + - If the trailing parenthesis must be 'dangled' on its on + - 'line, then align it to this reference: `prefix`: the start' + - 'of the statement, `prefix-indent`: the start of the' + - 'statement, plus one indentation level, `child`: align to' + - the column of the arguments + dangle_align: prefix + _help_min_prefix_chars: + - If the statement spelling length (including space and + - parenthesis) is smaller than this amount, then force reject + - nested layouts. + min_prefix_chars: 4 + _help_max_prefix_chars: + - If the statement spelling length (including space and + - parenthesis) is larger than the tab width by more than this + - amount, then force reject un-nested layouts. + max_prefix_chars: 10 + _help_max_lines_hwrap: + - If a candidate layout is wrapped horizontally but it exceeds + - this many lines, then reject the layout. + max_lines_hwrap: 2 + _help_line_ending: + - What style line endings to use in the output. + line_ending: unix + _help_command_case: + - Format command names consistently as 'lower' or 'upper' case + command_case: canonical + _help_keyword_case: + - Format keywords consistently as 'lower' or 'upper' case + keyword_case: unchanged + _help_always_wrap: + - A list of command names which should always be wrapped + always_wrap: [] + _help_enable_sort: + - If true, the argument lists which are known to be sortable + - will be sorted lexicographicall + enable_sort: true + _help_autosort: + - If true, the parsers may infer whether or not an argument + - list is sortable (without annotation). + autosort: false + _help_require_valid_layout: + - By default, if cmake-format cannot successfully fit + - everything into the desired linewidth it will apply the + - last, most aggressive attempt that it made. If this flag is + - True, however, cmake-format will print error, exit with non- + - zero status code, and write-out nothing + require_valid_layout: false + _help_layout_passes: + - A dictionary mapping layout nodes to a list of wrap + - decisions. See the documentation for more information. + layout_passes: {} +_help_markup: Options affecting comment reflow and formatting. +markup: + _help_bullet_char: + - What character to use for bulleted lists + bullet_char: '*' + _help_enum_char: + - What character to use as punctuation after numerals in an + - enumerated list + enum_char: . + _help_first_comment_is_literal: + - If comment markup is enabled, don't reflow the first comment + - block in each listfile. Use this to preserve formatting of + - your copyright/license statements. + first_comment_is_literal: false + _help_literal_comment_pattern: + - If comment markup is enabled, don't reflow any comment block + - which matches this (regex) pattern. Default is `None` + - (disabled). + literal_comment_pattern: null + _help_fence_pattern: + - Regular expression to match preformat fences in comments + - default= ``r'^\s*([`~]{3}[`~]*)(.*)$'`` + fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$ + _help_ruler_pattern: + - Regular expression to match rulers in comments default= + - '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``' + ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$ + _help_explicit_trailing_pattern: + - If a comment line matches starts with this pattern then it + - is explicitly a trailing comment for the preceding argument. + - Default is '#<' + explicit_trailing_pattern: '#<' + _help_hashruler_min_length: + - If a comment line starts with at least this many consecutive + - hash characters, then don't lstrip() them off. This allows + - for lazy hash rulers where the first hash char is not + - separated by space + hashruler_min_length: 10 + _help_canonicalize_hashrulers: + - If true, then insert a space between the first hash char and + - remaining hash chars in a hash ruler, and normalize its + - length to fill the column + canonicalize_hashrulers: true + _help_enable_markup: + - enable comment markup parsing and reflow + enable_markup: true +_help_lint: Options affecting the linter +lint: + _help_disabled_codes: + - a list of lint codes to disable + disabled_codes: [] + _help_function_pattern: + - regular expression pattern describing valid function names + function_pattern: '[0-9a-z_]+' + _help_macro_pattern: + - regular expression pattern describing valid macro names + macro_pattern: '[0-9A-Z_]+' + _help_global_var_pattern: + - regular expression pattern describing valid names for + - variables with global (cache) scope + global_var_pattern: '[A-Z][0-9A-Z_]+' + _help_internal_var_pattern: + - regular expression pattern describing valid names for + - variables with global scope (but internal semantic) + internal_var_pattern: _[A-Z][0-9A-Z_]+ + _help_local_var_pattern: + - regular expression pattern describing valid names for + - variables with local scope + local_var_pattern: '[a-z][a-z0-9_]+' + _help_private_var_pattern: + - regular expression pattern describing valid names for + - privatedirectory variables + private_var_pattern: _[0-9a-z_]+ + _help_public_var_pattern: + - regular expression pattern describing valid names for public + - directory variables + public_var_pattern: '[A-Z][0-9A-Z_]+' + _help_argument_var_pattern: + - regular expression pattern describing valid names for + - function/macro arguments and loop variables. + argument_var_pattern: '[a-z][a-z0-9_]+' + _help_keyword_pattern: + - regular expression pattern describing valid names for + - keywords used in functions or macros + keyword_pattern: '[A-Z][0-9A-Z_]+' + _help_max_conditionals_custom_parser: + - In the heuristic for C0201, how many conditionals to match + - within a loop in before considering the loop a parser. + max_conditionals_custom_parser: 2 + _help_min_statement_spacing: + - Require at least this many newlines between statements + min_statement_spacing: 1 + _help_max_statement_spacing: + - Require no more than this many newlines between statements + max_statement_spacing: 2 + max_returns: 6 + max_branches: 12 + max_arguments: 5 + max_localvars: 15 + max_statements: 50 +_help_encode: Options affecting file encoding +encode: + _help_emit_byteorder_mark: + - If true, emit the unicode byte-order mark (BOM) at the start + - of the file + emit_byteorder_mark: false + _help_input_encoding: + - Specify the encoding of the input file. Defaults to utf-8 + input_encoding: utf-8 + _help_output_encoding: + - Specify the encoding of the output file. Defaults to utf-8. + - Note that cmake only claims to support utf-8 so be careful + - when using anything else + output_encoding: utf-8 +_help_misc: Miscellaneous configurations options. +misc: + _help_per_command: + - A dictionary containing any per-command configuration + - overrides. Currently only `command_case` is supported. + per_command: {} diff --git a/deps/zlib/.github/workflows/c-std.yml b/deps/zlib/.github/workflows/c-std.yml new file mode 100644 index 000000000..a99cdb569 --- /dev/null +++ b/deps/zlib/.github/workflows/c-std.yml @@ -0,0 +1,230 @@ +name: C Standard + +# Compile with as many C standards as possible. +# The worflow is setup to fail on any compilation warnings. + +on: + workflow_dispatch: + push: + pull_request: + +jobs: + + main: + name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }} + runs-on: ${{ matrix.os.value }} + strategy: + fail-fast: false + matrix: + os: + - name: Linux + value: ubuntu-latest + + - name: MacOS + value: macos-latest + + - name: Windows + value: windows-latest + cmake-opt: -G Ninja + + compiler: + - gcc + - clang + + arch: + - name: 64-bit + tag: amd64 + compiler-opt: -m64 + cmake-opt: -A x64 + + - name: 32-bit + tag: i386 + compiler-opt: -m32 + cmake-opt: -A Win32 + + + builder: + - configure + - cmake + + std: + - name: c89 + value: c89 + + - name: gnu89 + value: gnu89 + + - name: c94 + value: iso9899:199409 + + - name: c99 + value: c99 + + - name: gnu99 + value: gnu99 + + - name: c11 + value: c11 + + - name: gnu11 + value: gnu11 + + - name: c17 + value: c17 + + - name: gnu17 + value: gnu17 + + - name: c2x + value: c2x + + - name: gnu2x + value: gnu2x + + exclude: + # Don't run 32-bit on MacOS + - { os: { name: MacOS }, + arch: { tag: i386 } } + + # Don't run configure on Windows + - { os: { name: Windows }, + builder: configure } + + # Don't run gcc 32-bit on Windows + - { os: { name: Windows }, + arch: { tag: i386 } } + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + with: + show-progress: 'false' + + - name: Install packages (Linux) + if: runner.os == 'Linux' && matrix.arch.tag == 'i386' + run: | + sudo apt-get update + sudo apt install gcc-multilib libc6-dev-i386-cross + + - name: Install packages (Windows) + if: runner.os == 'Windows' + run: | + choco install --no-progress ninja + + - name: Generate project files (configure) + if: matrix.builder == 'configure' + run: | + ./configure + env: + CC: ${{ matrix.compiler }} + CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra + + - name: Compile source code (configure) + if: matrix.builder == 'configure' + run: make -j2 + + - name: Run test cases (configure) + if: matrix.builder == 'configure' + run: | + make test + make cover + + - name: Generate project files (cmake) + if: matrix.builder == 'cmake' + run: | + cmake -S . -B ./build1 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_TESTING=OFF + env: + CC: ${{ matrix.compiler }} + CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra + + - name: Generate project files with tests (cmake) + if: matrix.builder == 'cmake' + run: | + cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF + env: + CC: ${{ matrix.compiler }} + CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Wall -Wextra + + - name: Compile source code (cmake) + if: matrix.builder == 'cmake' + run: cmake --build ./build1 --config Release + + - name: Compile source code with tests (cmake) + if: matrix.builder == 'cmake' + run: cmake --build ./build2 --config Release + + - name: Run test cases (cmake) + if: matrix.builder == 'cmake' + run: ctest ./build2 -C Release --output-on-failure --max-width 120 + + + msvc: + name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }} + runs-on: ${{ matrix.os.value }} + strategy: + fail-fast: false + matrix: + os: + - name: Windows + value: windows-latest + + compiler: + - cl + + arch: + - name: 32-bit + value: -A Win32 + + - name: 64-bit + value: -A x64 + + builder: + - cmake + + std: + - name: default + value: "" + + - name: C11 + value: /std:c11 + + - name: C17 + value: /std:c17 + + # not available on the runner yet + # - name: C20 + # value: /std:c20 + + - name: latest + value: /std:clatest + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + with: + show-progress: 'false' + + - name: Generate project files (cmake) + run: | + cmake -S . -B ./build1 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_TESTING=OFF + env: + CC: ${{ matrix.compiler }} + CFLAGS: /WX ${{ matrix.std.value }} + + - name: Generate project files with tests (cmake) + run: | + cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF + env: + CC: ${{ matrix.compiler }} + CFLAGS: ${{ matrix.std.value }} + + - name: Compile source code (cmake) + run: cmake --build ./build1 --config Release -v + + - name: Compile source code with tests(cmake) + run: cmake --build ./build2 --config Release -v + + - name: Run test cases (cmake) + run: ctest ./build2 -C Release --output-on-failure --max-width 120 diff --git a/deps/zlib/.github/workflows/cmake.yml b/deps/zlib/.github/workflows/cmake.yml new file mode 100644 index 000000000..25a3b8124 --- /dev/null +++ b/deps/zlib/.github/workflows/cmake.yml @@ -0,0 +1,112 @@ +name: CMake +on: [push, pull_request] +jobs: + ci-cmake: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu GCC + os: ubuntu-latest + compiler: gcc + cflags: -Wall -Wextra + pkgtgt: package package_source + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + - name: Ubuntu GCC -O3 + os: ubuntu-latest + compiler: gcc + cflags: -O3 -Wall -Wextra + pkgtgt: package package_source + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + - name: Ubuntu Clang + os: ubuntu-latest + compiler: clang + cflags: -Wall -Wextra + pkgtgt: package package_source + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + - name: Ubuntu Clang Debug + os: ubuntu-latest + compiler: clang + cflags: -Wall -Wextra + build-config: Debug + pkgtgt: package package_source + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + - name: Windows MSVC Win32 + os: windows-latest + compiler: cl + cflags: /W3 + cmake-args: -A Win32 + pkgtgt: PACKAGE + + - name: Windows MSVC Win64 + os: windows-latest + compiler: cl + cflags: /W3 + cmake-args: -A x64 -DMINIZIP_ENABLE_BZIP2=OFF + pkgtgt: PACKAGE + + - name: Windows GCC + os: windows-latest + compiler: gcc + cflags: -Wall -Wextra + cmake-args: -G Ninja -DMINIZIP_ENABLE_BZIP2=OFF + pkgtgt: package + + - name: macOS Clang + os: macos-latest + compiler: clang + cflags: -Wall -Wextra + pkgtgt: package + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + - name: macOS GCC + os: macos-latest + compiler: gcc-12 + cflags: -Wall -Wextra + pkgtgt: package + cmake-args: -DMINIZIP_ENABLE_BZIP2=ON + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install packages (Windows) + if: runner.os == 'Windows' + run: | + choco install --no-progress ninja + + - name: Install packages (Linux) + if: runner.os == 'Linux' + run: | + sudo apt install libbz2-dev + - name: Generate project files + run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON + env: + CC: ${{ matrix.compiler }} + CFLAGS: ${{ matrix.cflags }} + + - name: Compile source code + run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }} + + - name: Run test cases + run: ctest -C Release --output-on-failure --max-width 120 + working-directory: ../build + + - name: create packages + run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }} + + - name: Upload build errors + uses: actions/upload-artifact@v4 + if: failure() + with: + name: ${{ matrix.name }} (cmake) + path: | + ../build/CMakeFiles/CMakeOutput.log + ../build/CMakeFiles/CMakeError.log + retention-days: 7 diff --git a/deps/zlib/.github/workflows/configure.yml b/deps/zlib/.github/workflows/configure.yml new file mode 100644 index 000000000..f19272c72 --- /dev/null +++ b/deps/zlib/.github/workflows/configure.yml @@ -0,0 +1,136 @@ +name: Configure +on: [push, pull_request] +jobs: + ci-configure: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu GCC + os: ubuntu-latest + compiler: gcc + configure-args: --warn + + # Test out of source builds + - name: Ubuntu GCC OSB + os: ubuntu-latest + compiler: gcc + configure-args: --warn + build-dir: ../build + src-dir: ../zlib + + - name: Ubuntu GCC ARM SF + os: ubuntu-latest + compiler: arm-linux-gnueabi-gcc + configure-args: --warn + chost: arm-linux-gnueabi + packages: qemu-system qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross + qemu-run: qemu-arm -L /usr/arm-linux-gnueabi + + - name: Ubuntu GCC ARM HF + os: ubuntu-latest + compiler: arm-linux-gnueabihf-gcc + configure-args: --warn + chost: arm-linux-gnueabihf + packages: qemu-system qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross + qemu-run: qemu-arm -L /usr/arm-linux-gnueabihf + + - name: Ubuntu GCC AARCH64 + os: ubuntu-latest + compiler: aarch64-linux-gnu-gcc + configure-args: --warn + chost: aarch64-linux-gnu + packages: qemu-system qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross + qemu-run: qemu-aarch64 -L /usr/aarch64-linux-gnu + + - name: Ubuntu GCC PPC + os: ubuntu-latest + compiler: powerpc-linux-gnu-gcc + configure-args: --warn --static + chost: powerpc-linux-gnu + packages: qemu-system qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross + qemu-run: qemu-ppc -L /usr/powerpc-linux-gnu + cflags: -static + ldflags: -static + + - name: Ubuntu GCC PPC64 + os: ubuntu-latest + compiler: powerpc64-linux-gnu-gcc + configure-args: --warn --static + chost: powerpc-linux-gnu + packages: qemu-system qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross + qemu-run: qemu-ppc64 -L /usr/powerpc64-linux-gnu + cflags: -static + ldflags: -static + + - name: Ubuntu GCC PPC64LE + os: ubuntu-latest + compiler: powerpc64le-linux-gnu-gcc + configure-args: --warn + chost: powerpc64le-linux-gnu + packages: qemu-system qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross + qemu-run: qemu-ppc64le -L /usr/powerpc64le-linux-gnu + + - name: Ubuntu GCC S390X + os: ubuntu-latest + compiler: s390x-linux-gnu-gcc + configure-args: --warn --static + chost: s390x-linux-gnu + packages: qemu-system qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross + qemu-run: qemu-s390x -L /usr/s390x-linux-gnu + cflags: -static + ldflags: -static + + - name: macOS GCC + os: macos-latest + compiler: gcc-12 + configure-args: --warn + + - name: macOS Clang + os: macos-latest + compiler: clang + configure-args: --warn + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install packages (Ubuntu) + if: runner.os == 'Linux' && matrix.packages + run: | + sudo apt-get update + sudo apt-get install -y ${{ matrix.packages }} + + - name: Generate project files + run: | + [ -d ${{ matrix.build-dir || '.' }} ] || mkdir ${{ matrix.build-dir || '.' }} + cd ${{ matrix.build-dir || '.' }} + ${{ matrix.src-dir || '.' }}/configure ${{ matrix.configure-args }} + env: + CC: ${{ matrix.compiler }} + CFLAGS: ${{ matrix.cflags }} + LDFLAGS: ${{ matrix.ldflags }} + CHOST: ${{ matrix.chost }} + + - name: Compile source code + run: make -j2 + working-directory: ${{ matrix.build-dir }} + + - name: Run test cases + run: | + make test + make cover + working-directory: ${{ matrix.build-dir }} + env: + QEMU_RUN: ${{ matrix.qemu-run }} + + - name: Upload build errors + uses: actions/upload-artifact@v4 + if: failure() + with: + name: ${{ matrix.name }} (configure) + path: | + ${{ matrix.build-dir || '.' }}/configure.log + retention-days: 7 diff --git a/deps/zlib/.github/workflows/fuzz.yml b/deps/zlib/.github/workflows/fuzz.yml new file mode 100644 index 000000000..ddca83c37 --- /dev/null +++ b/deps/zlib/.github/workflows/fuzz.yml @@ -0,0 +1,25 @@ +name: OSS-Fuzz +on: [pull_request] +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'zlib' + dry-run: false + + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'zlib' + fuzz-seconds: 300 + dry-run: false + + - name: Upload Crash + uses: actions/upload-artifact@v4 + if: failure() + with: + name: artifacts + path: ./out/artifacts diff --git a/deps/zlib/.github/workflows/msys-cygwin.yml b/deps/zlib/.github/workflows/msys-cygwin.yml new file mode 100644 index 000000000..e76be9f0d --- /dev/null +++ b/deps/zlib/.github/workflows/msys-cygwin.yml @@ -0,0 +1,77 @@ +name: mingw/cygwin + +on: [push, pull_request] + +jobs: + MSys: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + sys: [mingw32, mingw64, ucrt64, clang64] + name: MSys - ${{ matrix.sys }} + defaults: + run: + shell: msys2 {0} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.sys }} + update: true + install: >- + make + pacboy: >- + toolchain:p + cmake:p + - name: Configure + run: | + cmake -G"Unix Makefiles" \ + -S . \ + -B build \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DMINIZIP_ENABLE_BZIP2=ON + - name: Build + run: cmake --build build --config Release + - name: Run tests + run: ctest --output-on-failure --test-dir build -C Release + + cygwin: + strategy: + fail-fast: false + runs-on: windows-latest + defaults: + run: + shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}' + name: Cygwin + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup cygwin + uses: cygwin/cygwin-install-action@master + with: + packages: >- + cmake + cygwin-devel + gcc-core + gcc-g++ + ninja + - name: Configure + run: | + cmake /cygdrive/d/a/zlib/zlib \ + -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DZLIB_BUILD_MINIZIP=ON \ + -DMINIZIP_ENABLE_BZIP2=OFF \ + -G Ninja + - name: Build + run: cmake --build build --config Release -v -j1 + - name: Run tests + run: ctest --output-on-failure --test-dir build -C Release diff --git a/deps/zlib/.gitignore b/deps/zlib/.gitignore new file mode 100644 index 000000000..8d069ed38 --- /dev/null +++ b/deps/zlib/.gitignore @@ -0,0 +1,51 @@ +*.diff +*.patch +*.orig +*.rej + +*~ +*.a +*.lo +*.o +*.dylib + +*.gcda +*.gcno +*.gcov + +/zconf.h +/Makefile +/example +/example64 +/examplesh +**/libz.so* +/minigzip +/minigzip64 +/minigzipsh +/zlib.pc +/configure.log +/build + +.DS_Store +.vs +*.user +*.nupkg +contrib/vstudio/vc143/x86 +contrib/vstudio/vc143/x64 +contrib/vstudio/vc143/arm +contrib/vstudio/vc143/arm64 +contrib/nuget/bin +contrib/nuget/obj +*.included + +# Bazel directories +/bazel-* +/bazel-bin +/bazel-genfiles +/bazel-out +/bazel-testlogs +user.bazelrc + +# MODULE.bazel.lock is ignored for now as per this recommendation: +# https://github.com/bazelbuild/bazel/issues/20369 +MODULE.bazel.lock diff --git a/deps/zlib/BUILD.bazel b/deps/zlib/BUILD.bazel new file mode 100644 index 000000000..9a294f2f2 --- /dev/null +++ b/deps/zlib/BUILD.bazel @@ -0,0 +1,134 @@ +# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches +# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD + +# Copyright 2008 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Code generated by the Protocol Buffer compiler is owned by the owner +# of the input file used when generating it. This code is not +# standalone and requires a support library to be linked with it. This +# support library is itself covered by the above license. + +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_license//rules:license.bzl", "license") + +package( + default_applicable_licenses = [":license"], +) + +license( + name = "license", + license_kinds = ["@rules_license//licenses/spdx:Zlib"], + license_text = "LICENSE", +) + +exports_files([ + "LICENSE", +]) + +_ZLIB_HEADERS = [ + "crc32.h", + "deflate.h", + "gzguts.h", + "inffast.h", + "inffixed.h", + "inflate.h", + "inftrees.h", + "trees.h", + "zconf.h", + "zlib.h", + "zutil.h", +] + +_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS] + +# In order to limit the damage from the `includes` propagation +# via `:zlib`, copy the public headers to a subdirectory and +# expose those. +genrule( + name = "copy_public_headers", + srcs = _ZLIB_HEADERS, + outs = _ZLIB_PREFIXED_HEADERS, + cmd_bash = "cp $(SRCS) $(@D)/zlib/include/", + cmd_bat = " && ".join( + ["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" % + s for s in _ZLIB_HEADERS], + ), +) + +config_setting( + name = "mingw_gcc_compiler", + flag_values = { + "@bazel_tools//tools/cpp:compiler": "mingw-gcc", + }, + visibility = [":__subpackages__"], +) + +cc_library( + name = "z", + srcs = [ + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "gzclose.c", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", + # Include the un-prefixed headers in srcs to work + # around the fact that zlib isn't consistent in its + # choice of <> or "" delimiter when including itself. + ] + _ZLIB_HEADERS, + hdrs = _ZLIB_PREFIXED_HEADERS, + copts = select({ + ":mingw_gcc_compiler": [ + "-fpermissive", + ], + "@platforms//os:windows": [], + "//conditions:default": [ + "-Wno-deprecated-non-prototype", + "-Wno-unused-variable", + "-Wno-implicit-function-declaration", + ], + }), + includes = ["zlib/include/"], + visibility = ["//visibility:public"], +) + +alias( + name = "zlib", + actual = ":z", + visibility = ["//visibility:public"], +) diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt index 0fe939df6..aa7359121 100644 --- a/deps/zlib/CMakeLists.txt +++ b/deps/zlib/CMakeLists.txt @@ -1,99 +1,131 @@ -cmake_minimum_required(VERSION 2.4.4) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) +cmake_minimum_required(VERSION 3.12...3.31) -project(zlib C) +project( + zlib + LANGUAGES C + VERSION 1.4.1.1 + HOMEPAGE_URL "https://zlib.net/" + DESCRIPTION "a general-purpose lossless data-compression library") -set(VERSION "1.2.11") +# ============================================================================ +# CPack +# ============================================================================ +set(CPACK_PACKAGE_VENDOR "zlib-Project") +set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README) +set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE) +set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README) -option(ASM686 "Enable building i686 assembly implementation") -option(AMD64 "Enable building amd64 assembly implementation") +# ============================================================================ +# configuration +# ============================================================================ -set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") +option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON) +option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON) +option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON) +option(ZLIB_BUILD_MINIZIP "Enable building libminizip contrib library" OFF) +option(ZLIB_INSTALL "Enable installation of zlib" ON) +option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in" + OFF) +mark_as_advanced(ZLIB_PREFIX) -include(CheckTypeSize) +if(WIN32) + option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON) +endif(WIN32) + +get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + +if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI) + message(STATUS "No CMAKE_BUILD_TYPE set -- using Release") + set(CMAKE_BUILD_TYPE Release) +endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI) + +include(CheckCSourceCompiles) include(CheckFunctionExists) include(CheckIncludeFile) -include(CheckCSourceCompiles) -enable_testing() +include(CMakePackageConfigHelpers) +include(CheckTypeSize) +include(CPack) +include(GNUInstallDirs) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) +set(CPACK_INCLUDED TRUE) + +if(NOT ZLIB_CONF_WRITTEN) + set(Z_PREFIX ${ZLIB_PREFIX}) + set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein) + file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245) + file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT}) + file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n") + file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n") + file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n") + file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244) + set(FIRST_ITEM TRUE) + + foreach(item IN LISTS ZCONF_CONTENT) + if(FIRST_ITEM) + string(APPEND OUT_CONTENT ${item}) + set(FIRST_ITEM FALSE) + else(FIRST_ITEM) + string(APPEND OUT_CONTENT "\;" ${item}) + endif(FIRST_ITEM) + endforeach(item IN LISTS ${ZCONF_CONTENT}) + + file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT}) + set(ZLIB_CONF_WRITTEN + TRUE + CACHE BOOL "zconf.h.cmakein was created") + mark_as_advanced(ZLIB_CONF_WRITTEN) +endif(NOT ZLIB_CONF_WRITTEN) # # Check to see if we have large file support # set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) -# We add these other definitions here because CheckTypeSize.cmake -# in CMake 2.4.x does not automatically do so and we want -# compatibility with CMake 2.4.x. -if(HAVE_SYS_TYPES_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) -endif() -if(HAVE_STDINT_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) -endif() -if(HAVE_STDDEF_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) -endif() check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable +unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable # # Check for fseeko # check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() + +# +# Check for stdarg.h +# +check_include_file(stdarg.h HAVE_STDARG_H) # # Check for unistd.h # -check_include_file(unistd.h Z_HAVE_UNISTD_H) +check_include_file(unistd.h HAVE_UNISTD_H) +# +# Check visibility attribute is supported +# if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() + set(CMAKE_REQUIRED_FLAGS "-WX") +else(MSVC) + set(CMAKE_REQUIRED_FLAGS "-WError") +endif(MSVC) -if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - # If we're doing an out of source build and the user has a zconf.h - # in their source tree... - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) - message(STATUS "Renaming") - message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") - message(STATUS "to 'zconf.h.included' because this file is included with zlib") - message(STATUS "but CMake generates it automatically in the build directory.") - file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) - endif() -endif() +check_c_source_compiles( + " + #include + static void f(void) __attribute__ ((visibility(\"hidden\"))); + int main(void) {return 0;} + " + HAVE___ATTR__VIS_HIDDEN) -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) +unset(CMAKE_COMPILE_FLAGS) +set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc) +configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY) +configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h) - -#============================================================================ +# ============================================================================ # zlib -#============================================================================ +# ============================================================================ + +set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h) -set(ZLIB_PUBLIC_HDRS - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h - zlib.h -) set(ZLIB_PRIVATE_HDRS crc32.h deflate.h @@ -103,8 +135,8 @@ set(ZLIB_PRIVATE_HDRS inflate.h inftrees.h trees.h - zutil.h -) + zutil.h) + set(ZLIB_SRCS adler32.c compress.c @@ -120,130 +152,179 @@ set(ZLIB_SRCS inffast.c trees.c uncompr.c - zutil.c -) + zutil.c) -if(NOT MINGW) - set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. - ) -endif() +if(WIN32) + set(zlib_static_suffix "s") + set(CMAKE_DEBUG_POSTFIX "d") +endif(WIN32) -if(CMAKE_COMPILER_IS_GNUCC) - if(ASM686) - set(ZLIB_ASMS contrib/asm686/match.S) - elseif (AMD64) - set(ZLIB_ASMS contrib/amd64/amd64-match.S) - endif () +if(ZLIB_BUILD_SHARED) + add_library( + zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS} + $<$,$>:win32/zlib1.rc>) + add_library(ZLIB::ZLIB ALIAS zlib) + target_include_directories( + zlib + PUBLIC $ + $ + $) + target_compile_definitions( + zlib + PRIVATE ZLIB_BUILD + $<$:NO_FSEEKO> + $<$:HAVE_HIDDEN> + $<$:_CRT_SECURE_NO_DEPRECATE> + $<$:_CRT_NONSTDC_NO_DEPRECATE> + PUBLIC $<$:_LARGEFILE64_SOURCE=1>) + set(INSTALL_VERSION ${zlib_VERSION}) - if(ZLIB_ASMS) - add_definitions(-DASMV) - set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) - endif() -endif() + if(NOT CYGWIN) + set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR} + VERSION ${INSTALL_VERSION}) + endif(NOT CYGWIN) -if(MSVC) - if(ASM686) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx86/inffas32.asm - contrib/masmx86/match686.asm - ) - elseif (AMD64) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx64/gvmat64.asm - contrib/masmx64/inffasx64.asm - ) - endif() + set_target_properties( + zlib + PROPERTIES DEFINE_SYMBOL ZLIB_DLL + EXPORT_NAME ZLIB + OUTPUT_NAME z) + if(UNIX + AND NOT APPLE + AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)) + # On unix-like platforms the library is almost always called libz + set_target_properties( + zlib + PROPERTIES LINK_FLAGS + "-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"") + endif( + UNIX + AND NOT APPLE + AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)) +endif(ZLIB_BUILD_SHARED) - if(ZLIB_ASMS) - add_definitions(-DASMV -DASMINF) - endif() -endif() +if(ZLIB_BUILD_STATIC) + add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} + ${ZLIB_PRIVATE_HDRS}) + add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic) + target_include_directories( + zlibstatic + PUBLIC $ + $ + $) + target_compile_definitions( + zlibstatic + PRIVATE ZLIB_BUILD + $<$:NO_FSEEKO> + $<$:HAVE_HIDDEN> + $<$:_CRT_SECURE_NO_DEPRECATE> + $<$:_CRT_NONSTDC_NO_DEPRECATE> + PUBLIC $<$:_LARGEFILE64_SOURCE=1>) + set_target_properties( + zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME + z${zlib_static_suffix}) +endif(ZLIB_BUILD_STATIC) -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) +if(ZLIB_INSTALL) + if(ZLIB_BUILD_SHARED) + install( + TARGETS zlib + COMPONENT Runtime + EXPORT zlibSharedExport + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install( + EXPORT zlibSharedExport + FILE ZLIB-shared.cmake + NAMESPACE ZLIB:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib) + if(ZLIB_INSTALL_COMPAT_DLL) + install( + FILES $ + COMPONENT Runtime + RENAME zlib1.dll + DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif(ZLIB_INSTALL_COMPAT_DLL) -if(MINGW) - # This gets us DLL resource information when compiling on MinGW. - if(NOT CMAKE_RC_COMPILER) - set(CMAKE_RC_COMPILER windres.exe) - endif() + if(MSVC) + install( + FILES $ + COMPONENT Runtime + DESTINATION ${CMAKE_INSTALL_BINDIR} + CONFIGURATIONS Debug OR RelWithDebInfo + OPTIONAL) + endif(MSVC) + endif(ZLIB_BUILD_SHARED) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - COMMAND ${CMAKE_RC_COMPILER} - -D GCC_WINDRES - -I ${CMAKE_CURRENT_SOURCE_DIR} - -I ${CMAKE_CURRENT_BINARY_DIR} - -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) -endif(MINGW) + if(ZLIB_BUILD_STATIC) + install( + TARGETS zlibstatic + COMPONENT Development + EXPORT zlibStaticExport + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install( + EXPORT zlibStaticExport + FILE ZLIB-static.cmake + NAMESPACE ZLIB:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib) -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -set_target_properties(zlib PROPERTIES SOVERSION 1) + if(ZLIB_INSTALL_COMPAT_DLL AND MINGW) + install( + FILES $ + COMPONENT Development + RENAME libz.dll.a + DESTINATION "${CMAKE_INSTALL_LIBDIR}") + endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW) + endif(ZLIB_BUILD_STATIC) -if(NOT CYGWIN) - # This property causes shared libraries on Linux to have the full version - # encoded into their final filename. We disable this on Cygwin because - # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll - # seems to be the default. - # - # This has no effect with MSVC, on that platform the version info for - # the DLL comes from the resource file win32/zlib1.rc - set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) -endif() + configure_package_config_file( + ${zlib_SOURCE_DIR}/zlibConfig.cmake.in + ${zlib_BINARY_DIR}/ZLIBConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib) -if(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") - endif() -elseif(BUILD_SHARED_LIBS AND WIN32) - # Creates zlib1.dll when building shared library version - set_target_properties(zlib PROPERTIES SUFFIX "1.dll") -endif() + write_basic_package_version_file( + "${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake" + VERSION "${zlib_VERSION}" + COMPATIBILITY AnyNewerVersion) -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) - install(TARGETS zlib zlibstatic - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) -endif() -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") -endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") -endif() + install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake + ${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib) + install( + FILES ${ZLIB_PUBLIC_HDRS} + COMPONENT Development + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install( + FILES zlib.3 + COMPONENT Docs + DESTINATION "${CMAKE_INSTALL_MANDIR}/man3") + install( + FILES LICENSE + doc/algorithm.txt + doc/crc-doc.1.0.pdf + doc/rfc1950.txt + doc/rfc1951.txt + doc/rfc1952.txt + doc/txtvsbin.txt + COMPONENT Docs + DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib") + install( + FILES ${ZLIB_PC} + COMPONENT Development + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +endif(ZLIB_INSTALL) -#============================================================================ -# Example binaries -#============================================================================ +# ============================================================================ +# Tests +# ============================================================================ +if(ZLIB_BUILD_TESTING) + enable_testing() + add_subdirectory(test) +endif(ZLIB_BUILD_TESTING) -add_executable(example test/example.c) -target_link_libraries(example zlib) -add_test(example example) - -add_executable(minigzip test/minigzip.c) -target_link_libraries(minigzip zlib) - -if(HAVE_OFF64_T) - add_executable(example64 test/example.c) - target_link_libraries(example64 zlib) - set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") - add_test(example64 example64) - - add_executable(minigzip64 test/minigzip.c) - target_link_libraries(minigzip64 zlib) - set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") -endif() +if(ZLIB_BUILD_MINIZIP) + add_subdirectory(contrib/minizip/) +endif(ZLIB_BUILD_MINIZIP) diff --git a/deps/zlib/ChangeLog b/deps/zlib/ChangeLog index 30199a65a..1f83ab05c 100644 --- a/deps/zlib/ChangeLog +++ b/deps/zlib/ChangeLog @@ -1,6 +1,112 @@ ChangeLog file for zlib +Changes in 1.3.1.1 (xx Jan 2024) +- + +Changes in 1.3.1 (22 Jan 2024) +- Reject overflows of zip header fields in minizip +- Fix bug in inflateSync() for data held in bit buffer +- Add LIT_MEM define to use more memory for a small deflate speedup +- Fix decision on the emission of Zip64 end records in minizip +- Add bounds checking to ERR_MSG() macro, used by zError() +- Neutralize zip file traversal attacks in miniunz +- Fix a bug in ZLIB_DEBUG compiles in check_match() +- Various portability and appearance improvements + +Changes in 1.3 (18 Aug 2023) +- Remove K&R function definitions and zlib2ansi +- Fix bug in deflateBound() for level 0 and memLevel 9 +- Fix bug when gzungetc() is used immediately after gzopen() +- Fix bug when using gzflush() with a very small buffer +- Fix crash when gzsetparams() attempted for transparent write +- Fix test/example.c to work with FORCE_STORED +- Rewrite of zran in examples (see zran.c version history) +- Fix minizip to allow it to open an empty zip file +- Fix reading disk number start on zip64 files in minizip +- Fix logic error in minizip argument processing +- Add minizip testing to Makefile +- Read multiple bytes instead of byte-by-byte in minizip unzip.c +- Add memory sanitizer to configure (--memory) +- Various portability improvements +- Various documentation improvements +- Various spelling and typo corrections + +Changes in 1.2.13 (13 Oct 2022) +- Fix configure issue that discarded provided CC definition +- Correct incorrect inputs provided to the CRC functions +- Repair prototypes and exporting of new CRC functions +- Fix inflateBack to detect invalid input with distances too far +- Have infback() deliver all of the available output up to any error +- Fix a bug when getting a gzip header extra field with inflate() +- Fix bug in block type selection when Z_FIXED used +- Tighten deflateBound bounds +- Remove deleted assembler code references +- Various portability and appearance improvements + +Changes in 1.2.12 (27 Mar 2022) +- Cygwin does not have _wopen(), so do not create gzopen_w() there +- Permit a deflateParams() parameter change as soon as possible +- Limit hash table inserts after switch from stored deflate +- Fix bug when window full in deflate_stored() +- Fix CLEAR_HASH macro to be usable as a single statement +- Avoid a conversion error in gzseek when off_t type too small +- Have Makefile return non-zero error code on test failure +- Avoid some conversion warnings in gzread.c and gzwrite.c +- Update use of errno for newer Windows CE versions +- Small speedup to inflate [psumbera] +- Return an error if the gzputs string length can't fit in an int +- Add address checking in clang to -w option of configure +- Don't compute check value for raw inflate if asked to validate +- Handle case where inflateSync used when header never processed +- Avoid the use of ptrdiff_t +- Avoid an undefined behavior of memcpy() in gzappend() +- Avoid undefined behaviors of memcpy() in gz*printf() +- Avoid an undefined behavior of memcpy() in _tr_stored_block() +- Make the names in functions declarations identical to definitions +- Remove old assembler code in which bugs have manifested +- Fix deflateEnd() to not report an error at start of raw deflate +- Add legal disclaimer to README +- Emphasize the need to continue decompressing gzip members +- Correct the initialization requirements for deflateInit2() +- Fix a bug that can crash deflate on some input when using Z_FIXED +- Assure that the number of bits for deflatePrime() is valid +- Use a structure to make globals in enough.c evident +- Use a macro for the printf format of big_t in enough.c +- Clean up code style in enough.c, update version +- Use inline function instead of macro for index in enough.c +- Clarify that prefix codes are counted in enough.c +- Show all the codes for the maximum tables size in enough.c +- Add gznorm.c example, which normalizes gzip files +- Fix the zran.c example to work on a multiple-member gzip file +- Add tables for crc32_combine(), to speed it up by a factor of 200 +- Add crc32_combine_gen() and crc32_combine_op() for fast combines +- Speed up software CRC-32 computation by a factor of 1.5 to 3 +- Use atomic test and set, if available, for dynamic CRC tables +- Don't bother computing check value after successful inflateSync() +- Correct comment in crc32.c +- Add use of the ARMv8 crc32 instructions when requested +- Use ARM crc32 instructions if the ARM architecture has them +- Explicitly note that the 32-bit check values are 32 bits +- Avoid adding empty gzip member after gzflush with Z_FINISH +- Fix memory leak on error in gzlog.c +- Fix error in comment on the polynomial representation of a byte +- Clarify gz* function interfaces, referring to parameter names +- Change macro name in inflate.c to avoid collision in VxWorks +- Correct typo in blast.c +- Improve portability of contrib/minizip +- Fix indentation in minizip's zip.c +- Replace black/white with allow/block. (theresa-m) +- minizip warning fix if MAXU32 already defined. (gvollant) +- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner) +- Clean up minizip to reduce warnings for testing +- Add fallthrough comments for gcc +- Eliminate use of ULL constants +- Separate out address sanitizing from warnings in configure +- Remove destructive aspects of make distclean +- Check for cc masquerading as gcc or clang in configure +- Fix crc32.c to compile local functions only if used + Changes in 1.2.11 (15 Jan 2017) - Fix deflate stored bug when pulling last block from window - Permit immediate deflateParams changes before any deflate input @@ -96,7 +202,7 @@ Changes in 1.2.7.1 (24 Mar 2013) - Fix types in contrib/minizip to match result of get_crc_table() - Simplify contrib/vstudio/vc10 with 'd' suffix - Add TOP support to win32/Makefile.msc -- Suport i686 and amd64 assembler builds in CMakeLists.txt +- Support i686 and amd64 assembler builds in CMakeLists.txt - Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h - Add vc11 and vc12 build files to contrib/vstudio - Add gzvprintf() as an undocumented function in zlib @@ -296,14 +402,14 @@ Changes in 1.2.5.1 (10 Sep 2011) - Use u4 type for crc_table to avoid conversion warnings - Apply casts in zlib.h to avoid conversion warnings - Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] -- Improve inflateSync() documentation to note indeterminancy +- Improve inflateSync() documentation to note indeterminacy - Add deflatePending() function to return the amount of pending output - Correct the spelling of "specification" in FAQ [Randers-Pehrson] - Add a check in configure for stdarg.h, use for gzprintf() - Check that pointers fit in ints when gzprint() compiled old style - Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] - Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] -- Add debug records in assmebler code [Londer] +- Add debug records in assembler code [Londer] - Update RFC references to use http://tools.ietf.org/html/... [Li] - Add --archs option, use of libtool to configure for Mac OS X [Borstel] @@ -511,7 +617,7 @@ Changes in 1.2.3.5 (8 Jan 2010) - Don't use _vsnprintf on later versions of MSVC [Lowman] - Add CMake build script and input file [Lowman] - Update contrib/minizip to 1.1 [Svensson, Vollant] -- Moved nintendods directory from contrib to . +- Moved nintendods directory from contrib to root - Replace gzio.c with a new set of routines with the same functionality - Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above - Update contrib/minizip to 1.1b @@ -685,7 +791,7 @@ Changes in 1.2.2.4 (11 July 2005) - Be more strict on incomplete code sets in inflate_table() and increase ENOUGH and MAXD -- this repairs a possible security vulnerability for invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for - discovering the vulnerability and providing test cases. + discovering the vulnerability and providing test cases - Add ia64 support to configure for HP-UX [Smith] - Add error return to gzread() for format or i/o error [Levin] - Use malloc.h for OS/2 [Necasek] @@ -721,7 +827,7 @@ Changes in 1.2.2.2 (30 December 2004) - Add Z_FIXED strategy option to deflateInit2() to force fixed trees - Add updated make_vms.com [Coghlan], update README - Create a new "examples" directory, move gzappend.c there, add zpipe.c, - fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. + fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html - Add FAQ entry and comments in deflate.c on uninitialized memory access - Add Solaris 9 make options in configure [Gilbert] - Allow strerror() usage in gzio.c for STDC @@ -792,7 +898,7 @@ Changes in 1.2.1.1 (9 January 2004) - Fix a big fat bug in inftrees.c that prevented decoding valid dynamic blocks with only literals and no distance codes -- Thanks to "Hot Emu" for the bug report and sample file -- Add a note to puff.c on no distance codes case. +- Add a note to puff.c on no distance codes case Changes in 1.2.1 (17 November 2003) - Remove a tab in contrib/gzappend/gzappend.c @@ -970,7 +1076,7 @@ Changes in 1.2.0.1 (17 March 2003) - Include additional header file on VMS for off_t typedef - Try to use _vsnprintf where it supplants vsprintf [Vollant] - Add some casts in inffast.c -- Enchance comments in zlib.h on what happens if gzprintf() tries to +- Enhance comments in zlib.h on what happens if gzprintf() tries to write more than 4095 bytes before compression - Remove unused state from inflateBackEnd() - Remove exit(0) from minigzip.c, example.c @@ -1036,14 +1142,14 @@ Changes in 1.2.0 (9 March 2003) - Add contrib/puff/ simple inflate for deflate format description Changes in 1.1.4 (11 March 2002) -- ZFREE was repeated on same allocation on some error conditions. +- ZFREE was repeated on same allocation on some error conditions This creates a security problem described in http://www.zlib.org/advisory-2002-03-11.txt - Returned incorrect error (Z_MEM_ERROR) on some invalid data - Avoid accesses before window for invalid distances with inflate window - less than 32K. + less than 32K - force windowBits > 8 to avoid a bug in the encoder for a window size - of 256 bytes. (A complete fix will be available in 1.1.5). + of 256 bytes. (A complete fix will be available in 1.1.5) Changes in 1.1.3 (9 July 1998) - fix "an inflate input buffer bug that shows up on rare but persistent @@ -1117,7 +1223,7 @@ Changes in 1.1.1 (27 Feb 98) - remove block truncation heuristic which had very marginal effect for zlib (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the compression ratio on some files. This also allows inlining _tr_tally for - matches in deflate_slow. + matches in deflate_slow - added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) Changes in 1.1.0 (24 Feb 98) @@ -1148,7 +1254,7 @@ Changes in 1.0.9 (17 Feb 1998) - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with - the declaration of FAR (Gilles VOllant) + the declaration of FAR (Gilles Vollant) - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) - read_buf buf parameter of type Bytef* instead of charf* - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) @@ -1162,7 +1268,7 @@ Changes in 1.0.8 (27 Jan 1998) - include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) - use constant arrays for the static trees in trees.c instead of computing them at run time (thanks to Ken Raeburn for this suggestion). To create - trees.h, compile with GEN_TREES_H and run "make test". + trees.h, compile with GEN_TREES_H and run "make test" - check return code of example in "make test" and display result - pass minigzip command line options to file_compress - simplifying code of inflateSync to avoid gcc 2.8 bug @@ -1201,12 +1307,12 @@ Changes in 1.0.6 (19 Jan 1998) - add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) - Fix a deflate bug occurring only with compression level 0 (thanks to - Andy Buckler for finding this one). -- In minigzip, pass transparently also the first byte for .Z files. + Andy Buckler for finding this one) +- In minigzip, pass transparently also the first byte for .Z files - return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() - check Z_FINISH in inflate (thanks to Marc Schluper) - Implement deflateCopy (thanks to Adam Costello) -- make static libraries by default in configure, add --shared option. +- make static libraries by default in configure, add --shared option - move MSDOS or Windows specific files to directory msdos - suppress the notion of partial flush to simplify the interface (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) @@ -1218,7 +1324,7 @@ Changes in 1.0.6 (19 Jan 1998) - added Makefile.nt (thanks to Stephen Williams) - added the unsupported "contrib" directory: contrib/asm386/ by Gilles Vollant - 386 asm code replacing longest_match(). + 386 asm code replacing longest_match() contrib/iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions contrib/iostream2/ by Tyge Løvset @@ -1226,7 +1332,7 @@ Changes in 1.0.6 (19 Jan 1998) contrib/untgz/ by "Pedro A. Aranda Guti\irrez" A very simple tar.gz file extractor using zlib contrib/visual-basic.txt by Carlos Rios - How to use compress(), uncompress() and the gz* functions from VB. + How to use compress(), uncompress() and the gz* functions from VB - pass params -f (filtered data), -h (huffman only), -1 to -9 (compression level) in minigzip (thanks to Tom Lane) @@ -1235,8 +1341,8 @@ Changes in 1.0.6 (19 Jan 1998) - add undocumented function inflateSyncPoint() (hack for Paul Mackerras) - add undocumented function zError to convert error code to string (for Tim Smithers) -- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code. -- Use default memcpy for Symantec MSDOS compiler. +- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code +- Use default memcpy for Symantec MSDOS compiler - Add EXPORT keyword for check_func (needed for Windows DLL) - add current directory to LD_LIBRARY_PATH for "make test" - create also a link for libz.so.1 @@ -1249,7 +1355,7 @@ Changes in 1.0.6 (19 Jan 1998) - allow compilation with ANSI keywords only enabled for TurboC in large model - avoid "versionString"[0] (Borland bug) - add NEED_DUMMY_RETURN for Borland -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch). +- use variable z_verbose for tracing in debug mode (L. Peter Deutsch) - allow compilation with CC - defined STDC for OS/2 (David Charlap) - limit external names to 8 chars for MVS (Thomas Lund) @@ -1259,7 +1365,7 @@ Changes in 1.0.6 (19 Jan 1998) - use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) - added makelcc.bat for lcc-win32 (Tom St Denis) - in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) -- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. +- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion - check for unistd.h in configure (for off_t) - remove useless check parameter in inflate_blocks_free - avoid useless assignment of s->check to itself in inflate_blocks_new @@ -1280,7 +1386,7 @@ Changes in 1.0.5 (3 Jan 98) Changes in 1.0.4 (24 Jul 96) - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF bit, so the decompressor could decompress all the correct data but went - on to attempt decompressing extra garbage data. This affected minigzip too. + on to attempt decompressing extra garbage data. This affected minigzip too - zlibVersion and gzerror return const char* (needed for DLL) - port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) - use z_error only for DEBUG (avoid problem with DLLs) @@ -1310,7 +1416,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] - fix array overlay in deflate.c which sometimes caused bad compressed data - fix inflate bug with empty stored block - fix MSDOS medium model which was broken in 0.99 -- fix deflateParams() which could generate bad compressed data. +- fix deflateParams() which could generate bad compressed data - Bytef is define'd instead of typedef'ed (work around Borland bug) - added an INDEX file - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), @@ -1331,7 +1437,7 @@ Changes in 0.99 (27 Jan 96) - allow preset dictionary shared between compressor and decompressor - allow compression level 0 (no compression) - add deflateParams in zlib.h: allow dynamic change of compression level - and compression strategy. + and compression strategy - test large buffers and deflateParams in example.c - add optional "configure" to build zlib as a shared library - suppress Makefile.qnx, use configure instead @@ -1370,33 +1476,33 @@ Changes in 0.99 (27 Jan 96) - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) - in fcalloc, normalize pointer if size > 65520 bytes - don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. - use Z_BINARY instead of BINARY - document that gzclose after gzdopen will close the file -- allow "a" as mode in gzopen. +- allow "a" as mode in gzopen - fix error checking in gzread - allow skipping .gz extra-field on pipes - added reference to Perl interface in README - put the crc table in FAR data (I dislike more and more the medium model :) - added get_crc_table -- added a dimension to all arrays (Borland C can't count). +- added a dimension to all arrays (Borland C can't count) - workaround Borland C bug in declaration of inflate_codes_new & inflate_fast - guard against multiple inclusion of *.h (for precompiled header on Mac) -- Watcom C pretends to be Microsoft C small model even in 32 bit mode. +- Watcom C pretends to be Microsoft C small model even in 32 bit mode - don't use unsized arrays to avoid silly warnings by Visual C++: warning C4746: 'inflate_mask' : unsized array treated as '__far' - (what's wrong with far data in far model?). + (what's wrong with far data in far model?) - define enum out of inflate_blocks_state to allow compilation with C++ Changes in 0.95 (16 Aug 95) - fix MSDOS small and medium model (now easier to adapt to any compiler) - inlined send_bits - fix the final (:-) bug for deflate with flush (output was correct but - not completely flushed in rare occasions). + not completely flushed in rare occasions) - default window size is same for compression and decompression - (it's now sufficient to set MAX_WBITS in zconf.h). + (it's now sufficient to set MAX_WBITS in zconf.h) - voidp -> voidpf and voidnp -> voidp (for consistency with other - typedefs and because voidnp was not near in large model). + typedefs and because voidnp was not near in large model) Changes in 0.94 (13 Aug 95) - support MSDOS medium model @@ -1405,12 +1511,12 @@ Changes in 0.94 (13 Aug 95) - added support for VMS - allow a compression level in gzopen() - gzflush now calls fflush -- For deflate with flush, flush even if no more input is provided. +- For deflate with flush, flush even if no more input is provided - rename libgz.a as libz.a - avoid complex expression in infcodes.c triggering Turbo C bug - work around a problem with gcc on Alpha (in INSERT_STRING) - don't use inline functions (problem with some gcc versions) -- allow renaming of Byte, uInt, etc... with #define. +- allow renaming of Byte, uInt, etc... with #define - avoid warning about (unused) pointer before start of array in deflate.c - avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c - avoid reserved word 'new' in trees.c @@ -1429,7 +1535,7 @@ Changes in 0.92 (3 May 95) - no memcpy on Pyramid - suppressed inftest.c - optimized fill_window, put longest_match inline for gcc -- optimized inflate on stored blocks. +- optimized inflate on stored blocks - untabify all sources to simplify patches Changes in 0.91 (2 May 95) @@ -1447,7 +1553,7 @@ Changes in 0.9 (1 May 95) - let again gzread copy uncompressed data unchanged (was working in 0.71) - deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented - added a test of inflateSync in example.c -- moved MAX_WBITS to zconf.h because users might want to change that. +- moved MAX_WBITS to zconf.h because users might want to change that - document explicitly that zalloc(64K) on MSDOS must return a normalized pointer (zero offset) - added Makefiles for Microsoft C, Turbo C, Borland C++ @@ -1456,7 +1562,7 @@ Changes in 0.9 (1 May 95) Changes in 0.8 (29 April 95) - added fast inflate (inffast.c) - deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this - is incompatible with previous versions of zlib which returned Z_OK. + is incompatible with previous versions of zlib which returned Z_OK - work around a TurboC compiler bug (bad code for b << 0, see infutil.h) (actually that was not a compiler bug, see 0.81 above) - gzread no longer reads one extra byte in certain cases @@ -1466,50 +1572,50 @@ Changes in 0.8 (29 April 95) Changes in 0.71 (14 April 95) - Fixed more MSDOS compilation problems :( There is still a bug with - TurboC large model. + TurboC large model Changes in 0.7 (14 April 95) -- Added full inflate support. +- Added full inflate support - Simplified the crc32() interface. The pre- and post-conditioning (one's complement) is now done inside crc32(). WARNING: this is - incompatible with previous versions; see zlib.h for the new usage. + incompatible with previous versions; see zlib.h for the new usage Changes in 0.61 (12 April 95) -- workaround for a bug in TurboC. example and minigzip now work on MSDOS. +- workaround for a bug in TurboC. example and minigzip now work on MSDOS Changes in 0.6 (11 April 95) - added minigzip.c - added gzdopen to reopen a file descriptor as gzFile -- added transparent reading of non-gziped files in gzread. +- added transparent reading of non-gziped files in gzread - fixed bug in gzread (don't read crc as data) -- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose). +- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose) - don't allocate big arrays in the stack (for MSDOS) - fix some MSDOS compilation problems Changes in 0.5: - do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but - not yet Z_FULL_FLUSH. + not yet Z_FULL_FLUSH - support decompression but only in a single step (forced Z_FINISH) -- added opaque object for zalloc and zfree. +- added opaque object for zalloc and zfree - added deflateReset and inflateReset -- added a variable zlib_version for consistency checking. -- renamed the 'filter' parameter of deflateInit2 as 'strategy'. - Added Z_FILTERED and Z_HUFFMAN_ONLY constants. +- added a variable zlib_version for consistency checking +- renamed the 'filter' parameter of deflateInit2 as 'strategy' + Added Z_FILTERED and Z_HUFFMAN_ONLY constants Changes in 0.4: -- avoid "zip" everywhere, use zlib instead of ziplib. +- avoid "zip" everywhere, use zlib instead of ziplib - suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush - if compression method == 8. + if compression method == 8 - added adler32 and crc32 - renamed deflateOptions as deflateInit2, call one or the other but not both -- added the method parameter for deflateInit2. +- added the method parameter for deflateInit2 - added inflateInit2 -- simplied considerably deflateInit and inflateInit by not supporting +- simplified considerably deflateInit and inflateInit by not supporting user-provided history buffer. This is supported only in deflateInit2 - and inflateInit2. + and inflateInit2 Changes in 0.3: - prefix all macro names with Z_ -- use Z_FINISH instead of deflateEnd to finish compression. +- use Z_FINISH instead of deflateEnd to finish compression - added Z_HUFFMAN_ONLY - added gzerror() diff --git a/deps/zlib/FAQ b/deps/zlib/FAQ index 99b7cf92e..f72cac63c 100644 --- a/deps/zlib/FAQ +++ b/deps/zlib/FAQ @@ -4,7 +4,7 @@ If your question is not there, please check the zlib home page http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html +The latest zlib FAQ is at http://zlib.net/zlib_faq.html 1. Is zlib Y2K-compliant? @@ -14,13 +14,12 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html 2. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . + file win32/DLL_FAQ.txt in the zlib distribution. 3. Where can I get a Visual Basic interface to zlib? See - * http://marknelson.us/1997/01/01/zlib-engine/ + * https://marknelson.us/posts/1997/01/01/zlib-engine.html * win32/DLL_FAQ.txt in the zlib distribution 4. compress() returns Z_BUF_ERROR. diff --git a/deps/zlib/LICENSE b/deps/zlib/LICENSE new file mode 100644 index 000000000..b517acd57 --- /dev/null +++ b/deps/zlib/LICENSE @@ -0,0 +1,22 @@ +Copyright notice: + + (C) 1995-2024 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu diff --git a/deps/zlib/MODULE.bazel b/deps/zlib/MODULE.bazel new file mode 100644 index 000000000..cb4c13ef3 --- /dev/null +++ b/deps/zlib/MODULE.bazel @@ -0,0 +1,9 @@ +module( + name = "zlib", + version = "0.0.0", + compatibility_level = 1, +) + +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.16") +bazel_dep(name = "rules_license", version = "1.0.0") diff --git a/deps/zlib/Makefile.in b/deps/zlib/Makefile.in index 5a77949ff..7010b25c5 100644 --- a/deps/zlib/Makefile.in +++ b/deps/zlib/Makefile.in @@ -1,5 +1,5 @@ # Makefile for zlib -# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler +# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: @@ -7,16 +7,14 @@ # Normally configure builds both a static and a shared library. # If you want to build just a static library, use: ./configure --static -# To use the asm code, type: -# cp contrib/asm?86/match.S ./match.S -# make LOC=-DASMV OBJA=match.o - # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install # To install in $HOME instead of /usr/local, use: # make install prefix=$HOME CC=cc +GCOV=GCOV +LLVM_GCOV_FLAG=LLMV_GCOV_FLAG CFLAGS=-O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 @@ -26,13 +24,13 @@ CFLAGS=-O SFLAGS=-O LDFLAGS= -TEST_LDFLAGS=-L. libz.a +TEST_LIBS=-L. libz.a LDSHARED=$(CC) CPP=$(CC) -E STATICLIB=libz.a SHAREDLIB=libz.so -SHAREDLIBV=libz.so.1.2.11 +SHAREDLIBV=libz.so.1.3.1.1 SHAREDLIBM=libz.so.1 LIBS=$(STATICLIB) $(SHAREDLIBV) @@ -87,12 +85,12 @@ test: all teststatic testshared teststatic: static @TMPST=tmpst_$$; \ - if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ + if echo hello world | ${QEMU_RUN} ./minigzip | ${QEMU_RUN} ./minigzip -d && ${QEMU_RUN} ./example $$TMPST ; then \ echo ' *** zlib test OK ***'; \ else \ echo ' *** zlib test FAILED ***'; false; \ - fi; \ - rm -f $$TMPST + fi + @rm -f tmpst_$$ testshared: shared @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ @@ -100,32 +98,36 @@ testshared: shared DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ TMPSH=tmpsh_$$; \ - if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ + if echo hello world | ${QEMU_RUN} ./minigzipsh | ${QEMU_RUN} ./minigzipsh -d && ${QEMU_RUN} ./examplesh $$TMPSH; then \ echo ' *** zlib shared test OK ***'; \ else \ echo ' *** zlib shared test FAILED ***'; false; \ - fi; \ - rm -f $$TMPSH + fi + @rm -f tmpsh_$$ test64: all64 @TMP64=tmp64_$$; \ - if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ + if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \ echo ' *** zlib 64-bit test OK ***'; \ else \ echo ' *** zlib 64-bit test FAILED ***'; false; \ - fi; \ - rm -f $$TMP64 + fi + @rm -f tmp64_$$ infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c + $(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c infcover: infcover.o libz.a - $(CC) $(CFLAGS) -o $@ infcover.o libz.a + $(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a cover: infcover +ifdef $(GCOV) rm -f *.gcda - ./infcover - gcov inf*.c + ${QEMU_RUN} ./infcover + ${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda +else + @echo 'cover disabled as no suitable gcov was found' +endif libz.a: $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) @@ -180,7 +182,7 @@ inftrees.o: $(SRCDIR)inftrees.c trees.o: $(SRCDIR)trees.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c -zutil.o: $(SRCDIR)zutil.c +zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c compress.o: $(SRCDIR)compress.c @@ -242,7 +244,7 @@ trees.lo: $(SRCDIR)trees.c $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c -@mv objs/trees.o $@ -zutil.lo: $(SRCDIR)zutil.c +zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c -@mv objs/zutil.o $@ @@ -286,22 +288,22 @@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a -@rmdir objs example$(EXE): example.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS) minigzip$(EXE): minigzip.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS) examplesh$(EXE): example.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) + $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) + $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) example64$(EXE): example64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS) minigzip64$(EXE): minigzip64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS) install-libs: $(LIBS) -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi @@ -353,18 +355,25 @@ docs: zlib.3.pdf zlib.3.pdf: $(SRCDIR)zlib.3 groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ -zconf.h.cmakein: $(SRCDIR)zconf.h.in - -@ TEMPFILE=zconfh_$$; \ - echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ - sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ - touch -r $(SRCDIR)zconf.h.in $@ &&\ - rm $$TEMPFILE +# zconf.h.cmakein: $(SRCDIR)zconf.h.in +# -@ TEMPFILE=zconfh_$$; \ +# echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ +# sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ +# touch -r $(SRCDIR)zconf.h.in $@ &&\ +# rm $$TEMPFILE +# zconf: $(SRCDIR)zconf.h.in cp -p $(SRCDIR)zconf.h.in zconf.h +minizip-test: static + cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } + +minizip-clean: + cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; } + mostlyclean: clean -clean: +clean: minizip-clean rm -f *.o *.lo *~ \ example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ example64$(EXE) minigzip64$(EXE) \ @@ -376,20 +385,19 @@ clean: rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov maintainer-clean: distclean -distclean: clean zconf zconf.h.cmakein docs +distclean: clean zconf # zconf.h.cmakein rm -f Makefile zlib.pc configure.log -@rm -f .DS_Store @if [ -f Makefile.in ]; then \ printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ touch -r $(SRCDIR)Makefile.in Makefile ; fi - @if [ ! -f zconf.h.in ]; then rm -f zconf.h zconf.h.cmakein ; fi - @if [ ! -f zlib.3 ]; then rm -f zlib.3.pdf ; fi tags: etags $(SRCDIR)*.[ch] -adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h +adler32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h +zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h @@ -399,7 +407,8 @@ inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h -adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h +adler32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h +zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h diff --git a/deps/zlib/README b/deps/zlib/README index 51106de47..75da52058 100644 --- a/deps/zlib/README +++ b/deps/zlib/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.11 is a general purpose data compression library. All the code is +zlib 1.3.1.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . +https://marknelson.us/posts/1997/01/01/zlib-engine.html . -The changes made in version 1.2.11 are documented in the file ChangeLog. +The changes made in version 1.3.1.1 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . +zlib is available in Java using the java.util.zip package. Follow the API +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . +A Perl interface to zlib and bzip2 written by Paul Marquess +can be found at https://github.com/pmqs/IO-Compress . A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see @@ -64,14 +63,12 @@ Notes for some targets: - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. -- gzdopen is not supported on RISCOS or BEOS. - - For PalmOs, see http://palmzlib.sourceforge.net/ @@ -84,7 +81,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2017 Jean-loup Gailly and Mark Adler + (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -108,7 +105,10 @@ Copyright notice: If you use the zlib library in a product, we would appreciate *not* receiving lengthy legal documents to sign. The sources are provided for free but without warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. +Gailly and Mark Adler; it does not include third-party code. We make all +contributions to and distributions of this project solely in our personal +capacity, and are not conveying any rights to any intellectual property of +any third parties. If you redistribute modified sources, we would appreciate that you include in the file ChangeLog history information documenting your changes. Please read diff --git a/deps/zlib/README-cmake.md b/deps/zlib/README-cmake.md new file mode 100644 index 000000000..7258f9cad --- /dev/null +++ b/deps/zlib/README-cmake.md @@ -0,0 +1,83 @@ +# For building with cmake at least version 3.12 (minizip 3.12) is needed + +In most cases the usual + + cmake -S . -B build -D CMAKE_BUILD_TYPE=Release + +will create everything you need, however if you want something off default you can adjust several options fit your needs. +Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with + + -D