projects
/
powerpc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[IPV6] IP6TUNNEL: Add support to IPv4 over IPv6 tunnel.
[powerpc.git]
/
net
/
ieee80211
/
ieee80211_crypt_tkip.c
diff --git
a/net/ieee80211/ieee80211_crypt_tkip.c
b/net/ieee80211/ieee80211_crypt_tkip.c
index
f2df2f5
..
fc1f99a
100644
(file)
--- a/
net/ieee80211/ieee80211_crypt_tkip.c
+++ b/
net/ieee80211/ieee80211_crypt_tkip.c
@@
-9,12
+9,14
@@
* more details.
*/
* more details.
*/
+#include <linux/err.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
+#include <linux/mm.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <asm/string.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <asm/string.h>
@@
-52,10
+54,10
@@
struct ieee80211_tkip_data {
int key_idx;
int key_idx;
- struct crypto_
tfm *t
x_tfm_arc4;
- struct crypto_
tfm *t
x_tfm_michael;
- struct crypto_
tfm *r
x_tfm_arc4;
- struct crypto_
tfm *r
x_tfm_michael;
+ struct crypto_
blkcipher *r
x_tfm_arc4;
+ struct crypto_
hash *r
x_tfm_michael;
+ struct crypto_
blkcipher *t
x_tfm_arc4;
+ struct crypto_
hash *t
x_tfm_michael;
/* scratch buffers for virt_to_page() (crypto API) */
u8 rx_hdr[16], tx_hdr[16];
/* scratch buffers for virt_to_page() (crypto API) */
u8 rx_hdr[16], tx_hdr[16];
@@
-87,31
+89,39
@@
static void *ieee80211_tkip_init(int key_idx)
priv->key_idx = key_idx;
priv->key_idx = key_idx;
- priv->tx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
- if (priv->tx_tfm_arc4 == NULL) {
+ priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tx_tfm_arc4)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API arc4\n");
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API arc4\n");
+ priv->tx_tfm_arc4 = NULL;
goto fail;
}
goto fail;
}
- priv->tx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
- if (priv->tx_tfm_michael == NULL) {
+ priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->tx_tfm_michael)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API michael_mic\n");
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API michael_mic\n");
+ priv->tx_tfm_michael = NULL;
goto fail;
}
goto fail;
}
- priv->rx_tfm_arc4 = crypto_alloc_tfm("arc4", 0);
- if (priv->rx_tfm_arc4 == NULL) {
+ priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->rx_tfm_arc4)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API arc4\n");
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API arc4\n");
+ priv->rx_tfm_arc4 = NULL;
goto fail;
}
goto fail;
}
- priv->rx_tfm_michael = crypto_alloc_tfm("michael_mic", 0);
- if (priv->rx_tfm_michael == NULL) {
+ priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
+ CRYPTO_ALG_ASYNC);
+ if (IS_ERR(priv->rx_tfm_michael)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API michael_mic\n");
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
"crypto API michael_mic\n");
+ priv->rx_tfm_michael = NULL;
goto fail;
}
goto fail;
}
@@
-120,13
+130,13
@@
static void *ieee80211_tkip_init(int key_idx)
fail:
if (priv) {
if (priv->tx_tfm_michael)
fail:
if (priv) {
if (priv->tx_tfm_michael)
- crypto_free_
tfm
(priv->tx_tfm_michael);
+ crypto_free_
hash
(priv->tx_tfm_michael);
if (priv->tx_tfm_arc4)
if (priv->tx_tfm_arc4)
- crypto_free_
tfm
(priv->tx_tfm_arc4);
+ crypto_free_
blkcipher
(priv->tx_tfm_arc4);
if (priv->rx_tfm_michael)
if (priv->rx_tfm_michael)
- crypto_free_
tfm
(priv->rx_tfm_michael);
+ crypto_free_
hash
(priv->rx_tfm_michael);
if (priv->rx_tfm_arc4)
if (priv->rx_tfm_arc4)
- crypto_free_
tfm
(priv->rx_tfm_arc4);
+ crypto_free_
blkcipher
(priv->rx_tfm_arc4);
kfree(priv);
}
kfree(priv);
}
@@
-138,13
+148,13
@@
static void ieee80211_tkip_deinit(void *priv)
struct ieee80211_tkip_data *_priv = priv;
if (_priv) {
if (_priv->tx_tfm_michael)
struct ieee80211_tkip_data *_priv = priv;
if (_priv) {
if (_priv->tx_tfm_michael)
- crypto_free_
tfm
(_priv->tx_tfm_michael);
+ crypto_free_
hash
(_priv->tx_tfm_michael);
if (_priv->tx_tfm_arc4)
if (_priv->tx_tfm_arc4)
- crypto_free_
tfm
(_priv->tx_tfm_arc4);
+ crypto_free_
blkcipher
(_priv->tx_tfm_arc4);
if (_priv->rx_tfm_michael)
if (_priv->rx_tfm_michael)
- crypto_free_
tfm
(_priv->rx_tfm_michael);
+ crypto_free_
hash
(_priv->rx_tfm_michael);
if (_priv->rx_tfm_arc4)
if (_priv->rx_tfm_arc4)
- crypto_free_
tfm
(_priv->rx_tfm_arc4);
+ crypto_free_
blkcipher
(_priv->rx_tfm_arc4);
}
kfree(priv);
}
}
kfree(priv);
}
@@
-344,6
+354,7
@@
static int ieee80211_tkip_hdr(struct sk_buff *skb, int hdr_len,
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
+ struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
int len;
u8 rc4key[16], *pos, *icv;
u32 crc;
int len;
u8 rc4key[16], *pos, *icv;
u32 crc;
@@
-377,13
+388,11
@@
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
icv[2] = crc >> 16;
icv[3] = crc >> 24;
icv[2] = crc >> 16;
icv[3] = crc >> 24;
- crypto_cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
+ crypto_
blk
cipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
sg.page = virt_to_page(pos);
sg.offset = offset_in_page(pos);
sg.length = len + 4;
sg.page = virt_to_page(pos);
sg.offset = offset_in_page(pos);
sg.length = len + 4;
- crypto_cipher_encrypt(tkey->tx_tfm_arc4, &sg, &sg, len + 4);
-
- return 0;
+ return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
}
/*
}
/*
@@
-402,6
+411,7
@@
static inline int tkip_replay_check(u32 iv32_n, u16 iv16_n,
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
+ struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
u8 rc4key[16];
u8 keyidx, *pos;
u32 iv32;
u8 rc4key[16];
u8 keyidx, *pos;
u32 iv32;
@@
-472,11
+482,18
@@
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
plen = skb->len - hdr_len - 12;
plen = skb->len - hdr_len - 12;
- crypto_cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
+ crypto_
blk
cipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
sg.page = virt_to_page(pos);
sg.offset = offset_in_page(pos);
sg.length = plen + 4;
sg.page = virt_to_page(pos);
sg.offset = offset_in_page(pos);
sg.length = plen + 4;
- crypto_cipher_decrypt(tkey->rx_tfm_arc4, &sg, &sg, plen + 4);
+ if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
+ if (net_ratelimit()) {
+ printk(KERN_DEBUG ": TKIP: failed to decrypt "
+ "received packet from " MAC_FMT "\n",
+ MAC_ARG(hdr->addr2));
+ }
+ return -7;
+ }
crc = ~crc32_le(~0, pos, plen);
icv[0] = crc;
crc = ~crc32_le(~0, pos, plen);
icv[0] = crc;
@@
-510,9
+527,10
@@
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return keyidx;
}
return keyidx;
}
-static int michael_mic(struct crypto_
tfm
*tfm_michael, u8 * key, u8 * hdr,
+static int michael_mic(struct crypto_
hash
*tfm_michael, u8 * key, u8 * hdr,
u8 * data, size_t data_len, u8 * mic)
{
u8 * data, size_t data_len, u8 * mic)
{
+ struct hash_desc desc;
struct scatterlist sg[2];
if (tfm_michael == NULL) {
struct scatterlist sg[2];
if (tfm_michael == NULL) {
@@
-527,12
+545,12
@@
static int michael_mic(struct crypto_tfm *tfm_michael, u8 * key, u8 * hdr,
sg[1].offset = offset_in_page(data);
sg[1].length = data_len;
sg[1].offset = offset_in_page(data);
sg[1].length = data_len;
- crypto_digest_init(tfm_michael);
- crypto_digest_setkey(tfm_michael, key, 8);
- crypto_digest_update(tfm_michael, sg, 2);
- crypto_digest_final(tfm_michael, mic);
+ if (crypto_hash_setkey(tfm_michael, key, 8))
+ return -1;
- return 0;
+ desc.tfm = tfm_michael;
+ desc.flags = 0;
+ return crypto_hash_digest(&desc, sg, data_len + 16, mic);
}
static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
}
static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
@@
-656,10
+674,10
@@
static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
int keyidx;
{
struct ieee80211_tkip_data *tkey = priv;
int keyidx;
- struct crypto_
tfm
*tfm = tkey->tx_tfm_michael;
- struct crypto_
tfm
*tfm2 = tkey->tx_tfm_arc4;
- struct crypto_
tfm
*tfm3 = tkey->rx_tfm_michael;
- struct crypto_
tfm
*tfm4 = tkey->rx_tfm_arc4;
+ struct crypto_
hash
*tfm = tkey->tx_tfm_michael;
+ struct crypto_
blkcipher
*tfm2 = tkey->tx_tfm_arc4;
+ struct crypto_
hash
*tfm3 = tkey->rx_tfm_michael;
+ struct crypto_
blkcipher
*tfm4 = tkey->rx_tfm_arc4;
keyidx = tkey->key_idx;
memset(tkey, 0, sizeof(*tkey));
keyidx = tkey->key_idx;
memset(tkey, 0, sizeof(*tkey));