From 264ec951c28f6478191ea03e523a8eb535c7a01a Mon Sep 17 00:00:00 2001 From: DoZ10 Date: Mon, 15 May 2017 19:21:49 -0400 Subject: [PATCH] Enhanced test.pl for 15400 and removed endianess confusion --- src/interface.c | 14 +++++++------- tools/test.pl | 13 ++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/interface.c b/src/interface.c index cfc0f67ab..9ee2a3983 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5347,11 +5347,11 @@ int chacha20_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U chacha20->iv[0] = hex_to_u32 ((const u8 *) iv_marker + 8); chacha20->iv[1] = hex_to_u32 ((const u8 *) iv_marker + 0); - chacha20->plain[0] = hex_to_u32 ((const u8 *) plain_marker + 8); - chacha20->plain[1] = hex_to_u32 ((const u8 *) plain_marker + 0); + chacha20->plain[0] = hex_to_u32 ((const u8 *) plain_marker + 0); + chacha20->plain[1] = hex_to_u32 ((const u8 *) plain_marker + 8); - chacha20->position[0] = byte_swap_32(hex_to_u32 ((const u8 *) position_marker + 8)); - chacha20->position[1] = byte_swap_32(hex_to_u32 ((const u8 *) position_marker + 0)); + chacha20->position[0] = hex_to_u32 ((const u8 *) position_marker + 0); + chacha20->position[1] = hex_to_u32 ((const u8 *) position_marker + 8); chacha20->offset = offset; @@ -18566,13 +18566,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le snprintf (out_buf, out_len - 1, "%s*%08x%08x*%d*%08x%08x*%08x%08x*%08x%08x", SIGNATURE_CHACHA20, - chacha20->position[1], - chacha20->position[0], + byte_swap_32(chacha20->position[0]), + byte_swap_32(chacha20->position[1]), chacha20->offset, byte_swap_32(chacha20->iv[1]), byte_swap_32(chacha20->iv[0]), - byte_swap_32(chacha20->plain[1]), byte_swap_32(chacha20->plain[0]), + byte_swap_32(chacha20->plain[1]), ptr[1], ptr[0]); } diff --git a/tools/test.pl b/tools/test.pl index 41c23701a..79bb756f6 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -8156,20 +8156,23 @@ END_CODE } elsif ($mode == 15400) { - my $eight_byte_iv = pack("H*", "0000000000000000"); - my $eight_byte_counter = pack("H*", "0100000000000000"); # little endian 64 bits + my $iv = "0200000000000001"; + my $counter = "0400000000000003"; + my $plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0a2b4c6d8e"; + my $eight_byte_iv = pack("H*", $iv); + my $eight_byte_counter = pack("H*", $counter); my $offset = int(rand(63)); my $pad_len = 32 - length $word_buf; my $key = $word_buf . "\0" x $pad_len; my $cipher = Crypt::OpenSSH::ChachaPoly->new($key); $cipher->ivsetup($eight_byte_iv, $eight_byte_counter); - - my $enc = $cipher->encrypt("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + + my $enc = $cipher->encrypt($plaintext); my $enc_offset = substr($enc, $offset, 8); $hash_buf = $enc_offset; - $tmp_hash = sprintf ("\$Chacha20\$\*%08x%08x\*%d\*0000000000000000\*4141414141414141\*%s", (unpack("V*", $eight_byte_counter))[1], (unpack("V*", $eight_byte_counter))[0], $offset, unpack("H*", $enc_offset)); + $tmp_hash = sprintf ("\$Chacha20\$\*%s\*%d\*%s\*%s\*%s", $counter, $offset, $iv, unpack("H*", substr($plaintext, $offset, 8)), unpack("H*", $enc_offset)); } elsif ($mode == 99999) {