Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
config RTL8822BU
tristate "Realtek 8822B USB WiFi"
depends on USB
depends on USB && CFG80211
help
Help message of RTL8822BU

26 changes: 13 additions & 13 deletions core/crypto/aes-ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce,
WPA_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len);

wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM B_0", b, AES_BLOCK_SIZE);
aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */
aes_encrypt_rtl8822b(aes, b, x); /* X_1 = E(K, B_0) */

if (!aad_len)
return;
Expand All @@ -50,12 +50,12 @@ static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce,
os_memset(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);

xor_aes_block(aad_buf, x);
aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */
aes_encrypt_rtl8822b(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */

if (aad_len > AES_BLOCK_SIZE - 2) {
xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x);
/* X_3 = E(K, X_2 XOR B_2) */
aes_encrypt(aes, &aad_buf[AES_BLOCK_SIZE], x);
aes_encrypt_rtl8822b(aes, &aad_buf[AES_BLOCK_SIZE], x);
}
}

Expand All @@ -69,13 +69,13 @@ static void aes_ccm_auth(void *aes, const u8 *data, size_t len, u8 *x)
/* X_i+1 = E(K, X_i XOR B_i) */
xor_aes_block(x, data);
data += AES_BLOCK_SIZE;
aes_encrypt(aes, x, x);
aes_encrypt_rtl8822b(aes, x, x);
}
if (last) {
/* XOR zero-padded last block */
for (i = 0; i < last; i++)
x[i] ^= *data++;
aes_encrypt(aes, x, x);
aes_encrypt_rtl8822b(aes, x, x);
}
}

Expand All @@ -98,14 +98,14 @@ static void aes_ccm_encr(void *aes, size_t L, const u8 *in, size_t len, u8 *out,
for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
/* S_i = E(K, A_i) */
aes_encrypt(aes, a, out);
aes_encrypt_rtl8822b(aes, a, out);
xor_aes_block(out, in);
out += AES_BLOCK_SIZE;
in += AES_BLOCK_SIZE;
}
if (last) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
aes_encrypt(aes, a, out);
aes_encrypt_rtl8822b(aes, a, out);
/* XOR zero-padded last block */
for (i = 0; i < last; i++)
*out++ ^= *in++;
Expand All @@ -121,7 +121,7 @@ static void aes_ccm_encr_auth(void *aes, size_t M, u8 *x, u8 *a, u8 *auth)
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", x, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
aes_encrypt(aes, a, tmp);
aes_encrypt_rtl8822b(aes, a, tmp);
for (i = 0; i < M; i++)
auth[i] = x[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
Expand All @@ -136,7 +136,7 @@ static void aes_ccm_decr_auth(void *aes, size_t M, u8 *a, const u8 *auth, u8 *t)
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
aes_encrypt(aes, a, tmp);
aes_encrypt_rtl8822b(aes, a, tmp);
for (i = 0; i < M; i++)
t[i] = auth[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M);
Expand All @@ -155,7 +155,7 @@ int aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1;

aes = aes_encrypt_init(key, key_len);
aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL)
return -1;

Expand All @@ -167,7 +167,7 @@ int aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
aes_ccm_encr(aes, L, plain, plain_len, crypt, a);
aes_ccm_encr_auth(aes, M, x, a, auth);

aes_encrypt_deinit(aes);
aes_encrypt_rtl8822b_deinit(aes);

return 0;
}
Expand All @@ -186,7 +186,7 @@ int aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1;

aes = aes_encrypt_init(key, key_len);
aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL)
return -1;

Expand All @@ -200,7 +200,7 @@ int aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
aes_ccm_auth_start(aes, M, L, nonce, aad, aad_len, crypt_len, x);
aes_ccm_auth(aes, plain, crypt_len, x);

aes_encrypt_deinit(aes);
aes_encrypt_rtl8822b_deinit(aes);

if (os_memcmp_const(x, t, M) != 0) {
wpa_printf(_MSG_EXCESSIVE_, "CCM: Auth mismatch");
Expand Down
6 changes: 3 additions & 3 deletions core/crypto/aes-ctr.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
u8 *pos = data;
u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE];

ctx = aes_encrypt_init(key, key_len);
ctx = aes_encrypt_rtl8822b_init(key, key_len);
if (ctx == NULL)
return -1;
os_memcpy(counter, nonce, AES_BLOCK_SIZE);

while (left > 0) {
aes_encrypt(ctx, counter, buf);
aes_encrypt_rtl8822b(ctx, counter, buf);

len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE;
for (j = 0; j < len; j++)
Expand All @@ -50,7 +50,7 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
break;
}
}
aes_encrypt_deinit(ctx);
aes_encrypt_rtl8822b_deinit(ctx);
return 0;
}

Expand Down
12 changes: 6 additions & 6 deletions core/crypto/aes-gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void aes_gctr(void *aes, const u8 *icb, const u8 *x, size_t xlen, u8 *y)
os_memcpy(cb, icb, AES_BLOCK_SIZE);
/* Full blocks */
for (i = 0; i < n; i++) {
aes_encrypt(aes, cb, ypos);
aes_encrypt_rtl8822b(aes, cb, ypos);
xor_block(ypos, xpos);
xpos += AES_BLOCK_SIZE;
ypos += AES_BLOCK_SIZE;
Expand All @@ -164,7 +164,7 @@ static void aes_gctr(void *aes, const u8 *icb, const u8 *x, size_t xlen, u8 *y)
last = x + xlen - xpos;
if (last) {
/* Last, partial block */
aes_encrypt(aes, cb, tmp);
aes_encrypt_rtl8822b(aes, cb, tmp);
for (i = 0; i < last; i++)
*ypos++ = *xpos++ ^ tmp[i];
}
Expand All @@ -175,13 +175,13 @@ static void * aes_gcm_init_hash_subkey(const u8 *key, size_t key_len, u8 *H)
{
void *aes;

aes = aes_encrypt_init(key, key_len);
aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL)
return NULL;

/* Generate hash subkey H = AES_K(0^128) */
os_memset(H, 0, AES_BLOCK_SIZE);
aes_encrypt(aes, H, H);
aes_encrypt_rtl8822b(aes, H, H);
wpa_hexdump_key(_MSG_EXCESSIVE_, "Hash subkey H for GHASH",
H, AES_BLOCK_SIZE);
return aes;
Expand Down Expand Up @@ -275,7 +275,7 @@ int aes_gcm_ae(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,

/* Return (C, T) */

aes_encrypt_deinit(aes);
aes_encrypt_rtl8822b_deinit(aes);

return 0;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ int aes_gcm_ad(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
/* T' = MSB_t(GCTR_K(J_0, S)) */
aes_gctr(aes, J0, S, sizeof(S), T);

aes_encrypt_deinit(aes);
aes_encrypt_rtl8822b_deinit(aes);

if (os_memcmp_const(tag, T, 16) != 0) {
wpa_printf(_MSG_EXCESSIVE_, "GCM: Tag mismatch");
Expand Down
6 changes: 3 additions & 3 deletions core/crypto/aes-internal-enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
}


void * aes_encrypt_init(const u8 *key, size_t len)
void * aes_encrypt_rtl8822b_init(const u8 *key, size_t len)
{
u32 *rk;
int res;
Expand All @@ -114,15 +114,15 @@ void * aes_encrypt_init(const u8 *key, size_t len)
}


int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
int aes_encrypt_rtl8822b(void *ctx, const u8 *plain, u8 *crypt)
{
u32 *rk = ctx;
rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt);
return 0;
}


void aes_encrypt_deinit(void *ctx)
void aes_encrypt_rtl8822b_deinit(void *ctx)
{
os_memset(ctx, 0, AES_PRIV_SIZE);
rtw_mfree(ctx, AES_PRIV_SIZE);
Expand Down
10 changes: 5 additions & 5 deletions core/crypto/aes-omac1.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
if (TEST_FAIL())
return -1;

ctx = aes_encrypt_init(key, key_len);
ctx = aes_encrypt_rtl8822b_init(key, key_len);
if (ctx == NULL)
return -1;
os_memset(cbc, 0, AES_BLOCK_SIZE);
Expand Down Expand Up @@ -81,12 +81,12 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
}
}
if (left > AES_BLOCK_SIZE)
aes_encrypt(ctx, cbc, cbc);
aes_encrypt_rtl8822b(ctx, cbc, cbc);
left -= AES_BLOCK_SIZE;
}

os_memset(pad, 0, AES_BLOCK_SIZE);
aes_encrypt(ctx, pad, pad);
aes_encrypt_rtl8822b(ctx, pad, pad);
gf_mulx(pad);

if (left || total_len == 0) {
Expand All @@ -110,8 +110,8 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,

for (i = 0; i < AES_BLOCK_SIZE; i++)
pad[i] ^= cbc[i];
aes_encrypt(ctx, pad, mac);
aes_encrypt_deinit(ctx);
aes_encrypt_rtl8822b(ctx, pad, mac);
aes_encrypt_rtl8822b_deinit(ctx);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions core/crypto/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#define AES_BLOCK_SIZE 16

void * aes_encrypt_init(const u8 *key, size_t len);
int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
void aes_encrypt_deinit(void *ctx);
void * aes_encrypt_rtl8822b_init(const u8 *key, size_t len);
int aes_encrypt_rtl8822b(void *ctx, const u8 *plain, u8 *crypt);
void aes_encrypt_rtl8822b_deinit(void *ctx);
void * aes_decrypt_init(const u8 *key, size_t len);
int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
void aes_decrypt_deinit(void *ctx);
Expand Down
4 changes: 2 additions & 2 deletions core/rtw_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,


#if NEW_CRYPTO
u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe)
u32 rtw_aes_encrypt_rtl8822b(_adapter *padapter, u8 *pxmitframe)
{
/* Intermediate Buffers */
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
Expand Down Expand Up @@ -1666,7 +1666,7 @@ u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe)
return res;
}
#else
u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe)
u32 rtw_aes_encrypt_rtl8822b(_adapter *padapter, u8 *pxmitframe)
{
/* exclude ICV */

Expand Down
2 changes: 1 addition & 1 deletion core/rtw_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@ static s32 xmitframe_swencrypt(_adapter *padapter, struct xmit_frame *pxmitframe
break;
case _AES_:
case _CCMP_256_:
rtw_aes_encrypt(padapter, (u8 *)pxmitframe);
rtw_aes_encrypt_rtl8822b(padapter, (u8 *)pxmitframe);
break;
case _GCMP_:
case _GCMP_256_:
Expand Down
2 changes: 1 addition & 1 deletion include/rtw_security.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void rtw_seccalctkipmic(
u8 *Miccode,
u8 priority);

u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe);
u32 rtw_aes_encrypt_rtl8822b(_adapter *padapter, u8 *pxmitframe);
u32 rtw_tkip_encrypt(_adapter *padapter, u8 *pxmitframe);
void rtw_wep_encrypt(_adapter *padapter, u8 *pxmitframe);

Expand Down