From 5fc6320f59b1c43d92ed9d3744e4adbe752a1994 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megous@megous.com>
Date: Wed, 25 Nov 2020 15:04:54 +0100
Subject: [PATCH 221/467] 8723cs: aes_encrypt -> aes_encrypt_128 to avoid
 symbol name conflict

The kernel already has aes_encrypt.

Signed-off-by: Ondrej Jirman <megous@megous.com>
---
 .../staging/rtl8723cs/core/crypto/aes-ccm.c    | 18 +++++++++---------
 .../staging/rtl8723cs/core/crypto/aes-ctr.c    |  2 +-
 .../staging/rtl8723cs/core/crypto/aes-gcm.c    |  6 +++---
 .../rtl8723cs/core/crypto/aes-internal-enc.c   |  2 +-
 .../staging/rtl8723cs/core/crypto/aes-omac1.c  |  6 +++---
 drivers/staging/rtl8723cs/core/crypto/aes.h    |  2 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723cs/core/crypto/aes-ccm.c b/drivers/staging/rtl8723cs/core/crypto/aes-ccm.c
index dceec778a..a2309b5f1 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes-ccm.c
+++ b/drivers/staging/rtl8723cs/core/crypto/aes-ccm.c
@@ -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_128(aes, b, x); /* X_1 = E(K, B_0) */
 
 	if (!aad_len)
 		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);
 
 	xor_aes_block(aad_buf, x);
-	aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */
+	aes_encrypt_128(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_128(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) */
 		xor_aes_block(x, data);
 		data += AES_BLOCK_SIZE;
-		aes_encrypt(aes, x, x);
+		aes_encrypt_128(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_128(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++) {
 		WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
 		/* S_i = E(K, A_i) */
-		aes_encrypt(aes, a, out);
+		aes_encrypt_128(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_128(aes, a, out);
 		/* XOR zero-padded last block */
 		for (i = 0; i < last; i++)
 			*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);
 	/* 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_128(aes, a, tmp);
 	for (i = 0; i < M; i++)
 		auth[i] = x[i] ^ tmp[i];
 	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);
 	/* 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_128(aes, a, tmp);
 	for (i = 0; i < M; i++)
 		t[i] = auth[i] ^ tmp[i];
 	wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M);
diff --git a/drivers/staging/rtl8723cs/core/crypto/aes-ctr.c b/drivers/staging/rtl8723cs/core/crypto/aes-ctr.c
index 6c06851dd..9533709b7 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes-ctr.c
+++ b/drivers/staging/rtl8723cs/core/crypto/aes-ctr.c
@@ -36,7 +36,7 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
 	os_memcpy(counter, nonce, AES_BLOCK_SIZE);
 
 	while (left > 0) {
-		aes_encrypt(ctx, counter, buf);
+		aes_encrypt_128(ctx, counter, buf);
 
 		len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE;
 		for (j = 0; j < len; j++)
diff --git a/drivers/staging/rtl8723cs/core/crypto/aes-gcm.c b/drivers/staging/rtl8723cs/core/crypto/aes-gcm.c
index 47088102b..76061f53d 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes-gcm.c
+++ b/drivers/staging/rtl8723cs/core/crypto/aes-gcm.c
@@ -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_128(aes, cb, ypos);
 		xor_block(ypos, xpos);
 		xpos += 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;
 	if (last) {
 		/* Last, partial block */
-		aes_encrypt(aes, cb, tmp);
+		aes_encrypt_128(aes, cb, tmp);
 		for (i = 0; i < last; i++)
 			*ypos++ = *xpos++ ^ tmp[i];
 	}
@@ -181,7 +181,7 @@ static void * aes_gcm_init_hash_subkey(const u8 *key, size_t key_len, u8 *H)
 
 	/* Generate hash subkey H = AES_K(0^128) */
 	os_memset(H, 0, AES_BLOCK_SIZE);
-	aes_encrypt(aes, H, H);
+	aes_encrypt_128(aes, H, H);
 	wpa_hexdump_key(_MSG_EXCESSIVE_, "Hash subkey H for GHASH",
 			H, AES_BLOCK_SIZE);
 	return aes;
diff --git a/drivers/staging/rtl8723cs/core/crypto/aes-internal-enc.c b/drivers/staging/rtl8723cs/core/crypto/aes-internal-enc.c
index 69e256be9..6728363b6 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes-internal-enc.c
+++ b/drivers/staging/rtl8723cs/core/crypto/aes-internal-enc.c
@@ -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_128(void *ctx, const u8 *plain, u8 *crypt)
 {
 	u32 *rk = ctx;
 	rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt);
diff --git a/drivers/staging/rtl8723cs/core/crypto/aes-omac1.c b/drivers/staging/rtl8723cs/core/crypto/aes-omac1.c
index 30b52629f..2d20aed87 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes-omac1.c
+++ b/drivers/staging/rtl8723cs/core/crypto/aes-omac1.c
@@ -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_128(ctx, cbc, cbc);
 		left -= AES_BLOCK_SIZE;
 	}
 
 	os_memset(pad, 0, AES_BLOCK_SIZE);
-	aes_encrypt(ctx, pad, pad);
+	aes_encrypt_128(ctx, pad, pad);
 	gf_mulx(pad);
 
 	if (left || total_len == 0) {
@@ -110,7 +110,7 @@ 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_128(ctx, pad, mac);
 	aes_encrypt_deinit(ctx);
 	return 0;
 }
diff --git a/drivers/staging/rtl8723cs/core/crypto/aes.h b/drivers/staging/rtl8723cs/core/crypto/aes.h
index 8ab3de2ee..1aafe3b4e 100644
--- a/drivers/staging/rtl8723cs/core/crypto/aes.h
+++ b/drivers/staging/rtl8723cs/core/crypto/aes.h
@@ -12,7 +12,7 @@
 #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);
+int aes_encrypt_128(void *ctx, const u8 *plain, u8 *crypt);
 void aes_encrypt_deinit(void *ctx);
 void * aes_decrypt_init(const u8 *key, size_t len);
 int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
-- 
2.34.0

