fix: multiple definition of aes_encrypt

This commit is contained in:
none 2025-01-07 17:52:39 +00:00
parent 139e4fc2ee
commit ad1863350b
9 changed files with 37 additions and 37 deletions

View File

@ -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_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len);
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM B_0", b, AES_BLOCK_SIZE); 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) if (!aad_len)
return; return;
@ -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); os_memset(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);
xor_aes_block(aad_buf, x); 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) { if (aad_len > AES_BLOCK_SIZE - 2) {
xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x); xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x);
/* X_3 = E(K, X_2 XOR B_2) */ /* 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);
} }
} }
@ -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) */ /* X_i+1 = E(K, X_i XOR B_i) */
xor_aes_block(x, data); xor_aes_block(x, data);
data += AES_BLOCK_SIZE; data += AES_BLOCK_SIZE;
aes_encrypt(aes, x, x); aes_encrypt_rtl8822b(aes, x, x);
} }
if (last) { if (last) {
/* XOR zero-padded last block */ /* XOR zero-padded last block */
for (i = 0; i < last; i++) for (i = 0; i < last; i++)
x[i] ^= *data++; x[i] ^= *data++;
aes_encrypt(aes, x, x); aes_encrypt_rtl8822b(aes, x, x);
} }
} }
@ -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++) { for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i); WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
/* S_i = E(K, A_i) */ /* S_i = E(K, A_i) */
aes_encrypt(aes, a, out); aes_encrypt_rtl8822b(aes, a, out);
xor_aes_block(out, in); xor_aes_block(out, in);
out += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE;
in += AES_BLOCK_SIZE; in += AES_BLOCK_SIZE;
} }
if (last) { if (last) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i); 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 */ /* XOR zero-padded last block */
for (i = 0; i < last; i++) for (i = 0; i < last; i++)
*out++ ^= *in++; *out++ ^= *in++;
@ -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); wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", x, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */ /* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 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++) for (i = 0; i < M; i++)
auth[i] = x[i] ^ tmp[i]; auth[i] = x[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M); wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
@ -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); wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */ /* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 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++) for (i = 0; i < M; i++)
t[i] = auth[i] ^ tmp[i]; t[i] = auth[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M); wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M);
@ -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) if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1; return -1;
aes = aes_encrypt_init(key, key_len); aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL) if (aes == NULL)
return -1; return -1;
@ -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(aes, L, plain, plain_len, crypt, a);
aes_ccm_encr_auth(aes, M, x, a, auth); aes_ccm_encr_auth(aes, M, x, a, auth);
aes_encrypt_deinit(aes); aes_encrypt_rtl8822b_deinit(aes);
return 0; return 0;
} }
@ -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) if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1; return -1;
aes = aes_encrypt_init(key, key_len); aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL) if (aes == NULL)
return -1; return -1;
@ -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_start(aes, M, L, nonce, aad, aad_len, crypt_len, x);
aes_ccm_auth(aes, plain, 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) { if (os_memcmp_const(x, t, M) != 0) {
wpa_printf(_MSG_EXCESSIVE_, "CCM: Auth mismatch"); wpa_printf(_MSG_EXCESSIVE_, "CCM: Auth mismatch");

View File

@ -30,13 +30,13 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
u8 *pos = data; u8 *pos = data;
u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE]; 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) if (ctx == NULL)
return -1; return -1;
os_memcpy(counter, nonce, AES_BLOCK_SIZE); os_memcpy(counter, nonce, AES_BLOCK_SIZE);
while (left > 0) { while (left > 0) {
aes_encrypt(ctx, counter, buf); aes_encrypt_rtl8822b(ctx, counter, buf);
len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE; len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE;
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
@ -50,7 +50,7 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
break; break;
} }
} }
aes_encrypt_deinit(ctx); aes_encrypt_rtl8822b_deinit(ctx);
return 0; return 0;
} }

View File

@ -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); os_memcpy(cb, icb, AES_BLOCK_SIZE);
/* Full blocks */ /* Full blocks */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
aes_encrypt(aes, cb, ypos); aes_encrypt_rtl8822b(aes, cb, ypos);
xor_block(ypos, xpos); xor_block(ypos, xpos);
xpos += AES_BLOCK_SIZE; xpos += AES_BLOCK_SIZE;
ypos += AES_BLOCK_SIZE; ypos += AES_BLOCK_SIZE;
@ -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; last = x + xlen - xpos;
if (last) { if (last) {
/* Last, partial block */ /* Last, partial block */
aes_encrypt(aes, cb, tmp); aes_encrypt_rtl8822b(aes, cb, tmp);
for (i = 0; i < last; i++) for (i = 0; i < last; i++)
*ypos++ = *xpos++ ^ tmp[i]; *ypos++ = *xpos++ ^ tmp[i];
} }
@ -175,13 +175,13 @@ static void * aes_gcm_init_hash_subkey(const u8 *key, size_t key_len, u8 *H)
{ {
void *aes; void *aes;
aes = aes_encrypt_init(key, key_len); aes = aes_encrypt_rtl8822b_init(key, key_len);
if (aes == NULL) if (aes == NULL)
return NULL; return NULL;
/* Generate hash subkey H = AES_K(0^128) */ /* Generate hash subkey H = AES_K(0^128) */
os_memset(H, 0, AES_BLOCK_SIZE); 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", wpa_hexdump_key(_MSG_EXCESSIVE_, "Hash subkey H for GHASH",
H, AES_BLOCK_SIZE); H, AES_BLOCK_SIZE);
return aes; return aes;
@ -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) */ /* Return (C, T) */
aes_encrypt_deinit(aes); aes_encrypt_rtl8822b_deinit(aes);
return 0; return 0;
} }
@ -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)) */ /* T' = MSB_t(GCTR_K(J_0, S)) */
aes_gctr(aes, J0, S, sizeof(S), T); 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) { if (os_memcmp_const(tag, T, 16) != 0) {
wpa_printf(_MSG_EXCESSIVE_, "GCM: Tag mismatch"); wpa_printf(_MSG_EXCESSIVE_, "GCM: Tag mismatch");

View File

@ -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; u32 *rk;
int res; int res;
@ -114,7 +114,7 @@ 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; u32 *rk = ctx;
rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt); rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt);
@ -122,7 +122,7 @@ int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
} }
void aes_encrypt_deinit(void *ctx) void aes_encrypt_rtl8822b_deinit(void *ctx)
{ {
os_memset(ctx, 0, AES_PRIV_SIZE); os_memset(ctx, 0, AES_PRIV_SIZE);
rtw_mfree(ctx, AES_PRIV_SIZE); rtw_mfree(ctx, AES_PRIV_SIZE);

View File

@ -50,7 +50,7 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
if (TEST_FAIL()) if (TEST_FAIL())
return -1; return -1;
ctx = aes_encrypt_init(key, key_len); ctx = aes_encrypt_rtl8822b_init(key, key_len);
if (ctx == NULL) if (ctx == NULL)
return -1; return -1;
os_memset(cbc, 0, AES_BLOCK_SIZE); os_memset(cbc, 0, AES_BLOCK_SIZE);
@ -81,12 +81,12 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
} }
} }
if (left > AES_BLOCK_SIZE) if (left > AES_BLOCK_SIZE)
aes_encrypt(ctx, cbc, cbc); aes_encrypt_rtl8822b(ctx, cbc, cbc);
left -= AES_BLOCK_SIZE; left -= AES_BLOCK_SIZE;
} }
os_memset(pad, 0, AES_BLOCK_SIZE); os_memset(pad, 0, AES_BLOCK_SIZE);
aes_encrypt(ctx, pad, pad); aes_encrypt_rtl8822b(ctx, pad, pad);
gf_mulx(pad); gf_mulx(pad);
if (left || total_len == 0) { if (left || total_len == 0) {
@ -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++) for (i = 0; i < AES_BLOCK_SIZE; i++)
pad[i] ^= cbc[i]; pad[i] ^= cbc[i];
aes_encrypt(ctx, pad, mac); aes_encrypt_rtl8822b(ctx, pad, mac);
aes_encrypt_deinit(ctx); aes_encrypt_rtl8822b_deinit(ctx);
return 0; return 0;
} }

View File

@ -11,9 +11,9 @@
#define AES_BLOCK_SIZE 16 #define AES_BLOCK_SIZE 16
void * aes_encrypt_init(const u8 *key, size_t len); void * aes_encrypt_rtl8822b_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);
void aes_encrypt_deinit(void *ctx); void aes_encrypt_rtl8822b_deinit(void *ctx);
void * aes_decrypt_init(const u8 *key, size_t len); void * aes_decrypt_init(const u8 *key, size_t len);
int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
void aes_decrypt_deinit(void *ctx); void aes_decrypt_deinit(void *ctx);

View File

@ -1587,7 +1587,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,
#if NEW_CRYPTO #if NEW_CRYPTO
u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe) u32 rtw_aes_encrypt_rtl8822b(_adapter *padapter, u8 *pxmitframe)
{ {
/* Intermediate Buffers */ /* Intermediate Buffers */
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
@ -1666,7 +1666,7 @@ u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe)
return res; return res;
} }
#else #else
u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe) u32 rtw_aes_encrypt_rtl8822b(_adapter *padapter, u8 *pxmitframe)
{ {
/* exclude ICV */ /* exclude ICV */

View File

@ -2078,7 +2078,7 @@ static s32 xmitframe_swencrypt(_adapter *padapter, struct xmit_frame *pxmitframe
break; break;
case _AES_: case _AES_:
case _CCMP_256_: case _CCMP_256_:
rtw_aes_encrypt(padapter, (u8 *)pxmitframe); rtw_aes_encrypt_rtl8822b(padapter, (u8 *)pxmitframe);
break; break;
case _GCMP_: case _GCMP_:
case _GCMP_256_: case _GCMP_256_:

View File

@ -366,7 +366,7 @@ void rtw_seccalctkipmic(
u8 *Miccode, u8 *Miccode,
u8 priority); 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); u32 rtw_tkip_encrypt(_adapter *padapter, u8 *pxmitframe);
void rtw_wep_encrypt(_adapter *padapter, u8 *pxmitframe); void rtw_wep_encrypt(_adapter *padapter, u8 *pxmitframe);