Get rid of src/cpu_aes.c, src/cpu_des.c, src/cpu_md5.c and src/cpu_sha256.c

pull/1971/head
jsteube 5 years ago
parent fb8a9d7c40
commit 5b667d2c01

@ -8,58 +8,6 @@
#include "inc_common.h"
#include "inc_cipher_des.h"
#define PERM_OP(a,b,n,m) \
{ \
u32x t; \
t = a >> n; \
t = t ^ b; \
t = t & m; \
b = b ^ t; \
t = t << n; \
a = a ^ t; \
}
#define HPERM_OP(a,n,m) \
{ \
u32x t; \
t = a << (16 + n); \
t = t ^ a; \
t = t & m; \
a = a ^ t; \
t = t >> (16 + n); \
a = a ^ t; \
}
#define DES_IP(l,r) \
{ \
PERM_OP (r, l, 4, 0x0f0f0f0f); \
PERM_OP (l, r, 16, 0x0000ffff); \
PERM_OP (r, l, 2, 0x33333333); \
PERM_OP (l, r, 8, 0x00ff00ff); \
PERM_OP (r, l, 1, 0x55555555); \
}
#define DES_FP(l,r) \
{ \
PERM_OP (l, r, 1, 0x55555555); \
PERM_OP (r, l, 8, 0x00ff00ff); \
PERM_OP (l, r, 2, 0x33333333); \
PERM_OP (r, l, 16, 0x0000ffff); \
PERM_OP (l, r, 4, 0x0f0f0f0f); \
}
#if VECT_SIZE == 1
#define DES_BOX(i,n,S) (S)[(n)][(i)]
#elif VECT_SIZE == 2
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1])
#elif VECT_SIZE == 4
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3])
#elif VECT_SIZE == 8
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7])
#elif VECT_SIZE == 16
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf])
#endif
DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64])
{
u32x r = data[0];
@ -224,10 +172,3 @@ DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE
Kd[i] = hc_rotl32 (Kd[i], 2u);
}
}
#undef PERM_OP
#undef HPERM_OP
#undef DES_IP
#undef DES_FP
#undef DES_BOX

@ -6,6 +6,60 @@
#ifndef _INC_CIPHER_DES_H
#define _INC_CIPHER_DES_H
// these really should be turned into real function
#define PERM_OP(a,b,n,m) \
{ \
u32x t; \
t = a >> n; \
t = t ^ b; \
t = t & m; \
b = b ^ t; \
t = t << n; \
a = a ^ t; \
}
#define HPERM_OP(a,n,m) \
{ \
u32x t; \
t = a << (16 + n); \
t = t ^ a; \
t = t & m; \
a = a ^ t; \
t = t >> (16 + n); \
a = a ^ t; \
}
#define DES_IP(l,r) \
{ \
PERM_OP (r, l, 4, 0x0f0f0f0f); \
PERM_OP (l, r, 16, 0x0000ffff); \
PERM_OP (r, l, 2, 0x33333333); \
PERM_OP (l, r, 8, 0x00ff00ff); \
PERM_OP (r, l, 1, 0x55555555); \
}
#define DES_FP(l,r) \
{ \
PERM_OP (l, r, 1, 0x55555555); \
PERM_OP (r, l, 8, 0x00ff00ff); \
PERM_OP (l, r, 2, 0x33333333); \
PERM_OP (r, l, 16, 0x0000ffff); \
PERM_OP (l, r, 4, 0x0f0f0f0f); \
}
#if VECT_SIZE == 1
#define DES_BOX(i,n,S) (S)[(n)][(i)]
#elif VECT_SIZE == 2
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1])
#elif VECT_SIZE == 4
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3])
#elif VECT_SIZE == 8
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7])
#elif VECT_SIZE == 16
#define DES_BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf])
#endif
CONSTANT_AS CONSTSPEC u32a c_SPtrans[8][64] =
{
{

@ -1,16 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _CPU_AES_H
#define _CPU_AES_H
void AES_set_encrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_set_decrypt_key (const u8 *key, int keysize, AES_KEY *aes_key);
void AES_encrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output);
void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16]);
#endif // _CPU_AES_H

@ -1,9 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _CPU_BLAKE2_H
#define _CPU_BLAKE2_H
#endif // _CPU_BLAKE2_H

@ -1,52 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _CPU_DES_H
#define _CPU_DES_H
#define PERM_OP(a,b,n,m) \
{ \
u32 t; \
t = a >> n; \
t = t ^ b; \
t = t & m; \
b = b ^ t; \
t = t << n; \
a = a ^ t; \
}
#define HPERM_OP(a,n,m) \
{ \
u32 t; \
t = a << (16 + n); \
t = t ^ a; \
t = t & m; \
a = a ^ t; \
t = t >> (16 + n); \
a = a ^ t; \
}
#define DES_IP(l,r) \
{ \
PERM_OP (r, l, 4, 0x0f0f0f0f); \
PERM_OP (l, r, 16, 0x0000ffff); \
PERM_OP (r, l, 2, 0x33333333); \
PERM_OP (l, r, 8, 0x00ff00ff); \
PERM_OP (r, l, 1, 0x55555555); \
}
#define DES_FP(l,r) \
{ \
PERM_OP (l, r, 1, 0x55555555); \
PERM_OP (r, l, 8, 0x00ff00ff); \
PERM_OP (l, r, 2, 0x33333333); \
PERM_OP (r, l, 16, 0x0000ffff); \
PERM_OP (l, r, 4, 0x0f0f0f0f); \
}
void _des_keysetup (const u32 data[2], u32 Kc[16], u32 Kd[16]);
void _des_encrypt (u32 data[2], const u32 Kc[16], const u32 Kd[16]);
#endif // _CPU_DES_H

@ -1,14 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _CPU_MD5_H
#define _CPU_MD5_H
#include <string.h>
void md5_64 (const u32 block[16], u32 digest[4]);
void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len);
#endif // _CPU_MD5_H

@ -1,11 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _CPU_SHA256_H
#define _CPU_SHA256_H
void sha256_64 (const u32 block[16], u32 digest[8]);
#endif // _CPU_SHA256_H

@ -0,0 +1,21 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EMU_INC_CIPHER_AES_H
#define _EMU_INC_CIPHER_AES_H
#include "emu_general.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include "inc_vendor.h"
#include "inc_cipher_aes.h"
#pragma GCC diagnostic pop
#endif // _EMU_INC_CIPHER_AES_H

@ -0,0 +1,21 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EMU_INC_CIPHER_DES_H
#define _EMU_INC_CIPHER_DES_H
#include "emu_general.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include "inc_vendor.h"
#include "inc_cipher_des.h"
#pragma GCC diagnostic pop
#endif // _EMU_INC_CIPHER_DES_H

@ -8,12 +8,6 @@
#include "emu_general.h"
#define DGST_ELEM 4
#define DGST_R0 0
#define DGST_R1 1
#define DGST_R2 2
#define DGST_R3 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

@ -0,0 +1,21 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EMU_INC_HASH_MD5_H
#define _EMU_INC_HASH_MD5_H
#include "emu_general.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include "inc_vendor.h"
#include "inc_hash_md5.h"
#pragma GCC diagnostic pop
#endif // _EMU_INC_HASH_MD5_H

@ -8,12 +8,6 @@
#include "emu_general.h"
#define DGST_ELEM 4
#define DGST_R0 0
#define DGST_R1 1
#define DGST_R2 2
#define DGST_R3 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

@ -0,0 +1,21 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EMU_INC_HASH_SHA256_H
#define _EMU_INC_HASH_SHA256_H
#include "emu_general.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include "inc_vendor.h"
#include "inc_hash_sha256.h"
#pragma GCC diagnostic pop
#endif // _EMU_INC_HASH_SHA256_H

@ -0,0 +1,21 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EMU_INC_HASH_SHA512_H
#define _EMU_INC_HASH_SHA512_H
#include "emu_general.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include "inc_vendor.h"
#include "inc_hash_sha512.h"
#pragma GCC diagnostic pop
#endif // _EMU_INC_HASH_SHA512_H

@ -8,12 +8,6 @@
#include "emu_general.h"
#define DGST_ELEM 4
#define DGST_R0 0
#define DGST_R1 1
#define DGST_R2 2
#define DGST_R3 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

@ -8,12 +8,6 @@
#include "emu_general.h"
#define DGST_ELEM 4
#define DGST_R0 0
#define DGST_R1 1
#define DGST_R2 2
#define DGST_R3 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

@ -288,7 +288,7 @@ EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized
EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512
EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp opencl outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL)
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp opencl outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL)
ifeq ($(ENABLE_BRAIN),1)
OBJS_ALL += brain
@ -322,9 +322,9 @@ WIN_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).WIN.o)
endif
endif
EMU_MODULE_OBJS_ALL := emu_general emu_inc_common emu_inc_hash_md4 emu_inc_hash_sha1
EMU_MODULE_OBJS_ALL := emu_general emu_inc_common emu_inc_cipher_aes emu_inc_cipher_des emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha512
MODULE_OBJS_ALL := bitops convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha256 ext_lzma filehandling keyboard_layout memory shared $(EMU_MODULE_OBJS_ALL)
MODULE_OBJS_ALL := bitops convert cpu_crc32 ext_lzma filehandling keyboard_layout memory shared $(EMU_MODULE_OBJS_ALL)
ifeq ($(USE_SYSTEM_LZMA),0)
MODULE_OBJS_ALL += Alloc Lzma2Dec LzmaDec

File diff suppressed because it is too large Load Diff

@ -1,421 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "bitops.h"
#include "cpu_des.h"
#define BOX(v,i,S) (S)[(i)][(v)]
static const u32 c_SPtrans[8][64] =
{
{
/* nibble 0 */
0x02080800, 0x00080000, 0x02000002, 0x02080802,
0x02000000, 0x00080802, 0x00080002, 0x02000002,
0x00080802, 0x02080800, 0x02080000, 0x00000802,
0x02000802, 0x02000000, 0x00000000, 0x00080002,
0x00080000, 0x00000002, 0x02000800, 0x00080800,
0x02080802, 0x02080000, 0x00000802, 0x02000800,
0x00000002, 0x00000800, 0x00080800, 0x02080002,
0x00000800, 0x02000802, 0x02080002, 0x00000000,
0x00000000, 0x02080802, 0x02000800, 0x00080002,
0x02080800, 0x00080000, 0x00000802, 0x02000800,
0x02080002, 0x00000800, 0x00080800, 0x02000002,
0x00080802, 0x00000002, 0x02000002, 0x02080000,
0x02080802, 0x00080800, 0x02080000, 0x02000802,
0x02000000, 0x00000802, 0x00080002, 0x00000000,
0x00080000, 0x02000000, 0x02000802, 0x02080800,
0x00000002, 0x02080002, 0x00000800, 0x00080802,
},
{
/* nibble 1 */
0x40108010, 0x00000000, 0x00108000, 0x40100000,
0x40000010, 0x00008010, 0x40008000, 0x00108000,
0x00008000, 0x40100010, 0x00000010, 0x40008000,
0x00100010, 0x40108000, 0x40100000, 0x00000010,
0x00100000, 0x40008010, 0x40100010, 0x00008000,
0x00108010, 0x40000000, 0x00000000, 0x00100010,
0x40008010, 0x00108010, 0x40108000, 0x40000010,
0x40000000, 0x00100000, 0x00008010, 0x40108010,
0x00100010, 0x40108000, 0x40008000, 0x00108010,
0x40108010, 0x00100010, 0x40000010, 0x00000000,
0x40000000, 0x00008010, 0x00100000, 0x40100010,
0x00008000, 0x40000000, 0x00108010, 0x40008010,
0x40108000, 0x00008000, 0x00000000, 0x40000010,
0x00000010, 0x40108010, 0x00108000, 0x40100000,
0x40100010, 0x00100000, 0x00008010, 0x40008000,
0x40008010, 0x00000010, 0x40100000, 0x00108000,
},
{
/* nibble 2 */
0x04000001, 0x04040100, 0x00000100, 0x04000101,
0x00040001, 0x04000000, 0x04000101, 0x00040100,
0x04000100, 0x00040000, 0x04040000, 0x00000001,
0x04040101, 0x00000101, 0x00000001, 0x04040001,
0x00000000, 0x00040001, 0x04040100, 0x00000100,
0x00000101, 0x04040101, 0x00040000, 0x04000001,
0x04040001, 0x04000100, 0x00040101, 0x04040000,
0x00040100, 0x00000000, 0x04000000, 0x00040101,
0x04040100, 0x00000100, 0x00000001, 0x00040000,
0x00000101, 0x00040001, 0x04040000, 0x04000101,
0x00000000, 0x04040100, 0x00040100, 0x04040001,
0x00040001, 0x04000000, 0x04040101, 0x00000001,
0x00040101, 0x04000001, 0x04000000, 0x04040101,
0x00040000, 0x04000100, 0x04000101, 0x00040100,
0x04000100, 0x00000000, 0x04040001, 0x00000101,
0x04000001, 0x00040101, 0x00000100, 0x04040000,
},
{
/* nibble 3 */
0x00401008, 0x10001000, 0x00000008, 0x10401008,
0x00000000, 0x10400000, 0x10001008, 0x00400008,
0x10401000, 0x10000008, 0x10000000, 0x00001008,
0x10000008, 0x00401008, 0x00400000, 0x10000000,
0x10400008, 0x00401000, 0x00001000, 0x00000008,
0x00401000, 0x10001008, 0x10400000, 0x00001000,
0x00001008, 0x00000000, 0x00400008, 0x10401000,
0x10001000, 0x10400008, 0x10401008, 0x00400000,
0x10400008, 0x00001008, 0x00400000, 0x10000008,
0x00401000, 0x10001000, 0x00000008, 0x10400000,
0x10001008, 0x00000000, 0x00001000, 0x00400008,
0x00000000, 0x10400008, 0x10401000, 0x00001000,
0x10000000, 0x10401008, 0x00401008, 0x00400000,
0x10401008, 0x00000008, 0x10001000, 0x00401008,
0x00400008, 0x00401000, 0x10400000, 0x10001008,
0x00001008, 0x10000000, 0x10000008, 0x10401000,
},
{
/* nibble 4 */
0x08000000, 0x00010000, 0x00000400, 0x08010420,
0x08010020, 0x08000400, 0x00010420, 0x08010000,
0x00010000, 0x00000020, 0x08000020, 0x00010400,
0x08000420, 0x08010020, 0x08010400, 0x00000000,
0x00010400, 0x08000000, 0x00010020, 0x00000420,
0x08000400, 0x00010420, 0x00000000, 0x08000020,
0x00000020, 0x08000420, 0x08010420, 0x00010020,
0x08010000, 0x00000400, 0x00000420, 0x08010400,
0x08010400, 0x08000420, 0x00010020, 0x08010000,
0x00010000, 0x00000020, 0x08000020, 0x08000400,
0x08000000, 0x00010400, 0x08010420, 0x00000000,
0x00010420, 0x08000000, 0x00000400, 0x00010020,
0x08000420, 0x00000400, 0x00000000, 0x08010420,
0x08010020, 0x08010400, 0x00000420, 0x00010000,
0x00010400, 0x08010020, 0x08000400, 0x00000420,
0x00000020, 0x00010420, 0x08010000, 0x08000020,
},
{
/* nibble 5 */
0x80000040, 0x00200040, 0x00000000, 0x80202000,
0x00200040, 0x00002000, 0x80002040, 0x00200000,
0x00002040, 0x80202040, 0x00202000, 0x80000000,
0x80002000, 0x80000040, 0x80200000, 0x00202040,
0x00200000, 0x80002040, 0x80200040, 0x00000000,
0x00002000, 0x00000040, 0x80202000, 0x80200040,
0x80202040, 0x80200000, 0x80000000, 0x00002040,
0x00000040, 0x00202000, 0x00202040, 0x80002000,
0x00002040, 0x80000000, 0x80002000, 0x00202040,
0x80202000, 0x00200040, 0x00000000, 0x80002000,
0x80000000, 0x00002000, 0x80200040, 0x00200000,
0x00200040, 0x80202040, 0x00202000, 0x00000040,
0x80202040, 0x00202000, 0x00200000, 0x80002040,
0x80000040, 0x80200000, 0x00202040, 0x00000000,
0x00002000, 0x80000040, 0x80002040, 0x80202000,
0x80200000, 0x00002040, 0x00000040, 0x80200040,
},
{
/* nibble 6 */
0x00004000, 0x00000200, 0x01000200, 0x01000004,
0x01004204, 0x00004004, 0x00004200, 0x00000000,
0x01000000, 0x01000204, 0x00000204, 0x01004000,
0x00000004, 0x01004200, 0x01004000, 0x00000204,
0x01000204, 0x00004000, 0x00004004, 0x01004204,
0x00000000, 0x01000200, 0x01000004, 0x00004200,
0x01004004, 0x00004204, 0x01004200, 0x00000004,
0x00004204, 0x01004004, 0x00000200, 0x01000000,
0x00004204, 0x01004000, 0x01004004, 0x00000204,
0x00004000, 0x00000200, 0x01000000, 0x01004004,
0x01000204, 0x00004204, 0x00004200, 0x00000000,
0x00000200, 0x01000004, 0x00000004, 0x01000200,
0x00000000, 0x01000204, 0x01000200, 0x00004200,
0x00000204, 0x00004000, 0x01004204, 0x01000000,
0x01004200, 0x00000004, 0x00004004, 0x01004204,
0x01000004, 0x01004200, 0x01004000, 0x00004004,
},
{
/* nibble 7 */
0x20800080, 0x20820000, 0x00020080, 0x00000000,
0x20020000, 0x00800080, 0x20800000, 0x20820080,
0x00000080, 0x20000000, 0x00820000, 0x00020080,
0x00820080, 0x20020080, 0x20000080, 0x20800000,
0x00020000, 0x00820080, 0x00800080, 0x20020000,
0x20820080, 0x20000080, 0x00000000, 0x00820000,
0x20000000, 0x00800000, 0x20020080, 0x20800080,
0x00800000, 0x00020000, 0x20820000, 0x00000080,
0x00800000, 0x00020000, 0x20000080, 0x20820080,
0x00020080, 0x20000000, 0x00000000, 0x00820000,
0x20800080, 0x20020080, 0x20020000, 0x00800080,
0x20820000, 0x00000080, 0x00800080, 0x20020000,
0x20820080, 0x00800000, 0x20800000, 0x20000080,
0x00820000, 0x00020080, 0x20020080, 0x20800000,
0x00000080, 0x20820000, 0x00820080, 0x00000000,
0x20000000, 0x20800080, 0x00020000, 0x00820080,
},
};
static const u32 c_skb[8][64] =
{
{
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x00000010, 0x20000000, 0x20000010,
0x00010000, 0x00010010, 0x20010000, 0x20010010,
0x00000800, 0x00000810, 0x20000800, 0x20000810,
0x00010800, 0x00010810, 0x20010800, 0x20010810,
0x00000020, 0x00000030, 0x20000020, 0x20000030,
0x00010020, 0x00010030, 0x20010020, 0x20010030,
0x00000820, 0x00000830, 0x20000820, 0x20000830,
0x00010820, 0x00010830, 0x20010820, 0x20010830,
0x00080000, 0x00080010, 0x20080000, 0x20080010,
0x00090000, 0x00090010, 0x20090000, 0x20090010,
0x00080800, 0x00080810, 0x20080800, 0x20080810,
0x00090800, 0x00090810, 0x20090800, 0x20090810,
0x00080020, 0x00080030, 0x20080020, 0x20080030,
0x00090020, 0x00090030, 0x20090020, 0x20090030,
0x00080820, 0x00080830, 0x20080820, 0x20080830,
0x00090820, 0x00090830, 0x20090820, 0x20090830,
},
{
/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
0x00000000, 0x02000000, 0x00002000, 0x02002000,
0x00200000, 0x02200000, 0x00202000, 0x02202000,
0x00000004, 0x02000004, 0x00002004, 0x02002004,
0x00200004, 0x02200004, 0x00202004, 0x02202004,
0x00000400, 0x02000400, 0x00002400, 0x02002400,
0x00200400, 0x02200400, 0x00202400, 0x02202400,
0x00000404, 0x02000404, 0x00002404, 0x02002404,
0x00200404, 0x02200404, 0x00202404, 0x02202404,
0x10000000, 0x12000000, 0x10002000, 0x12002000,
0x10200000, 0x12200000, 0x10202000, 0x12202000,
0x10000004, 0x12000004, 0x10002004, 0x12002004,
0x10200004, 0x12200004, 0x10202004, 0x12202004,
0x10000400, 0x12000400, 0x10002400, 0x12002400,
0x10200400, 0x12200400, 0x10202400, 0x12202400,
0x10000404, 0x12000404, 0x10002404, 0x12002404,
0x10200404, 0x12200404, 0x10202404, 0x12202404,
},
{
/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
0x00000000, 0x00000001, 0x00040000, 0x00040001,
0x01000000, 0x01000001, 0x01040000, 0x01040001,
0x00000002, 0x00000003, 0x00040002, 0x00040003,
0x01000002, 0x01000003, 0x01040002, 0x01040003,
0x00000200, 0x00000201, 0x00040200, 0x00040201,
0x01000200, 0x01000201, 0x01040200, 0x01040201,
0x00000202, 0x00000203, 0x00040202, 0x00040203,
0x01000202, 0x01000203, 0x01040202, 0x01040203,
0x08000000, 0x08000001, 0x08040000, 0x08040001,
0x09000000, 0x09000001, 0x09040000, 0x09040001,
0x08000002, 0x08000003, 0x08040002, 0x08040003,
0x09000002, 0x09000003, 0x09040002, 0x09040003,
0x08000200, 0x08000201, 0x08040200, 0x08040201,
0x09000200, 0x09000201, 0x09040200, 0x09040201,
0x08000202, 0x08000203, 0x08040202, 0x08040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203,
},
{
/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
0x00000000, 0x00100000, 0x00000100, 0x00100100,
0x00000008, 0x00100008, 0x00000108, 0x00100108,
0x00001000, 0x00101000, 0x00001100, 0x00101100,
0x00001008, 0x00101008, 0x00001108, 0x00101108,
0x04000000, 0x04100000, 0x04000100, 0x04100100,
0x04000008, 0x04100008, 0x04000108, 0x04100108,
0x04001000, 0x04101000, 0x04001100, 0x04101100,
0x04001008, 0x04101008, 0x04001108, 0x04101108,
0x00020000, 0x00120000, 0x00020100, 0x00120100,
0x00020008, 0x00120008, 0x00020108, 0x00120108,
0x00021000, 0x00121000, 0x00021100, 0x00121100,
0x00021008, 0x00121008, 0x00021108, 0x00121108,
0x04020000, 0x04120000, 0x04020100, 0x04120100,
0x04020008, 0x04120008, 0x04020108, 0x04120108,
0x04021000, 0x04121000, 0x04021100, 0x04121100,
0x04021008, 0x04121008, 0x04021108, 0x04121108,
},
{
/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x10000000, 0x00010000, 0x10010000,
0x00000004, 0x10000004, 0x00010004, 0x10010004,
0x20000000, 0x30000000, 0x20010000, 0x30010000,
0x20000004, 0x30000004, 0x20010004, 0x30010004,
0x00100000, 0x10100000, 0x00110000, 0x10110000,
0x00100004, 0x10100004, 0x00110004, 0x10110004,
0x20100000, 0x30100000, 0x20110000, 0x30110000,
0x20100004, 0x30100004, 0x20110004, 0x30110004,
0x00001000, 0x10001000, 0x00011000, 0x10011000,
0x00001004, 0x10001004, 0x00011004, 0x10011004,
0x20001000, 0x30001000, 0x20011000, 0x30011000,
0x20001004, 0x30001004, 0x20011004, 0x30011004,
0x00101000, 0x10101000, 0x00111000, 0x10111000,
0x00101004, 0x10101004, 0x00111004, 0x10111004,
0x20101000, 0x30101000, 0x20111000, 0x30111000,
0x20101004, 0x30101004, 0x20111004, 0x30111004,
},
{
/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
0x00000000, 0x08000000, 0x00000008, 0x08000008,
0x00000400, 0x08000400, 0x00000408, 0x08000408,
0x00020000, 0x08020000, 0x00020008, 0x08020008,
0x00020400, 0x08020400, 0x00020408, 0x08020408,
0x00000001, 0x08000001, 0x00000009, 0x08000009,
0x00000401, 0x08000401, 0x00000409, 0x08000409,
0x00020001, 0x08020001, 0x00020009, 0x08020009,
0x00020401, 0x08020401, 0x00020409, 0x08020409,
0x02000000, 0x0A000000, 0x02000008, 0x0A000008,
0x02000400, 0x0A000400, 0x02000408, 0x0A000408,
0x02020000, 0x0A020000, 0x02020008, 0x0A020008,
0x02020400, 0x0A020400, 0x02020408, 0x0A020408,
0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
},
{
/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
0x00000000, 0x00000100, 0x00080000, 0x00080100,
0x01000000, 0x01000100, 0x01080000, 0x01080100,
0x00000010, 0x00000110, 0x00080010, 0x00080110,
0x01000010, 0x01000110, 0x01080010, 0x01080110,
0x00200000, 0x00200100, 0x00280000, 0x00280100,
0x01200000, 0x01200100, 0x01280000, 0x01280100,
0x00200010, 0x00200110, 0x00280010, 0x00280110,
0x01200010, 0x01200110, 0x01280010, 0x01280110,
0x00000200, 0x00000300, 0x00080200, 0x00080300,
0x01000200, 0x01000300, 0x01080200, 0x01080300,
0x00000210, 0x00000310, 0x00080210, 0x00080310,
0x01000210, 0x01000310, 0x01080210, 0x01080310,
0x00200200, 0x00200300, 0x00280200, 0x00280300,
0x01200200, 0x01200300, 0x01280200, 0x01280300,
0x00200210, 0x00200310, 0x00280210, 0x00280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310,
},
{
/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
0x00000000, 0x04000000, 0x00040000, 0x04040000,
0x00000002, 0x04000002, 0x00040002, 0x04040002,
0x00002000, 0x04002000, 0x00042000, 0x04042000,
0x00002002, 0x04002002, 0x00042002, 0x04042002,
0x00000020, 0x04000020, 0x00040020, 0x04040020,
0x00000022, 0x04000022, 0x00040022, 0x04040022,
0x00002020, 0x04002020, 0x00042020, 0x04042020,
0x00002022, 0x04002022, 0x00042022, 0x04042022,
0x00000800, 0x04000800, 0x00040800, 0x04040800,
0x00000802, 0x04000802, 0x00040802, 0x04040802,
0x00002800, 0x04002800, 0x00042800, 0x04042800,
0x00002802, 0x04002802, 0x00042802, 0x04042802,
0x00000820, 0x04000820, 0x00040820, 0x04040820,
0x00000822, 0x04000822, 0x00040822, 0x04040822,
0x00002820, 0x04002820, 0x00042820, 0x04042820,
0x00002822, 0x04002822, 0x00042822, 0x04042822
}
};
void _des_keysetup (const u32 data[2], u32 Kc[16], u32 Kd[16])
{
u32 c = data[0];
u32 d = data[1];
PERM_OP (d, c, 4, 0x0f0f0f0f);
HPERM_OP (c, 2, 0xcccc0000);
HPERM_OP (d, 2, 0xcccc0000);
PERM_OP (d, c, 1, 0x55555555);
PERM_OP (c, d, 8, 0x00ff00ff);
PERM_OP (d, c, 1, 0x55555555);
d = ((d & 0x000000ff) << 16)
| ((d & 0x0000ff00) << 0)
| ((d & 0x00ff0000) >> 16)
| ((c & 0xf0000000) >> 4);
c = c & 0x0fffffff;
int i;
for (i = 0; i < 16; i++)
{
const u32 shifts3s0[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
const u32 shifts3s1[16] = { 27, 27, 26, 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, 26, 26, 27 };
c = c >> shifts3s0[i] | c << shifts3s1[i];
d = d >> shifts3s0[i] | d << shifts3s1[i];
c = c & 0x0fffffff;
d = d & 0x0fffffff;
u32 s = BOX ((( c >> 0) & 0x3f), 0, c_skb)
| BOX ((((c >> 6) & 0x03)
| ((c >> 7) & 0x3c)), 1, c_skb)
| BOX ((((c >> 13) & 0x0f)
| ((c >> 14) & 0x30)), 2, c_skb)
| BOX ((((c >> 20) & 0x01)
| ((c >> 21) & 0x06)
| ((c >> 22) & 0x38)), 3, c_skb);
u32 t = BOX ((( d >> 0) & 0x3f), 4, c_skb)
| BOX ((((d >> 7) & 0x03)
| ((d >> 8) & 0x3c)), 5, c_skb)
| BOX ((((d >> 15) & 0x3f)), 6, c_skb)
| BOX ((((d >> 21) & 0x0f)
| ((d >> 22) & 0x30)), 7, c_skb);
Kc[i] = ((t << 16) | (s & 0x0000ffff));
Kd[i] = ((s >> 16) | (t & 0xffff0000));
Kc[i] = rotl32 (Kc[i], 2u);
Kd[i] = rotl32 (Kd[i], 2u);
}
}
void _des_encrypt (u32 data[2], const u32 Kc[16], const u32 Kd[16])
{
u32 r = data[0];
u32 l = data[1];
DES_IP (r, l);
r = rotl32 (r, 3u);
l = rotl32 (l, 3u);
int i;
for (i = 0; i < 16; i++)
{
u32 u = Kc[i] ^ r;
u32 t = Kd[i] ^ rotl32 (r, 28u);
l ^= BOX (((u >> 2) & 0x3f), 0, c_SPtrans)
| BOX (((u >> 10) & 0x3f), 2, c_SPtrans)
| BOX (((u >> 18) & 0x3f), 4, c_SPtrans)
| BOX (((u >> 26) & 0x3f), 6, c_SPtrans)
| BOX (((t >> 2) & 0x3f), 1, c_SPtrans)
| BOX (((t >> 10) & 0x3f), 3, c_SPtrans)
| BOX (((t >> 18) & 0x3f), 5, c_SPtrans)
| BOX (((t >> 26) & 0x3f), 7, c_SPtrans);
u32 tt;
tt = l;
l = r;
r = tt;
}
l = rotl32 (l, 29u);
r = rotl32 (r, 29u);
DES_FP (r, l);
data[0] = l;
data[1] = r;
}

@ -1,329 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "bitops.h"
#define MD5_F_S(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define MD5_G_S(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
#define MD5_H_S(x,y,z) ((x) ^ (y) ^ (z))
#define MD5_I_S(x,y,z) ((y) ^ ((x) | ~(z)))
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
#define MD5_H1(x,y,z) ((t = (x) ^ (y)) ^ (z))
#define MD5_H2(x,y,z) ((x) ^ t)
#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z)))
#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z)))
#define MD5_Go(x,y,z) (MD5_G((x), (y), (z)))
#define MD5_STEP_S(f,a,b,c,d,x,K,s) \
{ \
a += K; \
a = add3_S (a, x, f (b, c, d)); \
a = rotl32_S (a, s); \
a += b; \
}
#define MD5_STEP(f,a,b,c,d,x,K,s) \
{ \
a += K; \
a = add3 (a, x, f (b, c, d)); \
a = rotl32 (a, s); \
a += b; \
}
#define MD5_STEP0(f,a,b,c,d,K,s) \
{ \
a = add3 (a, K, f (b, c, d)); \
a = rotl32 (a, s); \
a += b; \
}
void md5_64 (const u32 block[16], u32 digest[4])
{
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = block[ 0];
w0[1] = block[ 1];
w0[2] = block[ 2];
w0[3] = block[ 3];
w1[0] = block[ 4];
w1[1] = block[ 5];
w1[2] = block[ 6];
w1[3] = block[ 7];
w2[0] = block[ 8];
w2[1] = block[ 9];
w2[2] = block[10];
w2[3] = block[11];
w3[0] = block[12];
w3[1] = block[13];
w3[2] = block[14];
w3[3] = block[15];
u32 a = digest[0];
u32 b = digest[1];
u32 c = digest[2];
u32 d = digest[3];
MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
digest[0] += a;
digest[1] += b;
digest[2] += c;
digest[3] += d;
}
// only use this when really, really needed, SLOW
void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len)
{
u32 a = MD5M_A;
u32 b = MD5M_B;
u32 c = MD5M_C;
u32 d = MD5M_D;
digest[0] = a;
digest[1] = b;
digest[2] = c;
digest[3] = d;
u32 r_a = digest[0];
u32 r_b = digest[1];
u32 r_c = digest[2];
u32 r_d = digest[3];
u32 block[16];
int block_total_len = 16 * 4; // sizeof (block)
char *block_ptr = (char *) block;
char *plain_ptr = (char *) plain;
// init
int remaining_len = (int) plain_len;
// loop
u32 loop = 1;
while (loop)
{
loop = (remaining_len > 55);
int cur_len = MIN (block_total_len, remaining_len);
int copy_len = MAX (cur_len, 0); // should never be negative of course
// initialize the block
memset (block_ptr, 0, block_total_len);
// copy the bytes from the plain pointer (plain_ptr)
memcpy (block_ptr, plain_ptr, (size_t) copy_len);
/*
* final block
*/
// set 0x80 if needed
if (cur_len >= 0)
{
if (copy_len < block_total_len)
{
block_ptr[copy_len] = (char) 0x80;
}
}
// set block[14] set to total_len
if (! loop) block[14] = plain_len * 8;
/*
* md5 ()
*/
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = block[ 0];
w0[1] = block[ 1];
w0[2] = block[ 2];
w0[3] = block[ 3];
w1[0] = block[ 4];
w1[1] = block[ 5];
w1[2] = block[ 6];
w1[3] = block[ 7];
w2[0] = block[ 8];
w2[1] = block[ 9];
w2[2] = block[10];
w2[3] = block[11];
w3[0] = block[12];
w3[1] = block[13];
w3[2] = block[14];
w3[3] = block[15];
MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
remaining_len -= block_total_len;
plain_ptr += 64;
a += r_a;
b += r_b;
c += r_c;
d += r_d;
digest[0] = a;
digest[1] = b;
digest[2] = c;
digest[3] = d;
r_a = digest[0];
r_b = digest[1];
r_c = digest[2];
r_d = digest[3];
}
}

@ -1,151 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "bitops.h"
#define SHIFT_RIGHT_32(x,n) ((x) >> (n))
#define SHA256_S0_S(x) (rotl32_S ((x), 25u) ^ rotl32_S ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
#define SHA256_S1_S(x) (rotl32_S ((x), 15u) ^ rotl32_S ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
#define SHA256_S2_S(x) (rotl32_S ((x), 30u) ^ rotl32_S ((x), 19u) ^ rotl32_S ((x), 10u))
#define SHA256_S3_S(x) (rotl32_S ((x), 26u) ^ rotl32_S ((x), 21u) ^ rotl32_S ((x), 7u))
#define SHA256_S0(x) (rotl32 ((x), 25u) ^ rotl32 ((x), 14u) ^ SHIFT_RIGHT_32 ((x), 3u))
#define SHA256_S1(x) (rotl32 ((x), 15u) ^ rotl32 ((x), 13u) ^ SHIFT_RIGHT_32 ((x), 10u))
#define SHA256_S2(x) (rotl32 ((x), 30u) ^ rotl32 ((x), 19u) ^ rotl32 ((x), 10u))
#define SHA256_S3(x) (rotl32 ((x), 26u) ^ rotl32 ((x), 21u) ^ rotl32 ((x), 7u))
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z)))
#define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z)))
#define SHA256_STEP_S(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
h = add3_S (h, K, x); \
h = add3_S (h, SHA256_S3_S (e), F1 (e,f,g)); \
d += h; \
h = add3_S (h, SHA256_S2_S (a), F0 (a,b,c)); \
}
#define SHA256_EXPAND_S(x,y,z,w) (SHA256_S1_S (x) + y + SHA256_S0_S (z) + w)
#define SHA256_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \
{ \
h = add3 (h, K, x); \
h = add3 (h, SHA256_S3 (e), F1 (e,f,g)); \
d += h; \
h = add3 (h, SHA256_S2 (a), F0 (a,b,c)); \
}
#define SHA256_EXPAND(x,y,z,w) (SHA256_S1 (x) + y + SHA256_S0 (z) + w)
void sha256_64 (const u32 block[16], u32 digest[8])
{
u32 w0_t = block[ 0];
u32 w1_t = block[ 1];
u32 w2_t = block[ 2];
u32 w3_t = block[ 3];
u32 w4_t = block[ 4];
u32 w5_t = block[ 5];
u32 w6_t = block[ 6];
u32 w7_t = block[ 7];
u32 w8_t = block[ 8];
u32 w9_t = block[ 9];
u32 wa_t = block[10];
u32 wb_t = block[11];
u32 wc_t = block[12];
u32 wd_t = block[13];
u32 we_t = block[14];
u32 wf_t = block[15];
u32 a = digest[0];
u32 b = digest[1];
u32 c = digest[2];
u32 d = digest[3];
u32 e = digest[4];
u32 f = digest[5];
u32 g = digest[6];
u32 h = digest[7];
SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00);
SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01);
SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02);
SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03);
SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04);
SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05);
SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06);
SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07);
SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08);
SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09);
SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a);
SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b);
SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c);
SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d);
SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e);
SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f);
w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10);
w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11);
w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12);
w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13);
w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14);
w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15);
w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16);
w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17);
w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18);
w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19);
wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a);
wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b);
wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c);
wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d);
we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e);
wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f);
w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20);
w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21);
w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22);
w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23);
w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24);
w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25);
w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26);
w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27);
w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28);
w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29);
wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a);
wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b);
wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c);
wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d);
we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e);
wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f);
w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30);
w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31);
w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32);
w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33);
w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34);
w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35);
w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36);
w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37);
w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38);
w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39);
wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a);
wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b);
wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c);
wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d);
we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e);
wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f);
digest[0] += a;
digest[1] += b;
digest[2] += c;
digest[3] += d;
digest[4] += e;
digest[5] += f;
digest[6] += g;
digest[7] += h;
}

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_aes.h"
#include "emu_inc_cipher_aes.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -59,6 +59,48 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c
return tmp_size;
}
static void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16])
{
AES_KEY skey;
aes128_set_decrypt_key (skey.rdk, key, (u32 *) te0, (u32 *) te1, (u32 *) te2, (u32 *) te3, (u32 *) te4, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4);
u32 _iv[4] = { 0 };
_iv[0] = iv[0];
_iv[1] = iv[1];
_iv[2] = iv[2];
_iv[3] = iv[3];
for (int i = 0; i < 16; i += 4)
{
u32 _in[4] = { 0 };
u32 _out[4] = { 0 };
_in[0] = in[i + 0];
_in[1] = in[i + 1];
_in[2] = in[i + 2];
_in[3] = in[i + 3];
aes128_decrypt (skey.rdk, _in, _out, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4);
_out[0] ^= _iv[0];
_out[1] ^= _iv[1];
_out[2] ^= _iv[2];
_out[3] ^= _iv[3];
out[i + 0] = _out[0];
out[i + 1] = _out[1];
out[i + 2] = _out[2];
out[i + 3] = _out[3];
_iv[0] = _in[0];
_iv[1] = _in[1];
_iv[2] = _in[2];
_iv[3] = _in[3];
}
}
static void juniper_decrypt_hash (const u8 *in, const int in_len, u8 *out)
{
// base64 decode

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -10,7 +10,7 @@
#include "convert.h"
#include "shared.h"
#include "memory.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -651,48 +651,48 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
for (int i = 0; i < 16; i++) block[i] = salt->salt_buf[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->pke[i + 0];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->pke[i + 16];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 0];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 16];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 32];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 48];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 6; i++) block_ptr[i + 0] = wpa_eapol->orig_mac_ap[i];
for (int i = 0; i < 6; i++) block_ptr[i + 6] = wpa_eapol->orig_mac_sta[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 32; i++) block_ptr[i + 0] = wpa_eapol->orig_nonce_ap[i];
for (int i = 0; i < 32; i++) block_ptr[i + 32] = wpa_eapol->orig_nonce_sta[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
block[0] = wpa_eapol->keymic[0];
block[1] = wpa_eapol->keymic[1];
block[2] = wpa_eapol->keymic[2];
block[3] = wpa_eapol->keymic[3];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
wpa_eapol->hash[0] = hash[0];
wpa_eapol->hash[1] = hash[1];

@ -10,7 +10,7 @@
#include "convert.h"
#include "shared.h"
#include "memory.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -651,48 +651,48 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
for (int i = 0; i < 16; i++) block[i] = salt->salt_buf[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->pke[i + 0];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->pke[i + 16];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 0];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 16];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 32];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 16; i++) block[i] = wpa_eapol->eapol[i + 48];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 6; i++) block_ptr[i + 0] = wpa_eapol->orig_mac_ap[i];
for (int i = 0; i < 6; i++) block_ptr[i + 6] = wpa_eapol->orig_mac_sta[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
for (int i = 0; i < 32; i++) block_ptr[i + 0] = wpa_eapol->orig_nonce_ap[i];
for (int i = 0; i < 32; i++) block_ptr[i + 32] = wpa_eapol->orig_nonce_sta[i];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
block[0] = wpa_eapol->keymic[0];
block[1] = wpa_eapol->keymic[1];
block[2] = wpa_eapol->keymic[2];
block[3] = wpa_eapol->keymic[3];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
wpa_eapol->hash[0] = hash[0];
wpa_eapol->hash[1] = hash[1];

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -45,6 +45,72 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len)
{
digest[0] = MD5M_A;
digest[1] = MD5M_B;
digest[2] = MD5M_C;
digest[3] = MD5M_D;
int block_total_len = 16 * 4; // sizeof (block)
u8 *plain_ptr = (u8 *) plain;
// init
int remaining_len = (int) plain_len;
// loop
u32 loop = 1;
while (loop)
{
loop = (remaining_len > 55);
int cur_len = MIN (block_total_len, remaining_len);
int copy_len = MAX (cur_len, 0); // should never be negative of course
// initialize the block
u32 block[16] = { 0 };
// copy the bytes from the plain pointer (plain_ptr)
memcpy (block, plain, (size_t) copy_len);
/*
* final block
*/
// set 0x80 if needed
if (cur_len >= 0)
{
if (copy_len < block_total_len)
{
u8 *block_ptr = (u8 *) block;
block_ptr[copy_len] = 0x80;
}
}
// set block[14] set to total_len
if (! loop) block[14] = plain_len * 8;
/*
* md5 ()
*/
md5_transform (block + 0, block + 4, block + 8, block + 12, digest);
remaining_len -= block_total_len;
plain_ptr += 64;
}
}
static void precompute_salt_md5 (const u32 *salt_buf, const u32 salt_len, u8 *salt_pc)
{
u32 digest[4] = { 0 };

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -47,6 +47,72 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len)
{
digest[0] = MD5M_A;
digest[1] = MD5M_B;
digest[2] = MD5M_C;
digest[3] = MD5M_D;
int block_total_len = 16 * 4; // sizeof (block)
u8 *plain_ptr = (u8 *) plain;
// init
int remaining_len = (int) plain_len;
// loop
u32 loop = 1;
while (loop)
{
loop = (remaining_len > 55);
int cur_len = MIN (block_total_len, remaining_len);
int copy_len = MAX (cur_len, 0); // should never be negative of course
// initialize the block
u32 block[16] = { 0 };
// copy the bytes from the plain pointer (plain_ptr)
memcpy (block, plain, (size_t) copy_len);
/*
* final block
*/
// set 0x80 if needed
if (cur_len >= 0)
{
if (copy_len < block_total_len)
{
u8 *block_ptr = (u8 *) block;
block_ptr[copy_len] = 0x80;
}
}
// set block[14] set to total_len
if (! loop) block[14] = plain_len * 8;
/*
* md5 ()
*/
md5_transform (block + 0, block + 4, block + 8, block + 12, digest);
remaining_len -= block_total_len;
plain_ptr += 64;
}
}
static void precompute_salt_md5 (const u32 *salt_buf, const u32 salt_len, u8 *salt_pc)
{
u32 digest[4] = { 0 };

@ -9,8 +9,8 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "cpu_md5.h"
#include "emu_inc_cipher_des.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -246,7 +246,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
dgst[2] = MD5M_C;
dgst[3] = MD5M_D;
md5_64 (w, dgst);
md5_transform (w + 0, w + 4, w + 8, w + 12, dgst);
salt->salt_buf[0] = dgst[0];
salt->salt_buf[1] = dgst[1];
@ -265,11 +265,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
u32 Kc[16] = { 0 };
u32 Kd[16] = { 0 };
_des_keysetup (key_des, Kc, Kd);
_des_crypt_keysetup (key_des[0], key_des[1], Kc, Kd, (u32 (*)[64]) c_skb);
u32 data3[2] = { salt->salt_buf[0], salt->salt_buf[1] };
_des_encrypt (data3, Kc, Kd);
_des_crypt_encrypt (data3, data3, Kc, Kd, (u32 (*)[64]) c_SPtrans);
if (data3[0] != digest_tmp[0]) continue;
if (data3[1] != digest_tmp[1]) continue;

@ -9,8 +9,8 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "cpu_md5.h"
#include "emu_inc_cipher_des.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -214,14 +214,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
for (u32 i = 0; i < 64; i += 16, uptr += 16)
{
md5_64 (uptr, salt->salt_buf);
md5_transform (uptr + 0, uptr + 4, uptr + 8, uptr + 12, salt->salt_buf);
}
uptr = (u32 *) netntlm->chall_buf;
for (u32 i = 0; i < 256; i += 16, uptr += 16)
{
md5_64 (uptr, salt->salt_buf);
md5_transform (uptr + 0, uptr + 4, uptr + 8, uptr + 12, salt->salt_buf);
}
salt->salt_len = 16;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -72,6 +72,72 @@ typedef struct pdf14_tmp
static const char *SIGNATURE_PDF = "$pdf$";
static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len)
{
digest[0] = MD5M_A;
digest[1] = MD5M_B;
digest[2] = MD5M_C;
digest[3] = MD5M_D;
int block_total_len = 16 * 4; // sizeof (block)
u8 *plain_ptr = (u8 *) plain;
// init
int remaining_len = (int) plain_len;
// loop
u32 loop = 1;
while (loop)
{
loop = (remaining_len > 55);
int cur_len = MIN (block_total_len, remaining_len);
int copy_len = MAX (cur_len, 0); // should never be negative of course
// initialize the block
u32 block[16] = { 0 };
// copy the bytes from the plain pointer (plain_ptr)
memcpy (block, plain, (size_t) copy_len);
/*
* final block
*/
// set 0x80 if needed
if (cur_len >= 0)
{
if (copy_len < block_total_len)
{
u8 *block_ptr = (u8 *) block;
block_ptr[copy_len] = 0x80;
}
}
// set block[14] set to total_len
if (! loop) block[14] = plain_len * 8;
/*
* md5 ()
*/
md5_transform (block + 0, block + 4, block + 8, block + 12, digest);
remaining_len -= block_total_len;
plain_ptr += 64;
}
}
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u64 esalt_size = (const u64) sizeof (pdf_t);

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
@ -55,6 +55,72 @@ typedef struct sip
static const char *SIGNATURE_SIP_AUTH = "$sip$";
static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 plain_len)
{
digest[0] = MD5M_A;
digest[1] = MD5M_B;
digest[2] = MD5M_C;
digest[3] = MD5M_D;
int block_total_len = 16 * 4; // sizeof (block)
u8 *plain_ptr = (u8 *) plain;
// init
int remaining_len = (int) plain_len;
// loop
u32 loop = 1;
while (loop)
{
loop = (remaining_len > 55);
int cur_len = MIN (block_total_len, remaining_len);
int copy_len = MAX (cur_len, 0); // should never be negative of course
// initialize the block
u32 block[16] = { 0 };
// copy the bytes from the plain pointer (plain_ptr)
memcpy (block, plain, (size_t) copy_len);
/*
* final block
*/
// set 0x80 if needed
if (cur_len >= 0)
{
if (copy_len < block_total_len)
{
u8 *block_ptr = (u8 *) block;
block_ptr[copy_len] = 0x80;
}
}
// set block[14] set to total_len
if (! loop) block[14] = plain_len * 8;
/*
* md5 ()
*/
md5_transform (block + 0, block + 4, block + 8, block + 12, digest);
remaining_len -= block_total_len;
plain_ptr += 64;
}
}
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u64 esalt_size = (const u64) sizeof (sip_t);

@ -10,7 +10,7 @@
#include "convert.h"
#include "shared.h"
#include "memory.h"
#include "cpu_aes.h"
#include "emu_inc_cipher_aes.h"
#include "cpu_crc32.h"
#include "ext_lzma.h"
@ -110,7 +110,7 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
seven_zip_hook_t *hook_item = &hook_items[pw_pos];
const u8 *ukey = (const u8 *) hook_item->ukey;
const u32 *ukey = (const u32 *) hook_item->ukey;
// init AES
@ -118,13 +118,13 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
memset (&aes_key, 0, sizeof (aes_key));
AES_set_decrypt_key (ukey, 256, &aes_key);
aes256_set_decrypt_key (aes_key.rdk, ukey, (u32 *) te0, (u32 *) te1, (u32 *) te2, (u32 *) te3, (u32 *) te4, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4);
int aes_len = seven_zip->aes_len;
u32 data[4];
u32 out [4];
u32 iv [4];
u32 out[4];
u32 iv[4];
iv[0] = seven_zip->iv_buf[0];
iv[1] = seven_zip->iv_buf[1];
@ -145,7 +145,7 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
data[2] = data_buf[j + 2];
data[3] = data_buf[j + 3];
AES_decrypt (&aes_key, (u8*) data, (u8*) out);
aes256_decrypt (aes_key.rdk, data, out, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4);
out[0] ^= iv[0];
out[1] ^= iv[1];
@ -170,7 +170,7 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
data[2] = data_buf[j + 2];
data[3] = data_buf[j + 3];
AES_decrypt (&aes_key, (u8*) data, (u8*) out);
aes256_decrypt (aes_key.rdk, data, out, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4);
out[0] ^= iv[0];
out[1] ^= iv[1];

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_sha256.h"
#include "emu_inc_hash_sha256.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 3;
@ -138,7 +138,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
u32 pc256[8] = { SHA256M_A, SHA256M_B, SHA256M_C, SHA256M_D, SHA256M_E, SHA256M_F, SHA256M_G, SHA256M_H };
sha256_64 (w, pc256);
sha256_transform (w + 0, w + 4, w + 8, w + 12, pc256);
salt->salt_buf_pc[0] = pc256[0];
salt->salt_buf_pc[1] = pc256[1];

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#include "emu_inc_cipher_des.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
#include "memory.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
@ -192,7 +192,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{
block[j] = jwt->salt_buf[i + j];
md5_64 (block, hash);
md5_transform (block + 0, block + 4, block + 8, block + 12, hash);
}
}

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
#include "memory.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
@ -42,19 +42,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
typedef struct md5_ctx
{
u32 h[4];
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
int len;
} md5_ctx_t;
typedef struct qnx_md5_tmp
{
md5_ctx_t md5_ctx;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_sha256.h"
#include "memory.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
@ -42,19 +42,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
typedef struct sha256_ctx
{
u32 h[8];
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
int len;
} sha256_ctx_t;
typedef struct qnx_sha256_tmp
{
sha256_ctx_t sha256_ctx;

@ -9,7 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_md5.h"
#include "emu_inc_hash_sha512.h"
#include "memory.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
@ -42,23 +42,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
typedef struct sha512_ctx
{
u64 h[8];
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
u32 w4[4];
u32 w5[4];
u32 w6[4];
u32 w7[4];
int len;
} sha512_ctx_t;
typedef struct qnx_sha512_tmp
{
sha512_ctx_t sha512_ctx;

@ -22,7 +22,7 @@
#include "wordlist.h"
#include "shared.h"
#include "hashes.h"
#include "cpu_md5.h"
#include "emu_inc_hash_md5.h"
#include "event.h"
#include "dynloader.h"
#include "opencl.h"
@ -4902,20 +4902,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%u-%u-%s-%s-%s-%d-%u-%u", device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, hashconfig->hash_mode);
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%u-%s-%s-%s-%d", device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime);
u32 *device_name_chksum32 = (u32 *) device_name_chksum;
u32 device_name_digest[4] = { 0 };
for (size_t i = 0; i < dnclen; i += 64)
{
md5_64 ((u32 *) (device_name_chksum + i), device_name_digest);
md5_transform (device_name_chksum32 + 0, device_name_chksum32 + 4, device_name_chksum32 + 8, device_name_chksum32 + 12, device_name_digest);
device_name_chksum32 += 16;
}
snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", device_name_digest[0]);
u32 *device_name_chksum_amp_mp32 = (u32 *) device_name_chksum;
u32 device_name_digest_amp_mp[4] = { 0 };
for (size_t i = 0; i < dnclen_amp_mp; i += 64)
{
md5_64 ((u32 *) (device_name_chksum_amp_mp + i), device_name_digest_amp_mp);
md5_transform (device_name_chksum_amp_mp32 + 0, device_name_chksum_amp_mp32 + 4, device_name_chksum_amp_mp32 + 8, device_name_chksum_amp_mp32 + 12, device_name_digest_amp_mp);
device_name_chksum_amp_mp32 += 16;
}
snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%08x", device_name_digest_amp_mp[0]);

@ -8,7 +8,6 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "cpu_des.h"
#if defined (__CYGWIN__)
#include <sys/cygwin.h>

Loading…
Cancel
Save