diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-27 04:03:50 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-27 23:23:20 -0400 |
commit | 957e0fe6292372460bdace9c2a67a857379ad1db (patch) | |
tree | d642a0afc2e2d7a117e6413f70c4079302d6ac9f /net/mac80211/aes_gcm.c | |
parent | 25528fdae4abb763c446b2e5081f80ba5a4b6f31 (diff) |
mac80211: Switch to new AEAD interface
This patch makes use of the new AEAD interface which uses a single
SG list instead of separate lists for the AD and plain text.
Tested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net/mac80211/aes_gcm.c')
-rw-r--r-- | net/mac80211/aes_gcm.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/net/mac80211/aes_gcm.c b/net/mac80211/aes_gcm.c index b91c9d7bf665..3afe361fd27c 100644 --- a/net/mac80211/aes_gcm.c +++ b/net/mac80211/aes_gcm.c | |||
@@ -18,7 +18,7 @@ | |||
18 | void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, | 18 | void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, |
19 | u8 *data, size_t data_len, u8 *mic) | 19 | u8 *data, size_t data_len, u8 *mic) |
20 | { | 20 | { |
21 | struct scatterlist assoc, pt, ct[2]; | 21 | struct scatterlist sg[3]; |
22 | 22 | ||
23 | char aead_req_data[sizeof(struct aead_request) + | 23 | char aead_req_data[sizeof(struct aead_request) + |
24 | crypto_aead_reqsize(tfm)] | 24 | crypto_aead_reqsize(tfm)] |
@@ -27,15 +27,14 @@ void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, | |||
27 | 27 | ||
28 | memset(aead_req, 0, sizeof(aead_req_data)); | 28 | memset(aead_req, 0, sizeof(aead_req_data)); |
29 | 29 | ||
30 | sg_init_one(&pt, data, data_len); | 30 | sg_init_table(sg, 3); |
31 | sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); | 31 | sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); |
32 | sg_init_table(ct, 2); | 32 | sg_set_buf(&sg[1], data, data_len); |
33 | sg_set_buf(&ct[0], data, data_len); | 33 | sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); |
34 | sg_set_buf(&ct[1], mic, IEEE80211_GCMP_MIC_LEN); | ||
35 | 34 | ||
36 | aead_request_set_tfm(aead_req, tfm); | 35 | aead_request_set_tfm(aead_req, tfm); |
37 | aead_request_set_assoc(aead_req, &assoc, assoc.length); | 36 | aead_request_set_crypt(aead_req, sg, sg, data_len, j_0); |
38 | aead_request_set_crypt(aead_req, &pt, ct, data_len, j_0); | 37 | aead_request_set_ad(aead_req, sg[0].length); |
39 | 38 | ||
40 | crypto_aead_encrypt(aead_req); | 39 | crypto_aead_encrypt(aead_req); |
41 | } | 40 | } |
@@ -43,7 +42,7 @@ void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, | |||
43 | int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, | 42 | int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, |
44 | u8 *data, size_t data_len, u8 *mic) | 43 | u8 *data, size_t data_len, u8 *mic) |
45 | { | 44 | { |
46 | struct scatterlist assoc, pt, ct[2]; | 45 | struct scatterlist sg[3]; |
47 | char aead_req_data[sizeof(struct aead_request) + | 46 | char aead_req_data[sizeof(struct aead_request) + |
48 | crypto_aead_reqsize(tfm)] | 47 | crypto_aead_reqsize(tfm)] |
49 | __aligned(__alignof__(struct aead_request)); | 48 | __aligned(__alignof__(struct aead_request)); |
@@ -54,16 +53,15 @@ int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad, | |||
54 | 53 | ||
55 | memset(aead_req, 0, sizeof(aead_req_data)); | 54 | memset(aead_req, 0, sizeof(aead_req_data)); |
56 | 55 | ||
57 | sg_init_one(&pt, data, data_len); | 56 | sg_init_table(sg, 3); |
58 | sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); | 57 | sg_set_buf(&sg[0], &aad[2], be16_to_cpup((__be16 *)aad)); |
59 | sg_init_table(ct, 2); | 58 | sg_set_buf(&sg[1], data, data_len); |
60 | sg_set_buf(&ct[0], data, data_len); | 59 | sg_set_buf(&sg[2], mic, IEEE80211_GCMP_MIC_LEN); |
61 | sg_set_buf(&ct[1], mic, IEEE80211_GCMP_MIC_LEN); | ||
62 | 60 | ||
63 | aead_request_set_tfm(aead_req, tfm); | 61 | aead_request_set_tfm(aead_req, tfm); |
64 | aead_request_set_assoc(aead_req, &assoc, assoc.length); | 62 | aead_request_set_crypt(aead_req, sg, sg, |
65 | aead_request_set_crypt(aead_req, ct, &pt, | ||
66 | data_len + IEEE80211_GCMP_MIC_LEN, j_0); | 63 | data_len + IEEE80211_GCMP_MIC_LEN, j_0); |
64 | aead_request_set_ad(aead_req, sg[0].length); | ||
67 | 65 | ||
68 | return crypto_aead_decrypt(aead_req); | 66 | return crypto_aead_decrypt(aead_req); |
69 | } | 67 | } |