Commit a60b7faf authored by Herbert Xu's avatar Herbert Xu

orinoco: Use ahash

This patch replaces uses the long obsolete hash interface with ahash.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent bbdb23b5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/crypto.h> #include <crypto/hash.h>
#include "orinoco.h" #include "orinoco.h"
#include "mic.h" #include "mic.h"
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
/********************************************************************/ /********************************************************************/
int orinoco_mic_init(struct orinoco_private *priv) int orinoco_mic_init(struct orinoco_private *priv)
{ {
priv->tx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0); priv->tx_tfm_mic = crypto_alloc_ahash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_mic)) { if (IS_ERR(priv->tx_tfm_mic)) {
printk(KERN_DEBUG "orinoco_mic_init: could not allocate " printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
"crypto API michael_mic\n"); "crypto API michael_mic\n");
...@@ -24,7 +25,8 @@ int orinoco_mic_init(struct orinoco_private *priv) ...@@ -24,7 +25,8 @@ int orinoco_mic_init(struct orinoco_private *priv)
return -ENOMEM; return -ENOMEM;
} }
priv->rx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0); priv->rx_tfm_mic = crypto_alloc_ahash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_mic)) { if (IS_ERR(priv->rx_tfm_mic)) {
printk(KERN_DEBUG "orinoco_mic_init: could not allocate " printk(KERN_DEBUG "orinoco_mic_init: could not allocate "
"crypto API michael_mic\n"); "crypto API michael_mic\n");
...@@ -38,18 +40,19 @@ int orinoco_mic_init(struct orinoco_private *priv) ...@@ -38,18 +40,19 @@ int orinoco_mic_init(struct orinoco_private *priv)
void orinoco_mic_free(struct orinoco_private *priv) void orinoco_mic_free(struct orinoco_private *priv)
{ {
if (priv->tx_tfm_mic) if (priv->tx_tfm_mic)
crypto_free_hash(priv->tx_tfm_mic); crypto_free_ahash(priv->tx_tfm_mic);
if (priv->rx_tfm_mic) if (priv->rx_tfm_mic)
crypto_free_hash(priv->rx_tfm_mic); crypto_free_ahash(priv->rx_tfm_mic);
} }
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key, int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key,
u8 *da, u8 *sa, u8 priority, u8 *da, u8 *sa, u8 priority,
u8 *data, size_t data_len, u8 *mic) u8 *data, size_t data_len, u8 *mic)
{ {
struct hash_desc desc; AHASH_REQUEST_ON_STACK(req, tfm_michael);
struct scatterlist sg[2]; struct scatterlist sg[2];
u8 hdr[ETH_HLEN + 2]; /* size of header + padding */ u8 hdr[ETH_HLEN + 2]; /* size of header + padding */
int err;
if (tfm_michael == NULL) { if (tfm_michael == NULL) {
printk(KERN_WARNING "orinoco_mic: tfm_michael == NULL\n"); printk(KERN_WARNING "orinoco_mic: tfm_michael == NULL\n");
...@@ -69,11 +72,13 @@ int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key, ...@@ -69,11 +72,13 @@ int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
sg_set_buf(&sg[0], hdr, sizeof(hdr)); sg_set_buf(&sg[0], hdr, sizeof(hdr));
sg_set_buf(&sg[1], data, data_len); sg_set_buf(&sg[1], data, data_len);
if (crypto_hash_setkey(tfm_michael, key, MIC_KEYLEN)) if (crypto_ahash_setkey(tfm_michael, key, MIC_KEYLEN))
return -1; return -1;
desc.tfm = tfm_michael; ahash_request_set_tfm(req, tfm_michael);
desc.flags = 0; ahash_request_set_callback(req, 0, NULL, NULL);
return crypto_hash_digest(&desc, sg, data_len + sizeof(hdr), ahash_request_set_crypt(req, sg, mic, data_len + sizeof(hdr));
mic); err = crypto_ahash_digest(req);
ahash_request_zero(req);
return err;
} }
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
/* Forward declarations */ /* Forward declarations */
struct orinoco_private; struct orinoco_private;
struct crypto_hash; struct crypto_ahash;
int orinoco_mic_init(struct orinoco_private *priv); int orinoco_mic_init(struct orinoco_private *priv);
void orinoco_mic_free(struct orinoco_private *priv); void orinoco_mic_free(struct orinoco_private *priv);
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key, int orinoco_mic(struct crypto_ahash *tfm_michael, u8 *key,
u8 *da, u8 *sa, u8 priority, u8 *da, u8 *sa, u8 priority,
u8 *data, size_t data_len, u8 *mic); u8 *data, size_t data_len, u8 *mic);
......
...@@ -152,8 +152,8 @@ struct orinoco_private { ...@@ -152,8 +152,8 @@ struct orinoco_private {
u8 *wpa_ie; u8 *wpa_ie;
int wpa_ie_len; int wpa_ie_len;
struct crypto_hash *rx_tfm_mic; struct crypto_ahash *rx_tfm_mic;
struct crypto_hash *tx_tfm_mic; struct crypto_ahash *tx_tfm_mic;
unsigned int wpa_enabled:1; unsigned int wpa_enabled:1;
unsigned int tkip_cm_active:1; unsigned int tkip_cm_active:1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment