From a1eb4b49fdd76cd0691c726c13ed0f75c8cccb57 Mon Sep 17 00:00:00 2001
From: Li Jingyi <lijingyi@espressif.com>
Date: Tue, 21 Jul 2020 14:44:45 +0800
Subject: [PATCH] feat(wpa_supplicant): remove CONFIG_ESP_AES to sync aes
 internal files with idf but will increase 3k flash size

---
 .../src/crypto/aes-internal-dec.c             | 46 +------------------
 .../src/crypto/aes-internal-enc.c             | 46 +------------------
 .../wpa_supplicant/src/crypto/aes-internal.c  | 10 +---
 3 files changed, 6 insertions(+), 96 deletions(-)

diff --git a/components/wpa_supplicant/src/crypto/aes-internal-dec.c b/components/wpa_supplicant/src/crypto/aes-internal-dec.c
index e154e327..8c91b5c0 100644
--- a/components/wpa_supplicant/src/crypto/aes-internal-dec.c
+++ b/components/wpa_supplicant/src/crypto/aes-internal-dec.c
@@ -21,15 +21,11 @@
  * See README and COPYING for more details.
  */
 
-#include "sdkconfig.h"
-
-#ifndef CONFIG_ESP_AES
-
 #include "utils/includes.h"
 
 #include "utils/common.h"
-#include "crypto/crypto.h"
-#include "crypto/aes_i.h"
+#include "crypto.h"
+#include "aes_i.h"
 
 
 
@@ -174,41 +170,3 @@ void  aes_decrypt_deinit(void *ctx)
 	os_memset(ctx, 0, AES_PRIV_SIZE);
 	os_free(ctx);
 }
-
-#else /* CONFIG_ESP_AES */
-
-#include <stdint.h>
-#include "esp_aes.h"
-#include "esp_heap_caps.h"
-
-void *aes_decrypt_init(const uint8_t *key, size_t len)
-{
-    int ret;
-    esp_aes_t *ctx;
-
-    ctx = heap_caps_malloc(sizeof(esp_aes_t), MALLOC_CAP_8BIT);
-    if (!ctx)
-        return NULL;
-
-    ret = esp_aes_set_decrypt_key(ctx, key, len * 8);
-    if (ret)
-        goto fail;
-
-    return ctx;
-
-fail:
-    heap_caps_free(ctx);
-    return NULL;
-}
-
-void aes_decrypt(void *ctx, const uint8_t *crypt, uint8_t *plain)
-{
-    esp_aes_decrypt_ecb(ctx, crypt, plain);
-}
-
-void aes_decrypt_deinit(void *ctx)
-{
-    heap_caps_free(ctx);
-}
-
-#endif /* CONFIG_ESP_AES */
diff --git a/components/wpa_supplicant/src/crypto/aes-internal-enc.c b/components/wpa_supplicant/src/crypto/aes-internal-enc.c
index a3f8de7b..56084e44 100644
--- a/components/wpa_supplicant/src/crypto/aes-internal-enc.c
+++ b/components/wpa_supplicant/src/crypto/aes-internal-enc.c
@@ -21,14 +21,10 @@
  * See README and COPYING for more details.
  */
 
-#include "sdkconfig.h"
-
-#ifndef CONFIG_ESP_AES
-
 #include "utils/includes.h"
 #include "utils/common.h"
-#include "crypto/crypto.h"
-#include "crypto/aes_i.h"
+#include "crypto.h"
+#include "aes_i.h"
 
 #include "os.h"
 
@@ -136,41 +132,3 @@ void  aes_encrypt_deinit(void *ctx)
 	os_memset(ctx, 0, AES_PRIV_SIZE);
 	os_free(ctx);
 }
-
-#else /* CONFIG_ESP_AES */
-
-#include <stdint.h>
-#include "esp_aes.h"
-#include "esp_heap_caps.h"
-
-void *aes_encrypt_init(const uint8_t *key, size_t len)
-{
-    int ret;
-    esp_aes_t *ctx;
-
-    ctx = heap_caps_malloc(sizeof(esp_aes_t), MALLOC_CAP_8BIT);
-    if (!ctx)
-        return NULL;
-
-    ret = esp_aes_set_encrypt_key(ctx, key, len * 8);
-    if (ret)
-        goto fail;
-
-    return ctx;
-
-fail:
-    heap_caps_free(ctx);
-    return NULL;
-}
-
-void aes_encrypt(void *ctx, const uint8_t *crypt, uint8_t *plain)
-{
-    esp_aes_encrypt_ecb(ctx, crypt, plain);
-}
-
-void aes_encrypt_deinit(void *ctx)
-{
-    heap_caps_free(ctx);
-}
-
-#endif /* CONFIG_ESP_AES */
diff --git a/components/wpa_supplicant/src/crypto/aes-internal.c b/components/wpa_supplicant/src/crypto/aes-internal.c
index 0d666e3c..93592f1d 100644
--- a/components/wpa_supplicant/src/crypto/aes-internal.c
+++ b/components/wpa_supplicant/src/crypto/aes-internal.c
@@ -24,8 +24,8 @@
 #include "utils/includes.h"
 
 #include "utils/common.h"
-#include "crypto/crypto.h"
-#include "crypto/aes_i.h"
+#include "crypto.h"
+#include "aes_i.h"
 
 /*
  * rijndael-alg-fst.c
@@ -53,10 +53,6 @@
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "sdkconfig.h"
-
-#ifndef CONFIG_ESP_AES
-
 #define AES_SMALL_TABLES
 
 /*
@@ -855,5 +851,3 @@ int rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits)
 
 	return -1;
 }
-
-#endif /* CONFIG_ESP_AES */