aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Möller <dl9pf@gmx.de>2014-03-21 02:39:32 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-04-09 04:55:27 -0400
commit6e1ee5d2e9e411892b5d84e3ea93e3fc88ac786c (patch)
tree93074ed6ad707806bee7aa749e0ffae80f96168f
parentcd6362befe4cc7bf589a5236d2a780af2d47bcc9 (diff)
mac80211: remove VLAIS usage from mac80211
Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This is the original VLAIS struct. struct { struct aead_request req; u8 priv[crypto_aead_reqsize(tfm)]; } aead_req; This patch instead allocates the appropriate amount of memory using a char array. The new code can be compiled with both gcc and clang. Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de> Signed-off-by: Behan Webster <behanw@converseincode.com> [small style cleanups] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--net/mac80211/aes_ccm.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index 7c7df475a401..ec24378caaaf 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -23,12 +23,13 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
23 u8 *data, size_t data_len, u8 *mic) 23 u8 *data, size_t data_len, u8 *mic)
24{ 24{
25 struct scatterlist assoc, pt, ct[2]; 25 struct scatterlist assoc, pt, ct[2];
26 struct {
27 struct aead_request req;
28 u8 priv[crypto_aead_reqsize(tfm)];
29 } aead_req;
30 26
31 memset(&aead_req, 0, sizeof(aead_req)); 27 char aead_req_data[sizeof(struct aead_request) +
28 crypto_aead_reqsize(tfm)]
29 __aligned(__alignof__(struct aead_request));
30 struct aead_request *aead_req = (void *) aead_req_data;
31
32 memset(aead_req, 0, sizeof(aead_req_data));
32 33
33 sg_init_one(&pt, data, data_len); 34 sg_init_one(&pt, data, data_len);
34 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); 35 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
@@ -36,23 +37,23 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
36 sg_set_buf(&ct[0], data, data_len); 37 sg_set_buf(&ct[0], data, data_len);
37 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); 38 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
38 39
39 aead_request_set_tfm(&aead_req.req, tfm); 40 aead_request_set_tfm(aead_req, tfm);
40 aead_request_set_assoc(&aead_req.req, &assoc, assoc.length); 41 aead_request_set_assoc(aead_req, &assoc, assoc.length);
41 aead_request_set_crypt(&aead_req.req, &pt, ct, data_len, b_0); 42 aead_request_set_crypt(aead_req, &pt, ct, data_len, b_0);
42 43
43 crypto_aead_encrypt(&aead_req.req); 44 crypto_aead_encrypt(aead_req);
44} 45}
45 46
46int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 47int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
47 u8 *data, size_t data_len, u8 *mic) 48 u8 *data, size_t data_len, u8 *mic)
48{ 49{
49 struct scatterlist assoc, pt, ct[2]; 50 struct scatterlist assoc, pt, ct[2];
50 struct { 51 char aead_req_data[sizeof(struct aead_request) +
51 struct aead_request req; 52 crypto_aead_reqsize(tfm)]
52 u8 priv[crypto_aead_reqsize(tfm)]; 53 __aligned(__alignof__(struct aead_request));
53 } aead_req; 54 struct aead_request *aead_req = (void *) aead_req_data;
54 55
55 memset(&aead_req, 0, sizeof(aead_req)); 56 memset(aead_req, 0, sizeof(aead_req_data));
56 57
57 sg_init_one(&pt, data, data_len); 58 sg_init_one(&pt, data, data_len);
58 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); 59 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
@@ -60,12 +61,12 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
60 sg_set_buf(&ct[0], data, data_len); 61 sg_set_buf(&ct[0], data, data_len);
61 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); 62 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
62 63
63 aead_request_set_tfm(&aead_req.req, tfm); 64 aead_request_set_tfm(aead_req, tfm);
64 aead_request_set_assoc(&aead_req.req, &assoc, assoc.length); 65 aead_request_set_assoc(aead_req, &assoc, assoc.length);
65 aead_request_set_crypt(&aead_req.req, ct, &pt, 66 aead_request_set_crypt(aead_req, ct, &pt,
66 data_len + IEEE80211_CCMP_MIC_LEN, b_0); 67 data_len + IEEE80211_CCMP_MIC_LEN, b_0);
67 68
68 return crypto_aead_decrypt(&aead_req.req); 69 return crypto_aead_decrypt(aead_req);
69} 70}
70 71
71struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[]) 72struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])