From 8e52f7de82b329273839d3c2ec8770f49ac7334a Mon Sep 17 00:00:00 2001 From: magnum Date: Wed, 25 Dec 2024 01:18:03 +0000 Subject: [PATCH] OpenCL bitlocker, pwsafe and shared twofish: Use shared ror32 This currently ends up with "rotate(x, 32U-(n))" on all platforms anyway so no net change. --- run/opencl/opencl_bitlocker.h | 3 ++- run/opencl/opencl_twofish.h | 3 ++- run/opencl/pwsafe_kernel.cl | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/run/opencl/opencl_bitlocker.h b/run/opencl/opencl_bitlocker.h index b3371033363..a6be3e511dd 100644 --- a/run/opencl/opencl_bitlocker.h +++ b/run/opencl/opencl_bitlocker.h @@ -19,7 +19,8 @@ #ifndef _BITCRACKER_H #define _BITCRACKER_H -#define ROR(x, i) (rotate((x), 32U - (i))) +#include "opencl_rotate.h" +#define ROR(x, i) ror32(x, i) #define SCHEDULE0() \ schedule0 = schedule16 + schedule25 \ diff --git a/run/opencl/opencl_twofish.h b/run/opencl/opencl_twofish.h index 549f0c56b84..10703e6ab88 100644 --- a/run/opencl/opencl_twofish.h +++ b/run/opencl/opencl_twofish.h @@ -38,6 +38,7 @@ #define OPENCL_TWOFISH_H_ #include "opencl_misc.h" +#include "opencl_rotate.h" typedef uchar Twofish_Byte; typedef uint Twofish_UInt32; @@ -49,7 +50,7 @@ typedef struct { #define UINT32_MASK ( (((UInt32)2)<<31) - 1 ) #define ROL32( x, n ) rotate((x), (uint)(n)) -#define ROR32( x, n ) rotate((x), (32U - (n))) +#define ROR32( x, n ) ror32(x, n) #if __OS_X__ #define LARGE_Q_TABLE 0 diff --git a/run/opencl/pwsafe_kernel.cl b/run/opencl/pwsafe_kernel.cl index ab062cafa1d..5126c05a492 100644 --- a/run/opencl/pwsafe_kernel.cl +++ b/run/opencl/pwsafe_kernel.cl @@ -6,6 +6,7 @@ */ #include "opencl_device_info.h" #include "opencl_misc.h" +#include "opencl_rotate.h" #if HAVE_LUT3 #define Ch(x, y, z) lut3(x, y, z, 0xca) @@ -28,7 +29,7 @@ #endif #endif -#define ror(x,n) rotate(x, 32U-n) +#define ror(x, n) ror32(x, n) #define Sigma0(x) ((ror(x, 2)) ^ (ror(x, 13)) ^ (ror(x, 22))) #define Sigma1(x) ((ror(x, 6)) ^ (ror(x, 11)) ^ (ror(x, 25)))