2017-07-03 16:11:57 +02:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NEW_SIMD_CODE
|
|
|
|
|
2019-03-22 15:16:25 +01:00
|
|
|
#ifdef KERNEL_STATIC
|
2019-03-21 23:00:38 +01:00
|
|
|
#include "inc_vendor.h"
|
|
|
|
#include "inc_types.h"
|
2017-07-03 16:11:57 +02:00
|
|
|
#include "inc_common.cl"
|
|
|
|
#include "inc_simd.cl"
|
|
|
|
#include "inc_hash_md5.cl"
|
|
|
|
#include "inc_hash_sha1.cl"
|
2017-09-19 12:19:46 +02:00
|
|
|
#include "inc_hash_sha256.cl"
|
2017-09-19 10:22:03 +02:00
|
|
|
#include "inc_cipher_aes.cl"
|
2019-03-23 22:15:38 +01:00
|
|
|
#else
|
|
|
|
#include "inc_vendor.h"
|
|
|
|
#include "inc_types.h"
|
|
|
|
#include "inc_common.h"
|
|
|
|
#include "inc_simd.h"
|
|
|
|
#include "inc_hash_md5.h"
|
|
|
|
#include "inc_hash_sha1.h"
|
|
|
|
#include "inc_hash_sha256.h"
|
|
|
|
#include "inc_cipher_aes.h"
|
2019-03-22 15:16:25 +01:00
|
|
|
#endif
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2019-03-08 13:05:23 +01:00
|
|
|
typedef struct wpa_pmk_tmp
|
|
|
|
{
|
|
|
|
u32 out[8];
|
|
|
|
|
|
|
|
} wpa_pmk_tmp_t;
|
|
|
|
|
2019-03-08 10:18:20 +01:00
|
|
|
typedef struct wpa_eapol
|
|
|
|
{
|
|
|
|
u32 pke[32];
|
|
|
|
u32 eapol[64 + 16];
|
|
|
|
u16 eapol_len;
|
|
|
|
u8 message_pair;
|
|
|
|
int message_pair_chgd;
|
|
|
|
u8 keyver;
|
|
|
|
u8 orig_mac_ap[6];
|
|
|
|
u8 orig_mac_sta[6];
|
|
|
|
u8 orig_nonce_ap[32];
|
|
|
|
u8 orig_nonce_sta[32];
|
|
|
|
u8 essid_len;
|
|
|
|
u8 essid[32];
|
|
|
|
u32 keymic[4];
|
|
|
|
u32 hash[4];
|
|
|
|
int nonce_compare;
|
|
|
|
int nonce_error_corrections;
|
|
|
|
int detected_le;
|
|
|
|
int detected_be;
|
|
|
|
|
|
|
|
} wpa_eapol_t;
|
|
|
|
|
2019-03-26 11:03:25 +01:00
|
|
|
DECLSPEC static u8 hex_convert (const u8 c)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
|
|
|
return (c & 15) + (c >> 6) * 9;
|
|
|
|
}
|
|
|
|
|
2019-03-26 11:03:25 +01:00
|
|
|
DECLSPEC static u8 hex_to_u8 (const u8 *hex)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
|
|
|
u8 v = 0;
|
|
|
|
|
|
|
|
v |= ((u8) hex_convert (hex[1]) << 0);
|
|
|
|
v |= ((u8) hex_convert (hex[0]) << 4);
|
|
|
|
|
|
|
|
return (v);
|
|
|
|
}
|
|
|
|
|
2019-03-26 11:03:25 +01:00
|
|
|
DECLSPEC static void make_kn (u32 *k)
|
2017-09-19 13:45:43 +02:00
|
|
|
{
|
|
|
|
u32 kl[4];
|
|
|
|
u32 kr[4];
|
|
|
|
|
|
|
|
kl[0] = (k[0] << 1) & 0xfefefefe;
|
|
|
|
kl[1] = (k[1] << 1) & 0xfefefefe;
|
|
|
|
kl[2] = (k[2] << 1) & 0xfefefefe;
|
|
|
|
kl[3] = (k[3] << 1) & 0xfefefefe;
|
|
|
|
|
|
|
|
kr[0] = (k[0] >> 7) & 0x01010101;
|
|
|
|
kr[1] = (k[1] >> 7) & 0x01010101;
|
|
|
|
kr[2] = (k[2] >> 7) & 0x01010101;
|
|
|
|
kr[3] = (k[3] >> 7) & 0x01010101;
|
|
|
|
|
|
|
|
const u32 c = kr[0] & 1;
|
|
|
|
|
|
|
|
kr[0] = kr[0] >> 8 | kr[1] << 24;
|
|
|
|
kr[1] = kr[1] >> 8 | kr[2] << 24;
|
|
|
|
kr[2] = kr[2] >> 8 | kr[3] << 24;
|
|
|
|
kr[3] = kr[3] >> 8;
|
|
|
|
|
|
|
|
k[0] = kl[0] | kr[0];
|
|
|
|
k[1] = kl[1] | kr[1];
|
|
|
|
k[2] = kl[2] | kr[2];
|
|
|
|
k[3] = kl[3] | kr[3];
|
2017-09-20 09:40:14 +02:00
|
|
|
|
|
|
|
k[3] ^= c * 0x87000000;
|
2017-09-19 13:45:43 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_init (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
|
|
|
u32 in[16];
|
|
|
|
|
|
|
|
in[ 0] = pws[gid].i[ 0];
|
|
|
|
in[ 1] = pws[gid].i[ 1];
|
|
|
|
in[ 2] = pws[gid].i[ 2];
|
|
|
|
in[ 3] = pws[gid].i[ 3];
|
|
|
|
in[ 4] = pws[gid].i[ 4];
|
|
|
|
in[ 5] = pws[gid].i[ 5];
|
|
|
|
in[ 6] = pws[gid].i[ 6];
|
|
|
|
in[ 7] = pws[gid].i[ 7];
|
|
|
|
in[ 8] = pws[gid].i[ 8];
|
|
|
|
in[ 9] = pws[gid].i[ 9];
|
|
|
|
in[10] = pws[gid].i[10];
|
|
|
|
in[11] = pws[gid].i[11];
|
|
|
|
in[12] = pws[gid].i[12];
|
|
|
|
in[13] = pws[gid].i[13];
|
|
|
|
in[14] = pws[gid].i[14];
|
|
|
|
in[15] = pws[gid].i[15];
|
|
|
|
|
|
|
|
u8 *in_ptr = (u8 *) in;
|
|
|
|
|
|
|
|
u32 out[8];
|
|
|
|
|
|
|
|
u8 *out_ptr = (u8 *) out;
|
|
|
|
|
|
|
|
for (int i = 0, j = 0; i < 32; i += 1, j += 2)
|
|
|
|
{
|
|
|
|
out_ptr[i] = hex_to_u8 (in_ptr + j);
|
|
|
|
}
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
tmps[gid].out[0] = hc_swap32_S (out[0]);
|
|
|
|
tmps[gid].out[1] = hc_swap32_S (out[1]);
|
|
|
|
tmps[gid].out[2] = hc_swap32_S (out[2]);
|
|
|
|
tmps[gid].out[3] = hc_swap32_S (out[3]);
|
|
|
|
tmps[gid].out[4] = hc_swap32_S (out[4]);
|
|
|
|
tmps[gid].out[5] = hc_swap32_S (out[5]);
|
|
|
|
tmps[gid].out[6] = hc_swap32_S (out[6]);
|
|
|
|
tmps[gid].out[7] = hc_swap32_S (out[7]);
|
2017-07-03 16:11:57 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_loop (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_comp (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
// not in use here, special case...
|
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2017-08-19 16:39:22 +02:00
|
|
|
const u64 gid = get_global_id (0);
|
2017-09-19 10:22:03 +02:00
|
|
|
const u64 lid = get_local_id (0);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
|
|
|
u32 out[8];
|
|
|
|
|
|
|
|
out[0] = tmps[gid].out[0];
|
|
|
|
out[1] = tmps[gid].out[1];
|
|
|
|
out[2] = tmps[gid].out[2];
|
|
|
|
out[3] = tmps[gid].out[3];
|
|
|
|
out[4] = tmps[gid].out[4];
|
|
|
|
out[5] = tmps[gid].out[5];
|
|
|
|
out[6] = tmps[gid].out[6];
|
|
|
|
out[7] = tmps[gid].out[7];
|
|
|
|
|
|
|
|
const u32 digest_pos = loop_pos;
|
|
|
|
|
|
|
|
const u32 digest_cur = digests_offset + digest_pos;
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
GLOBAL_AS const wpa_eapol_t *wpa_eapol = &esalt_bufs[digest_cur];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
|
|
|
u32 pke[32];
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
pke[ 0] = wpa_eapol->pke[ 0];
|
|
|
|
pke[ 1] = wpa_eapol->pke[ 1];
|
|
|
|
pke[ 2] = wpa_eapol->pke[ 2];
|
|
|
|
pke[ 3] = wpa_eapol->pke[ 3];
|
|
|
|
pke[ 4] = wpa_eapol->pke[ 4];
|
|
|
|
pke[ 5] = wpa_eapol->pke[ 5];
|
|
|
|
pke[ 6] = wpa_eapol->pke[ 6];
|
|
|
|
pke[ 7] = wpa_eapol->pke[ 7];
|
|
|
|
pke[ 8] = wpa_eapol->pke[ 8];
|
|
|
|
pke[ 9] = wpa_eapol->pke[ 9];
|
|
|
|
pke[10] = wpa_eapol->pke[10];
|
|
|
|
pke[11] = wpa_eapol->pke[11];
|
|
|
|
pke[12] = wpa_eapol->pke[12];
|
|
|
|
pke[13] = wpa_eapol->pke[13];
|
|
|
|
pke[14] = wpa_eapol->pke[14];
|
|
|
|
pke[15] = wpa_eapol->pke[15];
|
|
|
|
pke[16] = wpa_eapol->pke[16];
|
|
|
|
pke[17] = wpa_eapol->pke[17];
|
|
|
|
pke[18] = wpa_eapol->pke[18];
|
|
|
|
pke[19] = wpa_eapol->pke[19];
|
|
|
|
pke[20] = wpa_eapol->pke[20];
|
|
|
|
pke[21] = wpa_eapol->pke[21];
|
|
|
|
pke[22] = wpa_eapol->pke[22];
|
|
|
|
pke[23] = wpa_eapol->pke[23];
|
|
|
|
pke[24] = wpa_eapol->pke[24];
|
|
|
|
pke[25] = wpa_eapol->pke[25];
|
|
|
|
pke[26] = wpa_eapol->pke[26];
|
|
|
|
pke[27] = wpa_eapol->pke[27];
|
|
|
|
pke[28] = wpa_eapol->pke[28];
|
|
|
|
pke[29] = wpa_eapol->pke[29];
|
|
|
|
pke[30] = wpa_eapol->pke[30];
|
|
|
|
pke[31] = wpa_eapol->pke[31];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
|
|
|
u32 to;
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
|
|
|
to = pke[15] << 24
|
|
|
|
| pke[16] >> 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
to = pke[23] << 24
|
|
|
|
| pke[24] >> 8;
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
const u32 nonce_error_corrections = wpa_eapol->nonce_error_corrections;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_le == 1)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
|
|
|
{
|
|
|
|
u32 t = to;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
|
|
|
|
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
|
|
|
u32 keymic[4];
|
|
|
|
|
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx1;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
|
|
|
|
|
|
|
sha1_hmac_update (&ctx1, pke, 100);
|
|
|
|
|
|
|
|
sha1_hmac_final (&ctx1);
|
|
|
|
|
|
|
|
u32 digest[4];
|
|
|
|
|
|
|
|
digest[0] = ctx1.opad.h[0];
|
|
|
|
digest[1] = ctx1.opad.h[1];
|
|
|
|
digest[2] = ctx1.opad.h[2];
|
|
|
|
digest[3] = ctx1.opad.h[3];
|
|
|
|
|
|
|
|
u32 t0[4];
|
|
|
|
u32 t1[4];
|
|
|
|
u32 t2[4];
|
|
|
|
u32 t3[4];
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t0[0] = hc_swap32_S (digest[0]);
|
|
|
|
t0[1] = hc_swap32_S (digest[1]);
|
|
|
|
t0[2] = hc_swap32_S (digest[2]);
|
|
|
|
t0[3] = hc_swap32_S (digest[3]);
|
2018-06-15 17:00:41 +02:00
|
|
|
t1[0] = 0;
|
|
|
|
t1[1] = 0;
|
|
|
|
t1[2] = 0;
|
|
|
|
t1[3] = 0;
|
|
|
|
t2[0] = 0;
|
|
|
|
t2[1] = 0;
|
|
|
|
t2[2] = 0;
|
|
|
|
t2[3] = 0;
|
|
|
|
t3[0] = 0;
|
|
|
|
t3[1] = 0;
|
|
|
|
t3[2] = 0;
|
|
|
|
t3[3] = 0;
|
|
|
|
|
|
|
|
md5_hmac_ctx_t ctx2;
|
|
|
|
|
|
|
|
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
md5_hmac_update_global (&ctx2, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
md5_hmac_final (&ctx2);
|
|
|
|
|
|
|
|
keymic[0] = ctx2.opad.h[0];
|
|
|
|
keymic[1] = ctx2.opad.h[1];
|
|
|
|
keymic[2] = ctx2.opad.h[2];
|
|
|
|
keymic[3] = ctx2.opad.h[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
}
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_be == 1)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 t = to;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
|
|
|
|
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
|
|
|
u32 keymic[4];
|
|
|
|
|
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx1;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
|
|
|
|
|
|
|
sha1_hmac_update (&ctx1, pke, 100);
|
|
|
|
|
|
|
|
sha1_hmac_final (&ctx1);
|
|
|
|
|
|
|
|
u32 digest[4];
|
|
|
|
|
|
|
|
digest[0] = ctx1.opad.h[0];
|
|
|
|
digest[1] = ctx1.opad.h[1];
|
|
|
|
digest[2] = ctx1.opad.h[2];
|
|
|
|
digest[3] = ctx1.opad.h[3];
|
|
|
|
|
|
|
|
u32 t0[4];
|
|
|
|
u32 t1[4];
|
|
|
|
u32 t2[4];
|
|
|
|
u32 t3[4];
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t0[0] = hc_swap32_S (digest[0]);
|
|
|
|
t0[1] = hc_swap32_S (digest[1]);
|
|
|
|
t0[2] = hc_swap32_S (digest[2]);
|
|
|
|
t0[3] = hc_swap32_S (digest[3]);
|
2018-06-15 17:00:41 +02:00
|
|
|
t1[0] = 0;
|
|
|
|
t1[1] = 0;
|
|
|
|
t1[2] = 0;
|
|
|
|
t1[3] = 0;
|
|
|
|
t2[0] = 0;
|
|
|
|
t2[1] = 0;
|
|
|
|
t2[2] = 0;
|
|
|
|
t2[3] = 0;
|
|
|
|
t3[0] = 0;
|
|
|
|
t3[1] = 0;
|
|
|
|
t3[2] = 0;
|
|
|
|
t3[3] = 0;
|
|
|
|
|
|
|
|
md5_hmac_ctx_t ctx2;
|
|
|
|
|
|
|
|
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
md5_hmac_update_global (&ctx2, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
md5_hmac_final (&ctx2);
|
|
|
|
|
|
|
|
keymic[0] = ctx2.opad.h[0];
|
|
|
|
keymic[1] = ctx2.opad.h[1];
|
|
|
|
keymic[2] = ctx2.opad.h[2];
|
|
|
|
keymic[3] = ctx2.opad.h[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
2018-02-13 09:13:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
const u64 lid = get_local_id (0);
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
if (gid >= gid_max) return;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
u32 out[8];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
out[0] = tmps[gid].out[0];
|
|
|
|
out[1] = tmps[gid].out[1];
|
|
|
|
out[2] = tmps[gid].out[2];
|
|
|
|
out[3] = tmps[gid].out[3];
|
|
|
|
out[4] = tmps[gid].out[4];
|
|
|
|
out[5] = tmps[gid].out[5];
|
|
|
|
out[6] = tmps[gid].out[6];
|
|
|
|
out[7] = tmps[gid].out[7];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
const u32 digest_pos = loop_pos;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
const u32 digest_cur = digests_offset + digest_pos;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
GLOBAL_AS const wpa_eapol_t *wpa_eapol = &esalt_bufs[digest_cur];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
u32 pke[32];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
pke[ 0] = wpa_eapol->pke[ 0];
|
|
|
|
pke[ 1] = wpa_eapol->pke[ 1];
|
|
|
|
pke[ 2] = wpa_eapol->pke[ 2];
|
|
|
|
pke[ 3] = wpa_eapol->pke[ 3];
|
|
|
|
pke[ 4] = wpa_eapol->pke[ 4];
|
|
|
|
pke[ 5] = wpa_eapol->pke[ 5];
|
|
|
|
pke[ 6] = wpa_eapol->pke[ 6];
|
|
|
|
pke[ 7] = wpa_eapol->pke[ 7];
|
|
|
|
pke[ 8] = wpa_eapol->pke[ 8];
|
|
|
|
pke[ 9] = wpa_eapol->pke[ 9];
|
|
|
|
pke[10] = wpa_eapol->pke[10];
|
|
|
|
pke[11] = wpa_eapol->pke[11];
|
|
|
|
pke[12] = wpa_eapol->pke[12];
|
|
|
|
pke[13] = wpa_eapol->pke[13];
|
|
|
|
pke[14] = wpa_eapol->pke[14];
|
|
|
|
pke[15] = wpa_eapol->pke[15];
|
|
|
|
pke[16] = wpa_eapol->pke[16];
|
|
|
|
pke[17] = wpa_eapol->pke[17];
|
|
|
|
pke[18] = wpa_eapol->pke[18];
|
|
|
|
pke[19] = wpa_eapol->pke[19];
|
|
|
|
pke[20] = wpa_eapol->pke[20];
|
|
|
|
pke[21] = wpa_eapol->pke[21];
|
|
|
|
pke[22] = wpa_eapol->pke[22];
|
|
|
|
pke[23] = wpa_eapol->pke[23];
|
|
|
|
pke[24] = wpa_eapol->pke[24];
|
|
|
|
pke[25] = wpa_eapol->pke[25];
|
|
|
|
pke[26] = wpa_eapol->pke[26];
|
|
|
|
pke[27] = wpa_eapol->pke[27];
|
|
|
|
pke[28] = wpa_eapol->pke[28];
|
|
|
|
pke[29] = wpa_eapol->pke[29];
|
|
|
|
pke[30] = wpa_eapol->pke[30];
|
|
|
|
pke[31] = wpa_eapol->pke[31];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-02-13 09:13:35 +01:00
|
|
|
u32 to;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
to = pke[15] << 24
|
|
|
|
| pke[16] >> 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
to = pke[23] << 24
|
|
|
|
| pke[24] >> 8;
|
|
|
|
}
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
const u32 nonce_error_corrections = wpa_eapol->nonce_error_corrections;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_le == 1)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
|
|
|
{
|
|
|
|
u32 t = to;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
|
|
|
|
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
|
|
|
u32 keymic[4];
|
|
|
|
|
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx1;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
|
|
|
|
|
|
|
sha1_hmac_update (&ctx1, pke, 100);
|
|
|
|
|
|
|
|
sha1_hmac_final (&ctx1);
|
|
|
|
|
|
|
|
u32 digest[4];
|
|
|
|
|
|
|
|
digest[0] = ctx1.opad.h[0];
|
|
|
|
digest[1] = ctx1.opad.h[1];
|
|
|
|
digest[2] = ctx1.opad.h[2];
|
|
|
|
digest[3] = ctx1.opad.h[3];
|
|
|
|
|
|
|
|
u32 t0[4];
|
|
|
|
u32 t1[4];
|
|
|
|
u32 t2[4];
|
|
|
|
u32 t3[4];
|
|
|
|
|
|
|
|
t0[0] = digest[0];
|
|
|
|
t0[1] = digest[1];
|
|
|
|
t0[2] = digest[2];
|
|
|
|
t0[3] = digest[3];
|
|
|
|
t1[0] = 0;
|
|
|
|
t1[1] = 0;
|
|
|
|
t1[2] = 0;
|
|
|
|
t1[3] = 0;
|
|
|
|
t2[0] = 0;
|
|
|
|
t2[1] = 0;
|
|
|
|
t2[2] = 0;
|
|
|
|
t2[3] = 0;
|
|
|
|
t3[0] = 0;
|
|
|
|
t3[1] = 0;
|
|
|
|
t3[2] = 0;
|
|
|
|
t3[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx2;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
sha1_hmac_update_global (&ctx2, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
sha1_hmac_final (&ctx2);
|
|
|
|
|
|
|
|
keymic[0] = ctx2.opad.h[0];
|
|
|
|
keymic[1] = ctx2.opad.h[1];
|
|
|
|
keymic[2] = ctx2.opad.h[2];
|
|
|
|
keymic[3] = ctx2.opad.h[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
|
|
|
}
|
2018-02-13 09:13:35 +01:00
|
|
|
}
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_be == 1)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 t = to;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
|
|
|
|
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
|
|
|
u32 keymic[4];
|
|
|
|
|
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx1;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
|
|
|
|
|
|
|
sha1_hmac_update (&ctx1, pke, 100);
|
|
|
|
|
|
|
|
sha1_hmac_final (&ctx1);
|
|
|
|
|
|
|
|
u32 digest[4];
|
|
|
|
|
|
|
|
digest[0] = ctx1.opad.h[0];
|
|
|
|
digest[1] = ctx1.opad.h[1];
|
|
|
|
digest[2] = ctx1.opad.h[2];
|
|
|
|
digest[3] = ctx1.opad.h[3];
|
|
|
|
|
|
|
|
u32 t0[4];
|
|
|
|
u32 t1[4];
|
|
|
|
u32 t2[4];
|
|
|
|
u32 t3[4];
|
|
|
|
|
|
|
|
t0[0] = digest[0];
|
|
|
|
t0[1] = digest[1];
|
|
|
|
t0[2] = digest[2];
|
|
|
|
t0[3] = digest[3];
|
|
|
|
t1[0] = 0;
|
|
|
|
t1[1] = 0;
|
|
|
|
t1[2] = 0;
|
|
|
|
t1[3] = 0;
|
|
|
|
t2[0] = 0;
|
|
|
|
t2[1] = 0;
|
|
|
|
t2[2] = 0;
|
|
|
|
t2[3] = 0;
|
|
|
|
t3[0] = 0;
|
|
|
|
t3[1] = 0;
|
|
|
|
t3[2] = 0;
|
|
|
|
t3[3] = 0;
|
|
|
|
|
|
|
|
sha1_hmac_ctx_t ctx2;
|
|
|
|
|
|
|
|
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
sha1_hmac_update_global (&ctx2, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
sha1_hmac_final (&ctx2);
|
|
|
|
|
|
|
|
keymic[0] = ctx2.opad.h[0];
|
|
|
|
keymic[1] = ctx2.opad.h[1];
|
|
|
|
keymic[2] = ctx2.opad.h[2];
|
|
|
|
keymic[3] = ctx2.opad.h[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 09:13:35 +01:00
|
|
|
}
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
KERNEL_FQ void m02501_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_eapol_t))
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
const u64 gid = get_global_id (0);
|
|
|
|
const u64 lid = get_local_id (0);
|
|
|
|
const u64 lsz = get_local_size (0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aes shared
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef REAL_SHM
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
LOCAL_AS u32 s_td0[256];
|
|
|
|
LOCAL_AS u32 s_td1[256];
|
|
|
|
LOCAL_AS u32 s_td2[256];
|
|
|
|
LOCAL_AS u32 s_td3[256];
|
|
|
|
LOCAL_AS u32 s_td4[256];
|
2018-02-13 09:13:35 +01:00
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
LOCAL_AS u32 s_te0[256];
|
|
|
|
LOCAL_AS u32 s_te1[256];
|
|
|
|
LOCAL_AS u32 s_te2[256];
|
|
|
|
LOCAL_AS u32 s_te3[256];
|
|
|
|
LOCAL_AS u32 s_te4[256];
|
2018-02-13 09:13:35 +01:00
|
|
|
|
2019-03-03 19:18:56 +01:00
|
|
|
for (u32 i = lid; i < 256; i += lsz)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
s_td0[i] = td0[i];
|
|
|
|
s_td1[i] = td1[i];
|
|
|
|
s_td2[i] = td2[i];
|
|
|
|
s_td3[i] = td3[i];
|
|
|
|
s_td4[i] = td4[i];
|
|
|
|
|
|
|
|
s_te0[i] = te0[i];
|
|
|
|
s_te1[i] = te1[i];
|
|
|
|
s_te2[i] = te2[i];
|
|
|
|
s_te3[i] = te3[i];
|
|
|
|
s_te4[i] = te4[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
barrier (CLK_LOCAL_MEM_FENCE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
CONSTANT_AS u32a *s_td0 = td0;
|
|
|
|
CONSTANT_AS u32a *s_td1 = td1;
|
|
|
|
CONSTANT_AS u32a *s_td2 = td2;
|
|
|
|
CONSTANT_AS u32a *s_td3 = td3;
|
|
|
|
CONSTANT_AS u32a *s_td4 = td4;
|
2018-02-13 09:13:35 +01:00
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
CONSTANT_AS u32a *s_te0 = te0;
|
|
|
|
CONSTANT_AS u32a *s_te1 = te1;
|
|
|
|
CONSTANT_AS u32a *s_te2 = te2;
|
|
|
|
CONSTANT_AS u32a *s_te3 = te3;
|
|
|
|
CONSTANT_AS u32a *s_te4 = te4;
|
2018-02-13 09:13:35 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
|
|
|
u32 out[8];
|
|
|
|
|
|
|
|
out[0] = tmps[gid].out[0];
|
|
|
|
out[1] = tmps[gid].out[1];
|
|
|
|
out[2] = tmps[gid].out[2];
|
|
|
|
out[3] = tmps[gid].out[3];
|
|
|
|
out[4] = tmps[gid].out[4];
|
|
|
|
out[5] = tmps[gid].out[5];
|
|
|
|
out[6] = tmps[gid].out[6];
|
|
|
|
out[7] = tmps[gid].out[7];
|
|
|
|
|
|
|
|
const u32 digest_pos = loop_pos;
|
|
|
|
|
|
|
|
const u32 digest_cur = digests_offset + digest_pos;
|
|
|
|
|
2019-03-22 22:27:58 +01:00
|
|
|
GLOBAL_AS const wpa_eapol_t *wpa_eapol = &esalt_bufs[digest_cur];
|
2018-02-13 09:13:35 +01:00
|
|
|
|
|
|
|
u32 pke[32];
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
pke[ 0] = wpa_eapol->pke[ 0];
|
|
|
|
pke[ 1] = wpa_eapol->pke[ 1];
|
|
|
|
pke[ 2] = wpa_eapol->pke[ 2];
|
|
|
|
pke[ 3] = wpa_eapol->pke[ 3];
|
|
|
|
pke[ 4] = wpa_eapol->pke[ 4];
|
|
|
|
pke[ 5] = wpa_eapol->pke[ 5];
|
|
|
|
pke[ 6] = wpa_eapol->pke[ 6];
|
|
|
|
pke[ 7] = wpa_eapol->pke[ 7];
|
|
|
|
pke[ 8] = wpa_eapol->pke[ 8];
|
|
|
|
pke[ 9] = wpa_eapol->pke[ 9];
|
|
|
|
pke[10] = wpa_eapol->pke[10];
|
|
|
|
pke[11] = wpa_eapol->pke[11];
|
|
|
|
pke[12] = wpa_eapol->pke[12];
|
|
|
|
pke[13] = wpa_eapol->pke[13];
|
|
|
|
pke[14] = wpa_eapol->pke[14];
|
|
|
|
pke[15] = wpa_eapol->pke[15];
|
|
|
|
pke[16] = wpa_eapol->pke[16];
|
|
|
|
pke[17] = wpa_eapol->pke[17];
|
|
|
|
pke[18] = wpa_eapol->pke[18];
|
|
|
|
pke[19] = wpa_eapol->pke[19];
|
|
|
|
pke[20] = wpa_eapol->pke[20];
|
|
|
|
pke[21] = wpa_eapol->pke[21];
|
|
|
|
pke[22] = wpa_eapol->pke[22];
|
|
|
|
pke[23] = wpa_eapol->pke[23];
|
|
|
|
pke[24] = wpa_eapol->pke[24];
|
|
|
|
pke[25] = wpa_eapol->pke[25];
|
|
|
|
pke[26] = wpa_eapol->pke[26];
|
|
|
|
pke[27] = wpa_eapol->pke[27];
|
|
|
|
pke[28] = wpa_eapol->pke[28];
|
|
|
|
pke[29] = wpa_eapol->pke[29];
|
|
|
|
pke[30] = wpa_eapol->pke[30];
|
|
|
|
pke[31] = wpa_eapol->pke[31];
|
2018-02-13 09:13:35 +01:00
|
|
|
|
|
|
|
u32 to;
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-02-13 09:13:35 +01:00
|
|
|
{
|
|
|
|
to = pke[15] << 24
|
|
|
|
| pke[16] >> 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
to = pke[23] << 24
|
|
|
|
| pke[24] >> 8;
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
const u32 nonce_error_corrections = wpa_eapol->nonce_error_corrections;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_le == 1)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
|
|
|
{
|
|
|
|
u32 t = to;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
2018-02-13 09:13:35 +01:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
|
|
|
|
|
|
|
u32 keymic[4];
|
|
|
|
|
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
|
|
|
|
|
|
|
sha256_hmac_ctx_t ctx1;
|
|
|
|
|
|
|
|
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
|
|
|
|
|
|
|
sha256_hmac_update (&ctx1, pke, 102);
|
|
|
|
|
|
|
|
sha256_hmac_final (&ctx1);
|
|
|
|
|
|
|
|
u32 digest[4];
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
digest[0] = hc_swap32_S (ctx1.opad.h[0]);
|
|
|
|
digest[1] = hc_swap32_S (ctx1.opad.h[1]);
|
|
|
|
digest[2] = hc_swap32_S (ctx1.opad.h[2]);
|
|
|
|
digest[3] = hc_swap32_S (ctx1.opad.h[3]);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
// AES CMAC
|
|
|
|
|
|
|
|
u32 ks[44];
|
|
|
|
|
2019-03-31 19:41:28 +02:00
|
|
|
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
u32 m[4];
|
|
|
|
|
|
|
|
m[0] = 0;
|
|
|
|
m[1] = 0;
|
|
|
|
m[2] = 0;
|
|
|
|
m[3] = 0;
|
|
|
|
|
|
|
|
u32 iv[4];
|
|
|
|
|
|
|
|
iv[0] = 0;
|
|
|
|
iv[1] = 0;
|
|
|
|
iv[2] = 0;
|
|
|
|
iv[3] = 0;
|
|
|
|
|
|
|
|
int eapol_left;
|
|
|
|
int eapol_idx;
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
for (eapol_left = wpa_eapol->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
2018-07-25 16:46:06 +02:00
|
|
|
m[0] = wpa_eapol->eapol[eapol_idx + 0] ^ iv[0];
|
|
|
|
m[1] = wpa_eapol->eapol[eapol_idx + 1] ^ iv[1];
|
|
|
|
m[2] = wpa_eapol->eapol[eapol_idx + 2] ^ iv[2];
|
|
|
|
m[3] = wpa_eapol->eapol[eapol_idx + 3] ^ iv[3];
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
|
|
|
|
}
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
m[0] = wpa_eapol->eapol[eapol_idx + 0];
|
|
|
|
m[1] = wpa_eapol->eapol[eapol_idx + 1];
|
|
|
|
m[2] = wpa_eapol->eapol[eapol_idx + 2];
|
|
|
|
m[3] = wpa_eapol->eapol[eapol_idx + 3];
|
2018-06-15 17:00:41 +02:00
|
|
|
|
|
|
|
u32 k[4];
|
|
|
|
|
|
|
|
k[0] = 0;
|
|
|
|
k[1] = 0;
|
|
|
|
k[2] = 0;
|
|
|
|
k[3] = 0;
|
|
|
|
|
|
|
|
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
|
|
|
|
|
|
|
|
make_kn (k);
|
|
|
|
|
|
|
|
if (eapol_left < 16)
|
|
|
|
{
|
|
|
|
make_kn (k);
|
|
|
|
}
|
|
|
|
|
|
|
|
m[0] ^= k[0];
|
|
|
|
m[1] ^= k[1];
|
|
|
|
m[2] ^= k[2];
|
|
|
|
m[3] ^= k[3];
|
|
|
|
|
|
|
|
m[0] ^= iv[0];
|
|
|
|
m[1] ^= iv[1];
|
|
|
|
m[2] ^= iv[2];
|
|
|
|
m[3] ^= iv[3];
|
|
|
|
|
|
|
|
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
}
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->detected_be == 1)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 t = to;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
t -= nonce_error_corrections / 2;
|
|
|
|
t += nonce_error_correction;
|
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
t = hc_swap32_S (t);
|
2018-06-15 17:00:41 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if (wpa_eapol->nonce_compare < 0)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
|
|
|
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
|
|
|
|
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
|
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 w0[4];
|
|
|
|
u32 w1[4];
|
|
|
|
u32 w2[4];
|
|
|
|
u32 w3[4];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
w0[0] = out[0];
|
|
|
|
w0[1] = out[1];
|
|
|
|
w0[2] = out[2];
|
|
|
|
w0[3] = out[3];
|
|
|
|
w1[0] = out[4];
|
|
|
|
w1[1] = out[5];
|
|
|
|
w1[2] = out[6];
|
|
|
|
w1[3] = out[7];
|
|
|
|
w2[0] = 0;
|
|
|
|
w2[1] = 0;
|
|
|
|
w2[2] = 0;
|
|
|
|
w2[3] = 0;
|
|
|
|
w3[0] = 0;
|
|
|
|
w3[1] = 0;
|
|
|
|
w3[2] = 0;
|
|
|
|
w3[3] = 0;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 keymic[4];
|
2017-09-19 11:58:18 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
keymic[0] = 0;
|
|
|
|
keymic[1] = 0;
|
|
|
|
keymic[2] = 0;
|
|
|
|
keymic[3] = 0;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
sha256_hmac_ctx_t ctx1;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
sha256_hmac_update (&ctx1, pke, 102);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
sha256_hmac_final (&ctx1);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 digest[4];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2019-03-23 22:15:38 +01:00
|
|
|
digest[0] = hc_swap32_S (ctx1.opad.h[0]);
|
|
|
|
digest[1] = hc_swap32_S (ctx1.opad.h[1]);
|
|
|
|
digest[2] = hc_swap32_S (ctx1.opad.h[2]);
|
|
|
|
digest[3] = hc_swap32_S (ctx1.opad.h[3]);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
// AES CMAC
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 ks[44];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2019-03-31 19:41:28 +02:00
|
|
|
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3);
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 m[4];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
m[0] = 0;
|
|
|
|
m[1] = 0;
|
|
|
|
m[2] = 0;
|
|
|
|
m[3] = 0;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 iv[4];
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
iv[0] = 0;
|
|
|
|
iv[1] = 0;
|
|
|
|
iv[2] = 0;
|
|
|
|
iv[3] = 0;
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
int eapol_left;
|
|
|
|
int eapol_idx;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
for (eapol_left = wpa_eapol->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
|
2018-06-15 17:00:41 +02:00
|
|
|
{
|
2018-07-25 16:46:06 +02:00
|
|
|
m[0] = wpa_eapol->eapol[eapol_idx + 0] ^ iv[0];
|
|
|
|
m[1] = wpa_eapol->eapol[eapol_idx + 1] ^ iv[1];
|
|
|
|
m[2] = wpa_eapol->eapol[eapol_idx + 2] ^ iv[2];
|
|
|
|
m[3] = wpa_eapol->eapol[eapol_idx + 3] ^ iv[3];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
|
|
|
|
}
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
m[0] = wpa_eapol->eapol[eapol_idx + 0];
|
|
|
|
m[1] = wpa_eapol->eapol[eapol_idx + 1];
|
|
|
|
m[2] = wpa_eapol->eapol[eapol_idx + 2];
|
|
|
|
m[3] = wpa_eapol->eapol[eapol_idx + 3];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
u32 k[4];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
k[0] = 0;
|
|
|
|
k[1] = 0;
|
|
|
|
k[2] = 0;
|
|
|
|
k[3] = 0;
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2017-09-19 13:45:43 +02:00
|
|
|
make_kn (k);
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
if (eapol_left < 16)
|
|
|
|
{
|
|
|
|
make_kn (k);
|
|
|
|
}
|
|
|
|
|
|
|
|
m[0] ^= k[0];
|
|
|
|
m[1] ^= k[1];
|
|
|
|
m[2] ^= k[2];
|
|
|
|
m[3] ^= k[3];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
m[0] ^= iv[0];
|
|
|
|
m[1] ^= iv[1];
|
|
|
|
m[2] ^= iv[2];
|
|
|
|
m[3] ^= iv[3];
|
2017-09-19 10:22:03 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-06-15 17:00:41 +02:00
|
|
|
/**
|
|
|
|
* final compare
|
|
|
|
*/
|
2017-07-03 16:11:57 +02:00
|
|
|
|
2018-07-25 16:46:06 +02:00
|
|
|
if ((keymic[0] == wpa_eapol->keymic[0])
|
|
|
|
&& (keymic[1] == wpa_eapol->keymic[1])
|
|
|
|
&& (keymic[2] == wpa_eapol->keymic[2])
|
|
|
|
&& (keymic[3] == wpa_eapol->keymic[3]))
|
2017-07-03 16:11:57 +02:00
|
|
|
{
|
2018-06-15 17:00:41 +02:00
|
|
|
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
|
|
|
|
{
|
2019-03-15 21:48:49 +01:00
|
|
|
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0);
|
2018-06-15 17:00:41 +02:00
|
|
|
}
|
2017-07-03 16:11:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|