Skip to content

Commit a60b7fa

Browse files
committed
orinoco: Use ahash
This patch replaces uses the long obsolete hash interface with ahash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent bbdb23b commit a60b7fa

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

drivers/net/wireless/intersil/orinoco/mic.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <linux/string.h>
77
#include <linux/if_ether.h>
88
#include <linux/scatterlist.h>
9-
#include <linux/crypto.h>
9+
#include <crypto/hash.h>
1010

1111
#include "orinoco.h"
1212
#include "mic.h"
@@ -16,15 +16,17 @@
1616
/********************************************************************/
1717
int orinoco_mic_init(struct orinoco_private *priv)
1818
{
19-
priv->tx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0);
19+
priv->tx_tfm_mic = crypto_alloc_ahash("michael_mic", 0,
20+
CRYPTO_ALG_ASYNC);
2021
if (IS_ERR(priv->tx_tfm_mic)) {
2122
printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
2223
"crypto API michael_mic\n");
2324
priv->tx_tfm_mic = NULL;
2425
return -ENOMEM;
2526
}
2627

27-
priv->rx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0);
28+
priv->rx_tfm_mic = crypto_alloc_ahash("michael_mic", 0,
29+
CRYPTO_ALG_ASYNC);
2830
if (IS_ERR(priv->rx_tfm_mic)) {
2931
printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
3032
"crypto API michael_mic\n");
@@ -38,18 +40,19 @@ int orinoco_mic_init(struct orinoco_private *priv)
3840
void orinoco_mic_free(struct orinoco_private *priv)
3941
{
4042
if (priv->tx_tfm_mic)
41-
crypto_free_hash(priv->tx_tfm_mic);
43+
crypto_free_ahash(priv->tx_tfm_mic);
4244
if (priv->rx_tfm_mic)
43-
crypto_free_hash(priv->rx_tfm_mic);
45+
crypto_free_ahash(priv->rx_tfm_mic);
4446
}
4547

46-
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
48+
int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key,
4749
u8 *da, u8 *sa, u8 priority,
4850
u8 *data, size_t data_len, u8 *mic)
4951
{
50-
struct hash_desc desc;
52+
AHASH_REQUEST_ON_STACK(req, tfm_michael);
5153
struct scatterlist sg[2];
5254
u8 hdr[ETH_HLEN + 2]; /* size of header + padding */
55+
int err;
5356

5457
if (tfm_michael == NULL) {
5558
printk(KERN_WARNING "orinoco_mic: tfm_michael == NULL\n");
@@ -69,11 +72,13 @@ int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
6972
sg_set_buf(&sg[0], hdr, sizeof(hdr));
7073
sg_set_buf(&sg[1], data, data_len);
7174

72-
if (crypto_hash_setkey(tfm_michael, key, MIC_KEYLEN))
75+
if (crypto_ahash_setkey(tfm_michael, key, MIC_KEYLEN))
7376
return -1;
7477

75-
desc.tfm = tfm_michael;
76-
desc.flags = 0;
77-
return crypto_hash_digest(&desc, sg, data_len + sizeof(hdr),
78-
mic);
78+
ahash_request_set_tfm(req, tfm_michael);
79+
ahash_request_set_callback(req, 0, NULL, NULL);
80+
ahash_request_set_crypt(req, sg, mic, data_len + sizeof(hdr));
81+
err = crypto_ahash_digest(req);
82+
ahash_request_zero(req);
83+
return err;
7984
}

drivers/net/wireless/intersil/orinoco/mic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
/* Forward declarations */
1313
struct orinoco_private;
14-
struct crypto_hash;
14+
struct crypto_ahash;
1515

1616
int orinoco_mic_init(struct orinoco_private *priv);
1717
void orinoco_mic_free(struct orinoco_private *priv);
18-
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
18+
int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key,
1919
u8 *da, u8 *sa, u8 priority,
2020
u8 *data, size_t data_len, u8 *mic);
2121

drivers/net/wireless/intersil/orinoco/orinoco.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ struct orinoco_private {
152152
u8 *wpa_ie;
153153
int wpa_ie_len;
154154

155-
struct crypto_hash *rx_tfm_mic;
156-
struct crypto_hash *tx_tfm_mic;
155+
struct crypto_ahash *rx_tfm_mic;
156+
struct crypto_ahash *tx_tfm_mic;
157157

158158
unsigned int wpa_enabled:1;
159159
unsigned int tkip_cm_active:1;

0 commit comments

Comments
 (0)