From db4ec8ed2c7159242f6b9aae3af5684645fbd962 Mon Sep 17 00:00:00 2001 From: unix-ninja Date: Wed, 17 Oct 2018 16:34:34 -0400 Subject: [PATCH] Fix formatting to comply with hashcat coding guidelines --- OpenCL/m18100_a0-pure.cl | 4 ++-- OpenCL/m18100_a3-pure.cl | 4 ++-- src/hashes.c | 4 ++-- src/interface.c | 12 +++++------- tools/test.pl | 6 +++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/OpenCL/m18100_a0-pure.cl b/OpenCL/m18100_a0-pure.cl index 7ab09d5d1..e577d62ae 100644 --- a/OpenCL/m18100_a0-pure.cl +++ b/OpenCL/m18100_a0-pure.cl @@ -67,7 +67,7 @@ __kernel void m18100_mxx (__global pw_t *pws, __constant const kernel_rule_t *ru // grab 4 consecutive bytes of the hash, starting at offset // on some systems, &3 is faster than %4, so we will use it in our switch() - switch(otp_offset&3) + switch(otp_offset & 3) { case 1: otp_code = ((ctx.opad.h[otp_offset/4] & 0x00ffffff) << 8) | ((ctx.opad.h[otp_offset/4+1] & 0xff000000) >> 24); @@ -160,7 +160,7 @@ __kernel void m18100_sxx (__global pw_t *pws, __constant const kernel_rule_t *ru // grab 4 consecutive bytes of the hash, starting at offset // on some systems, &3 is faster than %4, so we will use it in our switch() - switch(otp_offset&3) + switch(otp_offset & 3) { case 1: otp_code = ((ctx.opad.h[otp_offset/4] & 0x00ffffff) << 8) | ((ctx.opad.h[otp_offset/4+1] & 0xff000000) >> 24); diff --git a/OpenCL/m18100_a3-pure.cl b/OpenCL/m18100_a3-pure.cl index 1352338a1..9838c34aa 100644 --- a/OpenCL/m18100_a3-pure.cl +++ b/OpenCL/m18100_a3-pure.cl @@ -76,7 +76,7 @@ __kernel void m18100_mxx (__global pw_t *pws, __global const kernel_rule_t *rule // grab 4 consecutive bytes of the hash, starting at offset // on some systems, &3 is faster than %4, so we will use it in our switch() - switch(otp_offset&3) + switch(otp_offset & 3) { case 1: otp_code = ((ctx.opad.h[otp_offset/4] & 0x00ffffff) << 8) | ((ctx.opad.h[otp_offset/4+1] & 0xff000000) >> 24); @@ -180,7 +180,7 @@ __kernel void m18100_sxx (__global pw_t *pws, __global const kernel_rule_t *rule // grab 4 consecutive bytes of the hash, starting at offset // on some systems, &3 is faster than %4, so we will use it in our switch() - switch(otp_offset&3) + switch(otp_offset & 3) { case 1: otp_code = ((ctx.opad.h[otp_offset/4] & 0x00ffffff) << 8) | ((ctx.opad.h[otp_offset/4+1] & 0xff000000) >> 24); diff --git a/src/hashes.c b/src/hashes.c index 7ade9faac..1681a585e 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -284,10 +284,10 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl // encode our plain base32_encode (int_to_base32, (const u8 *) plain_ptr, plain_len, (u8 *) temp_buf); - plain_len = strlen((const char *) temp_buf); + plain_len = strlen ((const char *) temp_buf); // copy the base32 content into our plain buffer - plain_ptr = (u8 *) strdup((const char *) temp_ptr); + plain_ptr = (u8 *) strdup ((const char *) temp_ptr); } // crackpos diff --git a/src/interface.c b/src/interface.c index 0e4ac545a..1ee32e416 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5193,7 +5193,7 @@ int totp_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE int otp_code = 0; for (int i = 0; i < 6; i++) { - otp_code = otp_code * 10 + itoa32_to_int(input_buf[i]); + otp_code = otp_code * 10 + itoa32_to_int (input_buf[i]); } if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); @@ -5203,16 +5203,14 @@ int totp_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE // convert ascii timestamp to ulong timestamp unsigned long timestamp = 0; - timestamp = hc_strtoul((const char *) salt_pos, NULL, 10); + timestamp = hc_strtoul ((const char *) salt_pos, NULL, 10); // 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 - for (int i = 2; i--; timestamp >>= 32) - { - salt->salt_buf[i] = byte_swap_32(timestamp); - } + salt->salt_buf[1] = byte_swap_32 (timestamp); + salt->salt_buf[0] = byte_swap_32 (timestamp >> 32); // our salt will always be 8 bytes salt->salt_len = 8; @@ -22337,7 +22335,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // for now, we only need to worry about 32 bit counters. // 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. - snprintf (out_buf, out_len - 1, "%06d:%d", digest_buf[1], byte_swap_32(salt.salt_buf[1]) * 30); + snprintf (out_buf, out_len - 1, "%06d:%d", digest_buf[1], byte_swap_32 (salt.salt_buf[1]) * 30); } else if (hash_mode == 99999) { diff --git a/tools/test.pl b/tools/test.pl index c5620d27b..f10ae9b79 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -9974,8 +9974,8 @@ END_CODE } elsif ($mode == 18100) { - my $paddedTime = sprintf("%016x", int(int($salt_buf) / 30)); - my $data = pack('H*', $paddedTime); + my $paddedTime = sprintf ("%016x", int (int ($salt_buf) / 30)); + my $data = pack ('H*', $paddedTime); my $key = $word_buf; $hash_buf = hmac_hex ($data, $key, \&sha1, 64); @@ -9987,7 +9987,7 @@ END_CODE $token %= 1000000; ## token must be leading zero padded, and salt leading zero stripped - $tmp_hash = sprintf ("%06d:%d", $token, int($salt_buf)); + $tmp_hash = sprintf ("%06d:%d", $token, int ($salt_buf)); } elsif ($mode == 99999) {