|
|
|
@ -5492,26 +5492,31 @@ int chacha20_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
|
|
|
|
|
|
|
|
|
|
salt_t *salt = (salt_t *) hash_buf->salt;
|
|
|
|
|
|
|
|
|
|
u8 *position_marker = (u8 *) strchr ((const char *) input_buf, '*') + 1;
|
|
|
|
|
u8 *position_marker = (u8 *) strchr ((const char *) input_buf, '*');
|
|
|
|
|
if (position_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
|
|
|
|
|
position_marker++;
|
|
|
|
|
if (is_valid_hex_string (position_marker, 16) == false) return (PARSER_SALT_ENCODING);
|
|
|
|
|
|
|
|
|
|
u8 *offset_marker = (u8 *) strchr ((const char *) position_marker, '*') + 1;
|
|
|
|
|
u8 *offset_marker = (u8 *) strchr ((const char *) position_marker, '*');
|
|
|
|
|
if (offset_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
|
|
|
|
|
offset_marker++;
|
|
|
|
|
|
|
|
|
|
int offset = atoi ((char*) offset_marker);
|
|
|
|
|
if (offset > 63) return (PARSER_SALT_VALUE);
|
|
|
|
|
|
|
|
|
|
u8 *iv_marker = (u8 *) strchr ((const char *) offset_marker, '*') + 1;
|
|
|
|
|
u8 *iv_marker = (u8 *) strchr ((const char *) offset_marker, '*');
|
|
|
|
|
if (iv_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
|
|
|
|
|
iv_marker++;
|
|
|
|
|
if (is_valid_hex_string (iv_marker, 16) == false) return (PARSER_SALT_ENCODING);
|
|
|
|
|
|
|
|
|
|
u8 *plain_marker = (u8 *) strchr ((const char *) iv_marker, '*') + 1;
|
|
|
|
|
u8 *plain_marker = (u8 *) strchr ((const char *) iv_marker, '*');
|
|
|
|
|
if (plain_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
|
|
|
|
|
plain_marker++;
|
|
|
|
|
if (is_valid_hex_string (plain_marker, 16) == false) return (PARSER_SALT_ENCODING);
|
|
|
|
|
|
|
|
|
|
u8 *cipher_marker = (u8 *) strchr ((const char *) plain_marker, '*') + 1;
|
|
|
|
|
u8 *cipher_marker = (u8 *) strchr ((const char *) plain_marker, '*');
|
|
|
|
|
if (cipher_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
|
|
|
|
|
cipher_marker++;
|
|
|
|
|
if (is_valid_hex_string (cipher_marker, 16) == false) return (PARSER_SALT_ENCODING);
|
|
|
|
|
|
|
|
|
|
chacha20->iv[0] = hex_to_u32 ((const u8 *) iv_marker + 8);
|
|
|
|
|