mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-22 22:58:30 +00:00
Moved bit operations out of shared.[hc] and created bitops.[hc]
based on 1aafa13e09
This commit is contained in:
parent
2216920866
commit
ff376ce112
18
include/bitops.h
Normal file
18
include/bitops.h
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
u32 is_power_of_2 (const u32 v);
|
||||
|
||||
u32 rotl32 (const u32 a, const u32 n);
|
||||
u32 rotr32 (const u32 a, const u32 n);
|
||||
u64 rotl64 (const u64 a, const u64 n);
|
||||
u64 rotr64 (const u64 a, const u64 n);
|
||||
|
||||
u32 byte_swap_32 (const u32 n);
|
||||
u64 byte_swap_64 (const u64 n);
|
@ -1400,16 +1400,6 @@ typedef enum kern_run_mp
|
||||
* functions
|
||||
*/
|
||||
|
||||
u32 is_power_of_2(u32 v);
|
||||
|
||||
u32 rotl32 (const u32 a, const u32 n);
|
||||
u32 rotr32 (const u32 a, const u32 n);
|
||||
u64 rotl64 (const u64 a, const u64 n);
|
||||
u64 rotr64 (const u64 a, const u64 n);
|
||||
|
||||
u32 byte_swap_32 (const u32 n);
|
||||
u64 byte_swap_64 (const u64 n);
|
||||
|
||||
u8 hex_convert (const u8 c);
|
||||
u8 hex_to_u8 (const u8 hex[2]);
|
||||
u32 hex_to_u32 (const u8 hex[8]);
|
||||
|
10
src/Makefile
10
src/Makefile
@ -165,7 +165,7 @@ LFLAGS_CROSS_WIN := -lpsapi
|
||||
## Objects
|
||||
##
|
||||
|
||||
NATIVE_OBJS := obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o
|
||||
NATIVE_OBJS := obj/bitops.NATIVE.o obj/ext_OpenCL.NATIVE.o obj/shared.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o
|
||||
|
||||
ifeq ($(UNAME),Linux)
|
||||
NATIVE_OBJS += obj/ext_ADL.NATIVE.o
|
||||
@ -174,8 +174,8 @@ NATIVE_OBJS += obj/ext_nvml.NATIVE.o
|
||||
NATIVE_OBJS += obj/ext_xnvctrl.NATIVE.o
|
||||
endif
|
||||
|
||||
LINUX_32_OBJS := obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o
|
||||
LINUX_64_OBJS := obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o
|
||||
LINUX_32_OBJS := obj/bitops.LINUX.32.o obj/ext_OpenCL.LINUX.32.o obj/shared.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o
|
||||
LINUX_64_OBJS := obj/bitops.LINUX.64.o obj/ext_OpenCL.LINUX.64.o obj/shared.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o
|
||||
|
||||
# Windows CRT file globbing:
|
||||
|
||||
@ -185,8 +185,8 @@ CRT_GLOB_INCLUDE_FOLDER := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
|
||||
include $(CRT_GLOB_INCLUDE_FOLDER)/win_file_globbing.mk
|
||||
|
||||
WIN_32_OBJS := obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_xnvctrl.WIN.32.o $(CRT_GLOB_32)
|
||||
WIN_64_OBJS := obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_xnvctrl.WIN.64.o $(CRT_GLOB_64)
|
||||
WIN_32_OBJS := obj/bitops.WIN.32.o obj/ext_OpenCL.WIN.32.o obj/shared.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_xnvctrl.WIN.32.o $(CRT_GLOB_32)
|
||||
WIN_64_OBJS := obj/bitops.WIN.64.o obj/ext_OpenCL.WIN.64.o obj/shared.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_xnvctrl.WIN.64.o $(CRT_GLOB_64)
|
||||
|
||||
##
|
||||
## Targets: Global
|
||||
|
51
src/bitops.c
Normal file
51
src/bitops.c
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "bitops.h"
|
||||
|
||||
u32 is_power_of_2 (const u32 v)
|
||||
{
|
||||
return (v && !(v & (v - 1)));
|
||||
}
|
||||
|
||||
u32 rotl32 (const u32 a, const u32 n)
|
||||
{
|
||||
return ((a << n) | (a >> (32 - n)));
|
||||
}
|
||||
|
||||
u32 rotr32 (const u32 a, const u32 n)
|
||||
{
|
||||
return ((a >> n) | (a << (32 - n)));
|
||||
}
|
||||
|
||||
u64 rotl64 (const u64 a, const u64 n)
|
||||
{
|
||||
return ((a << n) | (a >> (64 - n)));
|
||||
}
|
||||
|
||||
u64 rotr64 (const u64 a, const u64 n)
|
||||
{
|
||||
return ((a >> n) | (a << (64 - n)));
|
||||
}
|
||||
|
||||
u32 byte_swap_32 (const u32 n)
|
||||
{
|
||||
return (n & 0xff000000) >> 24
|
||||
| (n & 0x00ff0000) >> 8
|
||||
| (n & 0x0000ff00) << 8
|
||||
| (n & 0x000000ff) << 24;
|
||||
}
|
||||
|
||||
u64 byte_swap_64 (const u64 n)
|
||||
{
|
||||
return (n & 0xff00000000000000ULL) >> 56
|
||||
| (n & 0x00ff000000000000ULL) >> 40
|
||||
| (n & 0x0000ff0000000000ULL) >> 24
|
||||
| (n & 0x000000ff00000000ULL) >> 8
|
||||
| (n & 0x00000000ff000000ULL) << 8
|
||||
| (n & 0x0000000000ff0000ULL) << 24
|
||||
| (n & 0x000000000000ff00ULL) << 40
|
||||
| (n & 0x00000000000000ffULL) << 56;
|
||||
}
|
@ -14,17 +14,18 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <common.h>
|
||||
#include <shared.h>
|
||||
#include <rp_kernel_on_cpu.h>
|
||||
#include <getopt.h>
|
||||
#include "common.h"
|
||||
#include "bitops.h"
|
||||
#include "shared.h"
|
||||
#include "rp_kernel_on_cpu.h"
|
||||
#include "getopt.h"
|
||||
|
||||
static const char *PROGNAME = "hashcat";
|
||||
static const char *PROGNAME = "hashcat";
|
||||
|
||||
const uint VERSION_BIN = 310;
|
||||
const uint RESTORE_MIN = 300;
|
||||
|
||||
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
|
||||
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
|
||||
|
||||
#define INCR_RULES 10000
|
||||
#define INCR_SALTS 100000
|
||||
|
53
src/shared.c
53
src/shared.c
@ -15,58 +15,11 @@
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
#include <shared.h>
|
||||
#include "shared.h"
|
||||
#include "bitops.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/**
|
||||
* basic bit handling
|
||||
*/
|
||||
|
||||
u32 is_power_of_2(u32 v)
|
||||
{
|
||||
return (v && !(v & (v - 1)));
|
||||
}
|
||||
|
||||
u32 rotl32 (const u32 a, const u32 n)
|
||||
{
|
||||
return ((a << n) | (a >> (32 - n)));
|
||||
}
|
||||
|
||||
u32 rotr32 (const u32 a, const u32 n)
|
||||
{
|
||||
return ((a >> n) | (a << (32 - n)));
|
||||
}
|
||||
|
||||
u64 rotl64 (const u64 a, const u64 n)
|
||||
{
|
||||
return ((a << n) | (a >> (64 - n)));
|
||||
}
|
||||
|
||||
u64 rotr64 (const u64 a, const u64 n)
|
||||
{
|
||||
return ((a >> n) | (a << (64 - n)));
|
||||
}
|
||||
|
||||
u32 byte_swap_32 (const u32 n)
|
||||
{
|
||||
return (n & 0xff000000) >> 24
|
||||
| (n & 0x00ff0000) >> 8
|
||||
| (n & 0x0000ff00) << 8
|
||||
| (n & 0x000000ff) << 24;
|
||||
}
|
||||
|
||||
u64 byte_swap_64 (const u64 n)
|
||||
{
|
||||
return (n & 0xff00000000000000ULL) >> 56
|
||||
| (n & 0x00ff000000000000ULL) >> 40
|
||||
| (n & 0x0000ff0000000000ULL) >> 24
|
||||
| (n & 0x000000ff00000000ULL) >> 8
|
||||
| (n & 0x00000000ff000000ULL) << 8
|
||||
| (n & 0x0000000000ff0000ULL) << 24
|
||||
| (n & 0x000000000000ff00ULL) << 40
|
||||
| (n & 0x00000000000000ffULL) << 56;
|
||||
}
|
||||
|
||||
/**
|
||||
* ciphers for use on cpu
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user