aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wep.c
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-07-07 15:07:49 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-07-08 16:35:50 -0400
commit3473187d2459a078e00e5fac8aafc30af69c57fa (patch)
tree93c3da6dbcbfd09ea81884bee790219d4cee0d56 /net/mac80211/wep.c
parent73e194639d90594d06d0c10019c0ab4638869135 (diff)
mac80211: remove wep dependency
The current mac80211 code assumes that WEP is always available. If WEP fails to initialize, ieee80211_register_hw will always fail. In some cases (e.g. FIPS certification), the cryptography used by WEP is unavailable. However, in such cases there is no good reason why CCMP encryption (or even no link level encryption) cannot be used. So, this patch removes mac80211's assumption that WEP (and TKIP) will always be available for use. Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/wep.c')
-rw-r--r--net/mac80211/wep.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index 5f3a4113bda1..6d133b6efce5 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -47,8 +47,10 @@ int ieee80211_wep_init(struct ieee80211_local *local)
47 47
48void ieee80211_wep_free(struct ieee80211_local *local) 48void ieee80211_wep_free(struct ieee80211_local *local)
49{ 49{
50 crypto_free_blkcipher(local->wep_tx_tfm); 50 if (!IS_ERR(local->wep_tx_tfm))
51 crypto_free_blkcipher(local->wep_rx_tfm); 51 crypto_free_blkcipher(local->wep_tx_tfm);
52 if (!IS_ERR(local->wep_rx_tfm))
53 crypto_free_blkcipher(local->wep_rx_tfm);
52} 54}
53 55
54static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen) 56static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
@@ -122,19 +124,24 @@ static void ieee80211_wep_remove_iv(struct ieee80211_local *local,
122/* Perform WEP encryption using given key. data buffer must have tailroom 124/* Perform WEP encryption using given key. data buffer must have tailroom
123 * for 4-byte ICV. data_len must not include this ICV. Note: this function 125 * for 4-byte ICV. data_len must not include this ICV. Note: this function
124 * does _not_ add IV. data = RC4(data | CRC32(data)) */ 126 * does _not_ add IV. data = RC4(data | CRC32(data)) */
125void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, 127int ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
126 size_t klen, u8 *data, size_t data_len) 128 size_t klen, u8 *data, size_t data_len)
127{ 129{
128 struct blkcipher_desc desc = { .tfm = tfm }; 130 struct blkcipher_desc desc = { .tfm = tfm };
129 struct scatterlist sg; 131 struct scatterlist sg;
130 __le32 icv; 132 __le32 icv;
131 133
134 if (IS_ERR(tfm))
135 return -1;
136
132 icv = cpu_to_le32(~crc32_le(~0, data, data_len)); 137 icv = cpu_to_le32(~crc32_le(~0, data, data_len));
133 put_unaligned(icv, (__le32 *)(data + data_len)); 138 put_unaligned(icv, (__le32 *)(data + data_len));
134 139
135 crypto_blkcipher_setkey(tfm, rc4key, klen); 140 crypto_blkcipher_setkey(tfm, rc4key, klen);
136 sg_init_one(&sg, data, data_len + WEP_ICV_LEN); 141 sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
137 crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length); 142 crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length);
143
144 return 0;
138} 145}
139 146
140 147
@@ -168,10 +175,8 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local,
168 /* Add room for ICV */ 175 /* Add room for ICV */
169 skb_put(skb, WEP_ICV_LEN); 176 skb_put(skb, WEP_ICV_LEN);
170 177
171 ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3, 178 return ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3,
172 iv + WEP_IV_LEN, len); 179 iv + WEP_IV_LEN, len);
173
174 return 0;
175} 180}
176 181
177 182
@@ -185,6 +190,9 @@ int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
185 struct scatterlist sg; 190 struct scatterlist sg;
186 __le32 crc; 191 __le32 crc;
187 192
193 if (IS_ERR(tfm))
194 return -1;
195
188 crypto_blkcipher_setkey(tfm, rc4key, klen); 196 crypto_blkcipher_setkey(tfm, rc4key, klen);
189 sg_init_one(&sg, data, data_len + WEP_ICV_LEN); 197 sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
190 crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length); 198 crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length);