mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Migrate correct parsing function
This commit is contained in:
parent
cc59de6538
commit
9aeb4f602e
@ -822,6 +822,7 @@ typedef enum hash_type
|
||||
HASH_TYPE_MD4 = 1,
|
||||
HASH_TYPE_MD5 = 2,
|
||||
HASH_TYPE_SHA1 = 4,
|
||||
HASH_TYPE_SHA224 = 5,
|
||||
HASH_TYPE_SHA256 = 6,
|
||||
HASH_TYPE_SHA384 = 7,
|
||||
HASH_TYPE_SHA512 = 8,
|
||||
@ -1182,6 +1183,7 @@ int sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_bu
|
||||
int sha1b64_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha1b64s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha1s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha224_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha256_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha256s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
int sha384_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig);
|
||||
|
@ -5155,6 +5155,55 @@ int oraclet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int sha224_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
token_t token;
|
||||
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 56;
|
||||
token.len_max[0] = 56;
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer (input_buf, input_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[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]);
|
||||
|
||||
if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE)
|
||||
{
|
||||
digest[0] -= SHA224M_A;
|
||||
digest[1] -= SHA224M_B;
|
||||
digest[2] -= SHA224M_C;
|
||||
digest[3] -= SHA224M_D;
|
||||
digest[4] -= SHA224M_E;
|
||||
digest[5] -= SHA224M_F;
|
||||
digest[6] -= SHA224M_G;
|
||||
}
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int sha256_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "bitops.h"
|
||||
#include "convert.h"
|
||||
#include "shared.h"
|
||||
#include "inc_hash_constants.h"
|
||||
|
||||
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
|
||||
static const u32 DGST_POS0 = 6;
|
||||
@ -54,9 +53,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 56;
|
||||
token.len_max[0] = 56;
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
token.len[0] = 56;
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
||||
@ -64,6 +62,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
|
||||
const u8 *hash_pos = token.buf[0];
|
||||
const int hash_len = token.len[0];
|
||||
|
||||
if (hash_len != 56) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
digest[0] = hex_to_u32 (hash_pos + 0);
|
||||
digest[1] = hex_to_u32 (hash_pos + 8);
|
||||
@ -73,17 +74,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
digest[5] = hex_to_u32 (hash_pos + 40);
|
||||
digest[6] = hex_to_u32 (hash_pos + 48);
|
||||
|
||||
if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE)
|
||||
{
|
||||
digest[0] -= SHA224M_A;
|
||||
digest[1] -= SHA224M_B;
|
||||
digest[2] -= SHA224M_C;
|
||||
digest[3] -= SHA224M_D;
|
||||
digest[4] -= SHA224M_E;
|
||||
digest[5] -= SHA224M_F;
|
||||
digest[6] -= SHA224M_G;
|
||||
}
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user