1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

make it work with Apple Metal

This commit is contained in:
Your Name 2023-06-30 10:34:41 +02:00
parent b4c12ee628
commit 5927fea637
2 changed files with 16 additions and 16 deletions

View File

@ -25,17 +25,17 @@
} }
#define PUT_UINT32BE(n, b, i) \ #define PUT_UINT32BE(n, b, i) \
{ \ { \
(b)[(i) ] = (uchar) ((n) >> 24); \ (b)[(i) ] = (u8) ((n) >> 24); \
(b)[(i) + 1] = (uchar) ((n) >> 16); \ (b)[(i) + 1] = (u8) ((n) >> 16); \
(b)[(i) + 2] = (uchar) ((n) >> 8); \ (b)[(i) + 2] = (u8) ((n) >> 8); \
(b)[(i) + 3] = (uchar) ((n) ); \ (b)[(i) + 3] = (u8) ((n) ); \
} }
typedef struct { typedef struct {
uint K[32]; uint K[32];
} CAST_KEY; } CAST_KEY;
#define GETBYTE(x, y) (uint)(uchar)((x)>>(8*(y))) #define GETBYTE(x, y) (uint)(u8)((x)>>(8*(y)))
/* Macros to access 8-bit bytes out of a 32-bit word */ /* Macros to access 8-bit bytes out of a 32-bit word */
#define U8a(x) GETBYTE(x,3) #define U8a(x) GETBYTE(x,3)
@ -600,11 +600,11 @@ CONSTANT_AS uint S[8][256] = {
#define _CAST_F2(l, r, i, j) _CAST_f2(l, r, K[i], K[i+j]) #define _CAST_F2(l, r, i, j) _CAST_f2(l, r, K[i], K[i+j])
#define _CAST_F3(l, r, i, j) _CAST_f3(l, r, K[i], K[i+j]) #define _CAST_F3(l, r, i, j) _CAST_f3(l, r, K[i], K[i+j])
inline void Cast5Encrypt(const uchar *inBlock, uchar *outBlock, CAST_KEY *key) inline void Cast5Encrypt(PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key)
{ {
uint l; GET_UINT32BE(l, inBlock, 0); uint l; GET_UINT32BE(l, inBlock, 0);
uint r; GET_UINT32BE(r, inBlock, 4); uint r; GET_UINT32BE(r, inBlock, 4);
uint *K = key->K; PRIVATE_AS uint *K = key->K;
uint t; uint t;
/* Do the work */ /* Do the work */
@ -630,11 +630,11 @@ inline void Cast5Encrypt(const uchar *inBlock, uchar *outBlock, CAST_KEY *key)
PUT_UINT32BE(l, outBlock, 4); PUT_UINT32BE(l, outBlock, 4);
} }
inline void Cast5Decrypt(const uchar *inBlock, uchar *outBlock, CAST_KEY *key) inline void Cast5Decrypt(PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key)
{ {
uint l; GET_UINT32BE(l, inBlock, 0); uint l; GET_UINT32BE(l, inBlock, 0);
uint r; GET_UINT32BE(r, inBlock, 4); uint r; GET_UINT32BE(r, inBlock, 4);
uint *K = key->K; PRIVATE_AS uint *K = key->K;
uint t; uint t;
/* Only do full 16 rounds if key length > 80 bits */ /* Only do full 16 rounds if key length > 80 bits */
@ -661,10 +661,10 @@ inline void Cast5Decrypt(const uchar *inBlock, uchar *outBlock, CAST_KEY *key)
t = l = r = 0; t = l = r = 0;
} }
inline void Cast5SetKey(CAST_KEY *key, uint keylength, const uchar *userKey) inline void Cast5SetKey(PRIVATE_AS CAST_KEY *key, uint keylength, PRIVATE_AS const u8 *userKey)
{ {
uint i; uint i;
uint *K = key->K; PRIVATE_AS uint *K = key->K;
uint X[4], Z[4]; uint X[4], Z[4];
GET_UINT32BE(X[0], userKey, 0); GET_UINT32BE(X[0], userKey, 0);

View File

@ -132,9 +132,9 @@ DECLSPEC void cast128_decrypt_cfb (GLOBAL_AS const u32 *encrypted_data, int data
lencrypted_data[i + 2] = encrypted_data[i + 2]; lencrypted_data[i + 2] = encrypted_data[i + 2];
lencrypted_data[i + 3] = encrypted_data[i + 3]; lencrypted_data[i + 3] = encrypted_data[i + 3];
} }
u8 *lencrypted_data8 = (u8*)lencrypted_data; PRIVATE_AS u8 *lencrypted_data8 = (PRIVATE_AS u8*)lencrypted_data;
u8 *decrypted_data8 = (u8*)decrypted_data; PRIVATE_AS u8 *decrypted_data8 = (PRIVATE_AS u8*)decrypted_data;
u8 *key8 = (u8*)key; PRIVATE_AS u8 *key8 = (PRIVATE_AS u8*)key;
// Copy the IV, since this will be modified // Copy the IV, since this will be modified