aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2017-02-24 11:57:27 +0100
committerFelix Fietkau <nbd@nbd.name>2017-02-24 12:22:29 +0100
commit703515f889124248480f39d65f8704548cbf1c09 (patch)
treecd06f11ec2cc4e6ddb75c8982ecaab9882d3a9ed /package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
parentd27dd6298b0f9a66199758b32ce19c0932ef2ee0 (diff)
downloadupstream-703515f889124248480f39d65f8704548cbf1c09.tar.gz
upstream-703515f889124248480f39d65f8704548cbf1c09.tar.bz2
upstream-703515f889124248480f39d65f8704548cbf1c09.zip
mac80211: sync with master branch as of 9edff13abd97
Includes the following changes: 9edff13abd mac80211: disable potentially harmful PS software retry for A-MPDU sessions 75216a76b0 mac80211: backport upstream fix for CSA in IBSS mode 368cc8ef47 mac80211: update brcmfmac backporting brcmf_err cleanups 66a63d25c4 mac80211: fix build on linux 3.18 9eacb9d7fc rt2x00: mt7620: lots of improvements fd94fa61a7 mac80211: brcmfmac: update Raspberry Pi patches for linux 4.9 649e766a64 mac80211: update to wireless-testing 2017-01-31 47540afa5d ath9k: add a warning to the tx99 config option b367eef21d mac80211: rt2x00: add support for external LNA on MT7620 9200e168f2 mac80211: move (& update) upstream accepted brcmfmac patches Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch')
-rw-r--r--package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch288
1 files changed, 184 insertions, 104 deletions
diff --git a/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch b/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
index fbe22e51b7..95fea441a4 100644
--- a/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
+++ b/package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
@@ -18,12 +18,12 @@
- aes_gcm.o \
aes_cmac.o \
- aes_gmac.o \
+ fils_aead.o \
cfg.o \
ethtool.o \
- rx.o \
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
-@@ -13,89 +13,132 @@
+@@ -13,103 +13,132 @@
#include <linux/types.h>
#include <linux/err.h>
#include <crypto/aead.h>
@@ -33,17 +33,39 @@
#include "key.h"
#include "aes_ccm.h"
--void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
-- u8 *data, size_t data_len, u8 *mic,
-- size_t mic_len)
+-int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+- u8 *data, size_t data_len, u8 *mic,
+- size_t mic_len)
+static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, u8 *s_0,
+ u8 *a, u8 *b)
{
- struct scatterlist sg[3];
+- struct aead_request *aead_req;
+- int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
+- u8 *__aad;
+-
+- aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
+- if (!aead_req)
+- return -ENOMEM;
+-
+- __aad = (u8 *)aead_req + reqsize;
+- memcpy(__aad, aad, CCM_AAD_LEN);
+-
+- sg_init_table(sg, 3);
+- sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
+- sg_set_buf(&sg[1], data, data_len);
+- sg_set_buf(&sg[2], mic, mic_len);
+-
+- aead_request_set_tfm(aead_req, tfm);
+- aead_request_set_crypt(aead_req, sg, sg, data_len, b_0);
+- aead_request_set_ad(aead_req, sg[0].length);
+ int i;
-+
+
+- crypto_aead_encrypt(aead_req);
+- kzfree(aead_req);
+ crypto_cipher_encrypt_one(tfm, b, b_0);
-+
+
+- return 0;
+ /* Extra Authenticate-only data (always two AES blocks) */
+ for (i = 0; i < AES_BLOCK_SIZE; i++)
+ aad[i] ^= b[i];
@@ -54,29 +76,17 @@
+ for (i = 0; i < AES_BLOCK_SIZE; i++)
+ aad[i] ^= b[i];
+ crypto_cipher_encrypt_one(tfm, a, aad);
-
-- char aead_req_data[sizeof(struct aead_request) +
-- crypto_aead_reqsize(tfm)]
-- __aligned(__alignof__(struct aead_request));
-- struct aead_request *aead_req = (void *) aead_req_data;
++
+ /* Mask out bits from auth-only-b_0 */
+ b_0[0] &= 0x07;
-
-- memset(aead_req, 0, sizeof(aead_req_data));
++
+ /* S_0 is used to encrypt T (= MIC) */
+ b_0[14] = 0;
+ b_0[15] = 0;
+ crypto_cipher_encrypt_one(tfm, s_0, b_0);
+}
-
-- sg_init_table(sg, 3);
-- sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad));
-- sg_set_buf(&sg[1], data, data_len);
-- sg_set_buf(&sg[2], mic, mic_len);
-
-- aead_request_set_tfm(aead_req, tfm);
-- aead_request_set_crypt(aead_req, sg, sg, data_len, b_0);
-- aead_request_set_ad(aead_req, sg[0].length);
++
++
+void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
+ u8 *data, size_t data_len, u8 *mic,
+ size_t mic_len)
@@ -109,8 +119,7 @@
+ for (i = 0; i < blen; i++)
+ *cpos++ = *pos++ ^ e[i];
+ }
-
-- crypto_aead_encrypt(aead_req);
++
+ for (i = 0; i < mic_len; i++)
+ mic[i] = b[i] ^ s_0[i];
}
@@ -121,18 +130,23 @@
size_t mic_len)
{
- struct scatterlist sg[3];
-- char aead_req_data[sizeof(struct aead_request) +
-- crypto_aead_reqsize(tfm)]
-- __aligned(__alignof__(struct aead_request));
-- struct aead_request *aead_req = (void *) aead_req_data;
+- struct aead_request *aead_req;
+- int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm);
+- u8 *__aad;
+- int err;
-
- if (data_len == 0)
- return -EINVAL;
-
-- memset(aead_req, 0, sizeof(aead_req_data));
+- aead_req = kzalloc(reqsize + CCM_AAD_LEN, GFP_ATOMIC);
+- if (!aead_req)
+- return -ENOMEM;
+-
+- __aad = (u8 *)aead_req + reqsize;
+- memcpy(__aad, aad, CCM_AAD_LEN);
-
- sg_init_table(sg, 3);
-- sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad));
+- sg_set_buf(&sg[0], &__aad[2], be16_to_cpup((__be16 *)__aad));
- sg_set_buf(&sg[1], data, data_len);
- sg_set_buf(&sg[2], mic, mic_len);
-
@@ -172,7 +186,10 @@
+ return -1;
+ }
-- return crypto_aead_decrypt(aead_req);
+- err = crypto_aead_decrypt(aead_req);
+- kzfree(aead_req);
+-
+- return err;
+ return 0;
}
@@ -215,73 +232,11 @@
- crypto_free_aead(tfm);
+ crypto_free_cipher(tfm);
}
---- a/net/mac80211/aes_ccm.h
-+++ b/net/mac80211/aes_ccm.h
-@@ -12,15 +12,15 @@
-
- #include <linux/crypto.h>
-
--struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
-- size_t key_len,
-- size_t mic_len);
--void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
-+struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[],
-+ size_t key_len,
-+ size_t mic_len);
-+void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
- u8 *data, size_t data_len, u8 *mic,
- size_t mic_len);
--int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
-+int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
- u8 *data, size_t data_len, u8 *mic,
- size_t mic_len);
--void ieee80211_aes_key_free(struct crypto_aead *tfm);
-+void ieee80211_aes_key_free(struct crypto_cipher *tfm);
-
- #endif /* AES_CCM_H */
---- a/net/mac80211/aes_gcm.h
-+++ b/net/mac80211/aes_gcm.h
-@@ -11,12 +11,28 @@
-
- #include <linux/crypto.h>
-
--void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-- u8 *data, size_t data_len, u8 *mic);
--int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-- u8 *data, size_t data_len, u8 *mic);
--struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
-- size_t key_len);
--void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm);
-+static inline void
-+ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-+ u8 *data, size_t data_len, u8 *mic)
-+{
-+}
-+
-+static inline int
-+ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
-+ u8 *data, size_t data_len, u8 *mic)
-+{
-+ return -EOPNOTSUPP;
-+}
-+
-+static inline struct crypto_aead *
-+ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
-+{
-+ return NULL;
-+}
-+
-+static inline void
-+ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
-+{
-+}
-
- #endif /* AES_GCM_H */
--- a/net/mac80211/aes_gmac.h
+++ b/net/mac80211/aes_gmac.h
-@@ -11,10 +11,22 @@
-
- #include <linux/crypto.h>
+@@ -15,10 +15,22 @@
+ #define GMAC_MIC_LEN 16
+ #define GMAC_NONCE_LEN 12
-struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
- size_t key_len);
@@ -320,7 +275,7 @@
struct {
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
-@@ -304,7 +304,8 @@ ieee80211_crypto_tkip_decrypt(struct iee
+@@ -305,7 +305,8 @@ ieee80211_crypto_tkip_decrypt(struct iee
}
@@ -330,7 +285,7 @@
{
__le16 mask_fc;
int a4_included, mgmt;
-@@ -334,14 +335,8 @@ static void ccmp_special_blocks(struct s
+@@ -335,14 +336,8 @@ static void ccmp_special_blocks(struct s
else
qos_tid = 0;
@@ -347,7 +302,7 @@
/* Nonce: Nonce Flags | A2 | PN
* Nonce Flags: Priority (b0..b3) | Management (b4) | Reserved (b5..b7)
-@@ -349,6 +344,8 @@ static void ccmp_special_blocks(struct s
+@@ -350,6 +345,8 @@ static void ccmp_special_blocks(struct s
b_0[1] = qos_tid | (mgmt << 4);
memcpy(&b_0[2], hdr->addr2, ETH_ALEN);
memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN);
@@ -356,16 +311,31 @@
/* AAD (extra authenticate-only data) / masked 802.11 header
* FC | A1 | A2 | A3 | SC | [A4] | [QC] */
-@@ -460,7 +457,7 @@ static int ccmp_encrypt_skb(struct ieee8
+@@ -406,7 +403,7 @@ static int ccmp_encrypt_skb(struct ieee8
+ u8 *pos;
+ u8 pn[6];
+ u64 pn64;
+- u8 aad[CCM_AAD_LEN];
++ u8 aad[2 * AES_BLOCK_SIZE];
+ u8 b_0[AES_BLOCK_SIZE];
+
+ if (info->control.hw_key &&
+@@ -461,9 +458,11 @@ static int ccmp_encrypt_skb(struct ieee8
return 0;
pos += IEEE80211_CCMP_HDR_LEN;
- ccmp_special_blocks(skb, pn, b_0, aad);
+- return ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
+- skb_put(skb, mic_len), mic_len);
+ ccmp_special_blocks(skb, pn, b_0, aad, len);
- ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
- skb_put(skb, mic_len), mic_len);
++ ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len,
++ skb_put(skb, mic_len), mic_len);
++
++ return 0;
+ }
-@@ -537,7 +534,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
+
+@@ -536,7 +535,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
u8 aad[2 * AES_BLOCK_SIZE];
u8 b_0[AES_BLOCK_SIZE];
/* hardware didn't decrypt/verify MIC */
@@ -374,3 +344,113 @@
if (ieee80211_aes_ccm_decrypt(
key->u.ccmp.tfm, b_0, aad,
+@@ -638,7 +637,7 @@ static int gcmp_encrypt_skb(struct ieee8
+ u8 *pos;
+ u8 pn[6];
+ u64 pn64;
+- u8 aad[GCM_AAD_LEN];
++ u8 aad[2 * AES_BLOCK_SIZE];
+ u8 j_0[AES_BLOCK_SIZE];
+
+ if (info->control.hw_key &&
+@@ -695,8 +694,10 @@ static int gcmp_encrypt_skb(struct ieee8
+
+ pos += IEEE80211_GCMP_HDR_LEN;
+ gcmp_special_blocks(skb, pn, j_0, aad);
+- return ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
+- skb_put(skb, IEEE80211_GCMP_MIC_LEN));
++ ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len,
++ skb_put(skb, IEEE80211_GCMP_MIC_LEN));
++
++ return 0;
+ }
+
+ ieee80211_tx_result
+@@ -1120,9 +1121,9 @@ ieee80211_crypto_aes_gmac_encrypt(struct
+ struct ieee80211_key *key = tx->key;
+ struct ieee80211_mmie_16 *mmie;
+ struct ieee80211_hdr *hdr;
+- u8 aad[GMAC_AAD_LEN];
++ u8 aad[20];
+ u64 pn64;
+- u8 nonce[GMAC_NONCE_LEN];
++ u8 nonce[12];
+
+ if (WARN_ON(skb_queue_len(&tx->skbs) != 1))
+ return TX_DROP;
+@@ -1168,7 +1169,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct
+ struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
+ struct ieee80211_key *key = rx->key;
+ struct ieee80211_mmie_16 *mmie;
+- u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN];
++ u8 aad[20], mic[16], ipn[6], nonce[12];
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+
+ if (!ieee80211_is_mgmt(hdr->frame_control))
+--- a/net/mac80211/aes_ccm.h
++++ b/net/mac80211/aes_ccm.h
+@@ -12,17 +12,15 @@
+
+ #include <linux/crypto.h>
+
+-#define CCM_AAD_LEN 32
+-
+-struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
+- size_t key_len,
+- size_t mic_len);
+-int ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
+- u8 *data, size_t data_len, u8 *mic,
+- size_t mic_len);
+-int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
++struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[],
++ size_t key_len,
++ size_t mic_len);
++void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
++ u8 *data, size_t data_len, u8 *mic,
++ size_t mic_len);
++int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
+ u8 *data, size_t data_len, u8 *mic,
+ size_t mic_len);
+-void ieee80211_aes_key_free(struct crypto_aead *tfm);
++void ieee80211_aes_key_free(struct crypto_cipher *tfm);
+
+ #endif /* AES_CCM_H */
+--- a/net/mac80211/aes_gcm.h
++++ b/net/mac80211/aes_gcm.h
+@@ -11,14 +11,28 @@
+
+ #include <linux/crypto.h>
+
+-#define GCM_AAD_LEN 32
++static inline void
++ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
++ u8 *data, size_t data_len, u8 *mic)
++{
++}
+
+-int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
+- u8 *data, size_t data_len, u8 *mic);
+-int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
+- u8 *data, size_t data_len, u8 *mic);
+-struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
+- size_t key_len);
+-void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm);
++static inline int
++ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
++ u8 *data, size_t data_len, u8 *mic)
++{
++ return -EOPNOTSUPP;
++}
++
++static inline struct crypto_aead *
++ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
++{
++ return NULL;
++}
++
++static inline void
++ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
++{
++}
+
+ #endif /* AES_GCM_H */