mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-09 07:11:03 +00:00
The following parser functions have been rewritten to make use of
input_tokenizer(): androidpin_parse_hash chap_parse_hash lotus5_parse_hash lotus6_parse_hash radmin2_parse_hash gost2012sbog_256_parse_hash gost2012sbog_512_parse_hash
This commit is contained in:
parent
8b2478d744
commit
afd5fa760c
@ -1020,14 +1020,10 @@ typedef struct hccapx hccapx_t;
|
||||
|
||||
typedef enum display_len
|
||||
{
|
||||
DISPLAY_LEN_MIN_4800 = 32 + 1 + 32 + 1 + 2,
|
||||
DISPLAY_LEN_MAX_4800 = 32 + 1 + 32 + 1 + 2,
|
||||
DISPLAY_LEN_MIN_5300 = 48,
|
||||
DISPLAY_LEN_MAX_5300 = 1024,
|
||||
DISPLAY_LEN_MIN_5400 = 56,
|
||||
DISPLAY_LEN_MAX_5400 = 1024,
|
||||
DISPLAY_LEN_MIN_5800 = 40 + 1 + 1,
|
||||
DISPLAY_LEN_MAX_5800 = 40 + 1 + 16,
|
||||
DISPLAY_LEN_MIN_6300 = 6 + 1 + 8 + 22,
|
||||
DISPLAY_LEN_MAX_6300 = 6 + 1 + 48 + 22,
|
||||
DISPLAY_LEN_MIN_6400 = 9 + 2 + 1 + 16 + 1 + 43,
|
||||
@ -1068,10 +1064,6 @@ typedef enum display_len
|
||||
DISPLAY_LEN_MAX_8400 = 40 + 1 + 40,
|
||||
DISPLAY_LEN_MIN_8500 = 6 + 1 + 1 + 1 + 1,
|
||||
DISPLAY_LEN_MAX_8500 = 6 + 1 + 8 + 1 + 16,
|
||||
DISPLAY_LEN_MIN_8600 = 32,
|
||||
DISPLAY_LEN_MAX_8600 = 32,
|
||||
DISPLAY_LEN_MIN_8700 = 22,
|
||||
DISPLAY_LEN_MAX_8700 = 22,
|
||||
DISPLAY_LEN_MIN_8800 = 1 + 3 + 1 + 2 + 1 + 32 + 1 + 2 + 1 + 32 + 1 + 3072,
|
||||
DISPLAY_LEN_MAX_8800 = 1 + 3 + 1 + 2 + 1 + 32 + 1 + 2 + 1 + 32 + 1 + 3072,
|
||||
DISPLAY_LEN_MIN_8900 = 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 44,
|
||||
@ -1096,8 +1088,6 @@ typedef enum display_len
|
||||
DISPLAY_LEN_MAX_9800 = 12 + 1 + 32 + 1 + 32 + 1 + 40,
|
||||
DISPLAY_LEN_MIN_9820 = 12 + 1 + 32 + 1 + 32 + 1 + 40 + 1 + 10,
|
||||
DISPLAY_LEN_MAX_9820 = 12 + 1 + 32 + 1 + 32 + 1 + 40 + 1 + 10,
|
||||
DISPLAY_LEN_MIN_9900 = 32,
|
||||
DISPLAY_LEN_MAX_9900 = 32,
|
||||
DISPLAY_LEN_MIN_10000 = 13 + 1 + 1 + 1 + 0 + 44,
|
||||
DISPLAY_LEN_MAX_10000 = 13 + 1 + 6 + 1 + 15 + 44,
|
||||
DISPLAY_LEN_MIN_10100 = 16 + 1 + 1 + 1 + 1 + 1 + 32,
|
||||
@ -1134,10 +1124,6 @@ typedef enum display_len
|
||||
DISPLAY_LEN_MAX_11500 = 8 + 1 + 8,
|
||||
DISPLAY_LEN_MIN_11600 = 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 32 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 0 + 0 + 0 + 0,
|
||||
DISPLAY_LEN_MAX_11600 = 1 + 2 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 64 + 1 + 1 + 1 + 32 + 1 + 10 + 1 + 4 + 1 + 4 + 1 + 655056 + 1 + 4 + 1 + 10,
|
||||
DISPLAY_LEN_MIN_11700 = 64,
|
||||
DISPLAY_LEN_MAX_11700 = 64,
|
||||
DISPLAY_LEN_MIN_11800 = 128,
|
||||
DISPLAY_LEN_MAX_11800 = 128,
|
||||
DISPLAY_LEN_MIN_11900 = 3 + 1 + 1 + 0 + 1 + 12,
|
||||
DISPLAY_LEN_MAX_11900 = 3 + 6 + 1 + 64 + 1 + 88,
|
||||
DISPLAY_LEN_MIN_12000 = 4 + 1 + 1 + 0 + 1 + 16,
|
||||
|
306
src/interface.c
306
src/interface.c
@ -5090,14 +5090,6 @@ int vb30_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
|
||||
token.len_max[1] = 31;
|
||||
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 (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
@ -6707,19 +6699,35 @@ int whirlpool_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
|
||||
|
||||
int androidpin_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_5800) || (input_len > DISPLAY_LEN_MAX_5800)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
salt_t *salt = hash_buf->salt;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 40) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
|
||||
digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
|
||||
digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
|
||||
token.token_cnt = 2;
|
||||
|
||||
token.sep[0] = hashconfig->separator;
|
||||
token.len_min[0] = 40;
|
||||
token.len_max[0] = 40;
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
token.len_min[1] = 1;
|
||||
token.len_max[1] = 16;
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
|
||||
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[0] = byte_swap_32 (digest[0]);
|
||||
digest[1] = byte_swap_32 (digest[1]);
|
||||
@ -6727,19 +6735,12 @@ int androidpin_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
|
||||
digest[3] = byte_swap_32 (digest[3]);
|
||||
digest[4] = byte_swap_32 (digest[4]);
|
||||
|
||||
if (input_buf[40] != hashconfig->separator) return (PARSER_SEPARATOR_UNMATCHED);
|
||||
u8 *salt_pos = token.buf[1];
|
||||
int salt_len = token.len[1];
|
||||
|
||||
u32 salt_len = input_len - 40 - 1;
|
||||
const bool parse_rc = parse_and_store_generic_salt ((u8 *) salt->salt_buf, (int *) &salt->salt_len, salt_pos, salt_len, hashconfig);
|
||||
|
||||
u8 *salt_buf = input_buf + 40 + 1;
|
||||
|
||||
u8 *salt_buf_ptr = (u8 *) salt->salt_buf;
|
||||
|
||||
salt_len = parse_and_store_salt_legacy (salt_buf_ptr, salt_buf, salt_len, hashconfig);
|
||||
|
||||
if (salt_len == UINT_MAX) return (PARSER_SALT_LENGTH);
|
||||
|
||||
salt->salt_len = salt_len;
|
||||
if (parse_rc == false) return (PARSER_SALT_LENGTH);
|
||||
|
||||
salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
|
||||
|
||||
@ -8246,18 +8247,41 @@ int netscaler_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
|
||||
|
||||
int chap_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_4800) || (input_len > DISPLAY_LEN_MAX_4800)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
salt_t *salt = hash_buf->salt;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 32) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
|
||||
digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
|
||||
token.token_cnt = 3;
|
||||
|
||||
token.sep[0] = hashconfig->separator;
|
||||
token.len_min[0] = 32;
|
||||
token.len_max[0] = 32;
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
token.sep[1] = hashconfig->separator;
|
||||
token.len_min[1] = 32;
|
||||
token.len_max[1] = 32;
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
token.len_min[2] = 2;
|
||||
token.len_max[2] = 2;
|
||||
token.attr[2] = 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);
|
||||
|
||||
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_PRECOMPUTE_MERKLE)
|
||||
{
|
||||
@ -8267,26 +8291,16 @@ int chap_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
|
||||
digest[3] -= MD5M_D;
|
||||
}
|
||||
|
||||
if (input_buf[32] != hashconfig->separator) return (PARSER_SEPARATOR_UNMATCHED);
|
||||
u8 *salt_pos = token.buf[1];
|
||||
|
||||
u8 *salt_buf_ptr = input_buf + 32 + 1;
|
||||
|
||||
u32 *salt_buf = salt->salt_buf;
|
||||
|
||||
if (is_valid_hex_string (salt_buf_ptr, 32) == false) return (PARSER_SALT_ENCODING);
|
||||
|
||||
salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf_ptr[ 0]);
|
||||
salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf_ptr[ 8]);
|
||||
salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf_ptr[16]);
|
||||
salt_buf[3] = hex_to_u32 ((const u8 *) &salt_buf_ptr[24]);
|
||||
salt->salt_buf[0] = hex_to_u32 (salt_pos + 0);
|
||||
salt->salt_buf[1] = hex_to_u32 (salt_pos + 8);
|
||||
salt->salt_buf[2] = hex_to_u32 (salt_pos + 16);
|
||||
salt->salt_buf[3] = hex_to_u32 (salt_pos + 24);
|
||||
|
||||
salt->salt_len = 16 + 1;
|
||||
|
||||
if (input_buf[65] != hashconfig->separator) return (PARSER_SEPARATOR_UNMATCHED);
|
||||
|
||||
u8 *idbyte_buf_ptr = input_buf + 32 + 1 + 32 + 1;
|
||||
|
||||
salt_buf[4] = hex_to_u8 ((const u8 *) &idbyte_buf_ptr[0]) & 0xff;
|
||||
salt->salt_buf[4] = hex_to_u8 (token.buf[2]);
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
@ -8751,33 +8765,68 @@ int des_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED
|
||||
|
||||
int lotus5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_8600) || (input_len > DISPLAY_LEN_MAX_8600)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 32) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
|
||||
digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 32;
|
||||
token.len_max[0] = 32;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int lotus6_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_8700) || (input_len > DISPLAY_LEN_MAX_8700)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
if ((input_buf[0] != '(') || (input_buf[1] != 'G') || (input_buf[21] != ')')) return (PARSER_SIGNATURE_UNMATCHED);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
salt_t *salt = hash_buf->salt;
|
||||
|
||||
token_t token;
|
||||
|
||||
token.token_cnt = 4;
|
||||
|
||||
token.len[0] = 1;
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH;
|
||||
|
||||
token.len[1] = 1;
|
||||
token.attr[1] = TOKEN_ATTR_FIXED_LENGTH;
|
||||
|
||||
token.len[2] = 19;
|
||||
token.attr[2] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
token.len[3] = 1;
|
||||
token.attr[3] = TOKEN_ATTR_FIXED_LENGTH;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
|
||||
if (token.buf[0][0] != '(') return (PARSER_SIGNATURE_UNMATCHED);
|
||||
if (token.buf[1][0] != 'G') return (PARSER_SIGNATURE_UNMATCHED);
|
||||
if (token.buf[3][0] != ')') return (PARSER_SIGNATURE_UNMATCHED);
|
||||
|
||||
u8 *hash_pos = token.buf[2];
|
||||
int hash_len = token.len[2];
|
||||
|
||||
u8 tmp_buf[120] = { 0 };
|
||||
|
||||
base64_decode (lotus64_to_int, (const u8 *) input_buf + 2, input_len - 3, tmp_buf);
|
||||
base64_decode (lotus64_to_int, hash_pos, hash_len, tmp_buf);
|
||||
|
||||
tmp_buf[3] += -4; // dont ask!
|
||||
|
||||
@ -8789,7 +8838,7 @@ int lotus6_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
|
||||
|
||||
// yes, only 9 byte are needed to crack, but 10 to display
|
||||
|
||||
salt->salt_buf_pc[7] = input_buf[20];
|
||||
salt->salt_buf_pc[7] = hash_pos[18];
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
@ -9102,14 +9151,6 @@ int skype_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
|
||||
token.len_max[1] = SALT_MAX - 8;
|
||||
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 (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
@ -10524,16 +10565,27 @@ int oldoffice34cm2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, M
|
||||
|
||||
int radmin2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_9900) || (input_len > DISPLAY_LEN_MAX_9900)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 32) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
|
||||
digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 32;
|
||||
token.len_max[0] = 32;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
@ -10907,14 +10959,6 @@ int redmine_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
|
||||
token.len_max[1] = 32;
|
||||
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 (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
@ -10972,14 +11016,6 @@ int punbb_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
|
||||
token.len_max[1] = 12;
|
||||
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 (input_buf, input_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
@ -12970,48 +13006,70 @@ int seven_zip_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
|
||||
|
||||
int gost2012sbog_256_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_11700) || (input_len > DISPLAY_LEN_MAX_11700)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 64) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
|
||||
digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
|
||||
digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
|
||||
digest[5] = hex_to_u32 ((const u8 *) &input_buf[40]);
|
||||
digest[6] = hex_to_u32 ((const u8 *) &input_buf[48]);
|
||||
digest[7] = hex_to_u32 ((const u8 *) &input_buf[56]);
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 64;
|
||||
token.len_max[0] = 64;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int gost2012sbog_512_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig)
|
||||
{
|
||||
if ((input_len < DISPLAY_LEN_MIN_11800) || (input_len > DISPLAY_LEN_MAX_11800)) return (PARSER_GLOBAL_LENGTH);
|
||||
|
||||
u32 *digest = (u32 *) hash_buf->digest;
|
||||
|
||||
if (is_valid_hex_string (input_buf, 128) == false) return (PARSER_HASH_ENCODING);
|
||||
token_t token;
|
||||
|
||||
digest[ 0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
|
||||
digest[ 1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
|
||||
digest[ 2] = hex_to_u32 ((const u8 *) &input_buf[ 16]);
|
||||
digest[ 3] = hex_to_u32 ((const u8 *) &input_buf[ 24]);
|
||||
digest[ 4] = hex_to_u32 ((const u8 *) &input_buf[ 32]);
|
||||
digest[ 5] = hex_to_u32 ((const u8 *) &input_buf[ 40]);
|
||||
digest[ 6] = hex_to_u32 ((const u8 *) &input_buf[ 48]);
|
||||
digest[ 7] = hex_to_u32 ((const u8 *) &input_buf[ 56]);
|
||||
digest[ 8] = hex_to_u32 ((const u8 *) &input_buf[ 64]);
|
||||
digest[ 9] = hex_to_u32 ((const u8 *) &input_buf[ 72]);
|
||||
digest[10] = hex_to_u32 ((const u8 *) &input_buf[ 80]);
|
||||
digest[11] = hex_to_u32 ((const u8 *) &input_buf[ 88]);
|
||||
digest[12] = hex_to_u32 ((const u8 *) &input_buf[ 96]);
|
||||
digest[13] = hex_to_u32 ((const u8 *) &input_buf[104]);
|
||||
digest[14] = hex_to_u32 ((const u8 *) &input_buf[112]);
|
||||
digest[15] = hex_to_u32 ((const u8 *) &input_buf[120]);
|
||||
token.token_cnt = 1;
|
||||
|
||||
token.len_min[0] = 128;
|
||||
token.len_max[0] = 128;
|
||||
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);
|
||||
|
||||
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[ 8] = hex_to_u32 (hash_pos + 64);
|
||||
digest[ 9] = hex_to_u32 (hash_pos + 72);
|
||||
digest[10] = hex_to_u32 (hash_pos + 80);
|
||||
digest[11] = hex_to_u32 (hash_pos + 88);
|
||||
digest[12] = hex_to_u32 (hash_pos + 96);
|
||||
digest[13] = hex_to_u32 (hash_pos + 104);
|
||||
digest[14] = hex_to_u32 (hash_pos + 112);
|
||||
digest[15] = hex_to_u32 (hash_pos + 120);
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user