bb4c6fd04ba89dd2e731bee360936c10d29694db
[openwrt/staging/wigyori.git] / package / libs / wolfssl / patches / 020-build-fix-for-aesccm-devcrypto-cbc-wpas-and-afalg.patch
1 From 9fd38dc340c38dee6e5935da174f90270a63bfbf Mon Sep 17 00:00:00 2001
2 From: Jacob Barthelmeh <jacob@wolfssl.com>
3 Date: Fri, 30 Aug 2019 16:15:48 -0600
4 Subject: [PATCH] build fix for aesccm + devcrypto=cbc + wpas and afalg
5
6
7 diff --git a/configure.ac b/configure.ac
8 index 61fad39dd..30731eb52 100644
9 --- a/configure.ac
10 +++ b/configure.ac
11 @@ -1045,6 +1045,10 @@ AC_ARG_ENABLE([afalg],
12
13 if test "$ENABLED_AFALG" = "yes"
14 then
15 + if test "$ENABLED_AESCCM" = "yes"
16 + then
17 + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_DIRECT"
18 + fi
19 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AFALG"
20 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AFALG_HASH"
21 fi
22 diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
23 index fef2f9c74..d294f6236 100644
24 --- a/wolfcrypt/src/aes.c
25 +++ b/wolfcrypt/src/aes.c
26 @@ -759,7 +759,9 @@
27 }
28 #endif /* HAVE_AES_DECRYPT */
29
30 -#elif defined(WOLFSSL_IMX6_CAAM) && !defined(NO_IMX6_CAAM_AES)
31 +#elif (defined(WOLFSSL_IMX6_CAAM) && !defined(NO_IMX6_CAAM_AES)) || \
32 + ((defined(WOLFSSL_AFALG) || defined(WOLFSSL_DEVCRYPTO_AES)) && \
33 + defined(HAVE_AESCCM))
34 static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
35 {
36 wc_AesEncryptDirect(aes, outBlock, inBlock);
37 @@ -768,16 +770,6 @@
38
39 #elif defined(WOLFSSL_AFALG)
40 #elif defined(WOLFSSL_DEVCRYPTO_AES)
41 - /* if all AES is enabled with devcrypto then tables are not needed */
42 -
43 - #if defined(HAVE_AESCCM)
44 - static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
45 - {
46 - wc_AesEncryptDirect(aes, outBlock, inBlock);
47 - return 0;
48 - }
49 - #endif
50 -
51 #else
52
53 /* using wolfCrypt software implementation */
54 @@ -1593,8 +1585,8 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
55 #endif /* HAVE_AES_CBC || WOLFSSL_AES_DIRECT || HAVE_AESGCM */
56
57 #if defined(HAVE_AES_DECRYPT)
58 -#if (defined(HAVE_AES_CBC) || defined(WOLFSSL_AES_DIRECT)) && \
59 - !defined(WOLFSSL_DEVCRYPTO_CBC)
60 +#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC)) || \
61 + defined(WOLFSSL_AES_DIRECT)
62
63 /* load 4 Td Tables into cache by cache line stride */
64 static WC_INLINE word32 PreFetchTd(void)