ramips, mt7620: reproducible elecom-header uid/gid
[openwrt/staging/wigyori.git] / package / libs / wolfssl / patches / 010-build-with-devcrypto-and-aesccm.patch
1 From e8e1d35744c68b165e172a687e870a549438bdf0 Mon Sep 17 00:00:00 2001
2 From: Jacob Barthelmeh <jacob@wolfssl.com>
3 Date: Tue, 13 Aug 2019 14:12:45 -0600
4 Subject: [PATCH] build with devcrypto and aesccm
5
6
7 diff --git a/configure.ac b/configure.ac
8 index f943cc6ef..cf03e7f52 100644
9 --- a/configure.ac
10 +++ b/configure.ac
11 @@ -1096,6 +1096,10 @@ then
12 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO"
13 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO_CBC"
14 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO_AES"
15 + if test "$ENABLED_AESCCM" = "yes"
16 + then
17 + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_DIRECT"
18 + fi
19 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO_HASH"
20 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_HASH_RAW"
21 ENABLED_DEVCRYPTO=yes
22 @@ -1106,6 +1110,10 @@ then
23 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO"
24 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO_AES"
25 AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEVCRYPTO_CBC"
26 + if test "$ENABLED_AESCCM" = "yes"
27 + then
28 + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_DIRECT"
29 + fi
30 ENABLED_DEVCRYPTO=yes
31 fi
32 if test "$ENABLED_DEVCRYPTO" = "cbc"
33 diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
34 index beeae72a6..b583d03e9 100644
35 --- a/wolfcrypt/src/aes.c
36 +++ b/wolfcrypt/src/aes.c
37 @@ -760,6 +760,14 @@
38 #elif defined(WOLFSSL_DEVCRYPTO_AES)
39 /* if all AES is enabled with devcrypto then tables are not needed */
40
41 + #if defined(HAVE_AESCCM)
42 + static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
43 + {
44 + wc_AesEncryptDirect(aes, outBlock, inBlock);
45 + return 0;
46 + }
47 + #endif
48 +
49 #else
50
51 /* using wolfCrypt software implementation */
52 @@ -1314,7 +1322,8 @@ static const word32 Td[4][256] = {
53 };
54
55
56 -#if defined(HAVE_AES_CBC) || defined(WOLFSSL_AES_DIRECT)
57 +#if (defined(HAVE_AES_CBC) && !defined(WOLFSSL_DEVCRYPTO_CBC)) \
58 + || defined(WOLFSSL_AES_DIRECT)
59 static const byte Td4[256] =
60 {
61 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
62 diff --git a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c
63 index 5c63421e2..d5061f364 100644
64 --- a/wolfcrypt/src/port/devcrypto/devcrypto_aes.c
65 +++ b/wolfcrypt/src/port/devcrypto/devcrypto_aes.c
66 @@ -168,7 +168,7 @@ static int wc_DevCrypto_AesDirect(Aes* aes, byte* out, const byte* in,
67 #endif
68
69
70 -#if defined(WOLFSSL_AES_DIRECT)
71 +#if defined(WOLFSSL_AES_DIRECT) || defined(HAVE_AESCCM)
72 void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
73 {
74 wc_DevCrypto_AesDirect(aes, out, in, AES_BLOCK_SIZE, COP_ENCRYPT);