aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/aes_ccm.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2015-01-24 12:52:07 -0500
committerJohannes Berg <johannes.berg@intel.com>2015-01-27 05:07:35 -0500
commit2b2ba0db1c820d04d5143452d70012cd44d7b578 (patch)
tree7c186fc249d191d9ecba66e740e7a4c922a986d5 /net/mac80211/aes_ccm.c
parent00b9cfa3ff38401bd70c34b250ca13e5ea347b4a (diff)
mac80111: Add CCMP-256 cipher
This allows mac80211 to configure CCMP-256 to the driver and also use software-implementation within mac80211 when the driver does not support this with hardware accelaration. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com> [squash ccmp256 -> mic_len argument change] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/aes_ccm.c')
-rw-r--r--net/mac80211/aes_ccm.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index 09d9caaec591..7869bb40acaa 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -20,7 +20,8 @@
20#include "aes_ccm.h" 20#include "aes_ccm.h"
21 21
22void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 22void 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 size_t mic_len)
24{ 25{
25 struct scatterlist assoc, pt, ct[2]; 26 struct scatterlist assoc, pt, ct[2];
26 27
@@ -35,7 +36,7 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
35 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); 36 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
36 sg_init_table(ct, 2); 37 sg_init_table(ct, 2);
37 sg_set_buf(&ct[0], data, data_len); 38 sg_set_buf(&ct[0], data, data_len);
38 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); 39 sg_set_buf(&ct[1], mic, mic_len);
39 40
40 aead_request_set_tfm(aead_req, tfm); 41 aead_request_set_tfm(aead_req, tfm);
41 aead_request_set_assoc(aead_req, &assoc, assoc.length); 42 aead_request_set_assoc(aead_req, &assoc, assoc.length);
@@ -45,7 +46,8 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
45} 46}
46 47
47int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, 48int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
48 u8 *data, size_t data_len, u8 *mic) 49 u8 *data, size_t data_len, u8 *mic,
50 size_t mic_len)
49{ 51{
50 struct scatterlist assoc, pt, ct[2]; 52 struct scatterlist assoc, pt, ct[2];
51 char aead_req_data[sizeof(struct aead_request) + 53 char aead_req_data[sizeof(struct aead_request) +
@@ -62,17 +64,18 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
62 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); 64 sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
63 sg_init_table(ct, 2); 65 sg_init_table(ct, 2);
64 sg_set_buf(&ct[0], data, data_len); 66 sg_set_buf(&ct[0], data, data_len);
65 sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); 67 sg_set_buf(&ct[1], mic, mic_len);
66 68
67 aead_request_set_tfm(aead_req, tfm); 69 aead_request_set_tfm(aead_req, tfm);
68 aead_request_set_assoc(aead_req, &assoc, assoc.length); 70 aead_request_set_assoc(aead_req, &assoc, assoc.length);
69 aead_request_set_crypt(aead_req, ct, &pt, 71 aead_request_set_crypt(aead_req, ct, &pt, data_len + mic_len, b_0);
70 data_len + IEEE80211_CCMP_MIC_LEN, b_0);
71 72
72 return crypto_aead_decrypt(aead_req); 73 return crypto_aead_decrypt(aead_req);
73} 74}
74 75
75struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[]) 76struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
77 size_t key_len,
78 size_t mic_len)
76{ 79{
77 struct crypto_aead *tfm; 80 struct crypto_aead *tfm;
78 int err; 81 int err;
@@ -81,9 +84,9 @@ struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])
81 if (IS_ERR(tfm)) 84 if (IS_ERR(tfm))
82 return tfm; 85 return tfm;
83 86
84 err = crypto_aead_setkey(tfm, key, WLAN_KEY_LEN_CCMP); 87 err = crypto_aead_setkey(tfm, key, key_len);
85 if (!err) 88 if (!err)
86 err = crypto_aead_setauthsize(tfm, IEEE80211_CCMP_MIC_LEN); 89 err = crypto_aead_setauthsize(tfm, mic_len);
87 if (!err) 90 if (!err)
88 return tfm; 91 return tfm;
89 92