6
6
#include <linux/string.h>
7
7
#include <linux/if_ether.h>
8
8
#include <linux/scatterlist.h>
9
- #include <linux/ crypto.h>
9
+ #include <crypto/hash .h>
10
10
11
11
#include "orinoco.h"
12
12
#include "mic.h"
16
16
/********************************************************************/
17
17
int orinoco_mic_init (struct orinoco_private * priv )
18
18
{
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 );
20
21
if (IS_ERR (priv -> tx_tfm_mic )) {
21
22
printk (KERN_DEBUG "orinoco_mic_init: could not allocate "
22
23
"crypto API michael_mic\n" );
23
24
priv -> tx_tfm_mic = NULL ;
24
25
return - ENOMEM ;
25
26
}
26
27
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 );
28
30
if (IS_ERR (priv -> rx_tfm_mic )) {
29
31
printk (KERN_DEBUG "orinoco_mic_init: could not allocate "
30
32
"crypto API michael_mic\n" );
@@ -38,18 +40,19 @@ int orinoco_mic_init(struct orinoco_private *priv)
38
40
void orinoco_mic_free (struct orinoco_private * priv )
39
41
{
40
42
if (priv -> tx_tfm_mic )
41
- crypto_free_hash (priv -> tx_tfm_mic );
43
+ crypto_free_ahash (priv -> tx_tfm_mic );
42
44
if (priv -> rx_tfm_mic )
43
- crypto_free_hash (priv -> rx_tfm_mic );
45
+ crypto_free_ahash (priv -> rx_tfm_mic );
44
46
}
45
47
46
- int orinoco_mic (struct crypto_hash * tfm_michael , u8 * key ,
48
+ int orinoco_mic (struct crypto_ahash * tfm_michael , u8 * key ,
47
49
u8 * da , u8 * sa , u8 priority ,
48
50
u8 * data , size_t data_len , u8 * mic )
49
51
{
50
- struct hash_desc desc ;
52
+ AHASH_REQUEST_ON_STACK ( req , tfm_michael ) ;
51
53
struct scatterlist sg [2 ];
52
54
u8 hdr [ETH_HLEN + 2 ]; /* size of header + padding */
55
+ int err ;
53
56
54
57
if (tfm_michael == NULL ) {
55
58
printk (KERN_WARNING "orinoco_mic: tfm_michael == NULL\n" );
@@ -69,11 +72,13 @@ int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key,
69
72
sg_set_buf (& sg [0 ], hdr , sizeof (hdr ));
70
73
sg_set_buf (& sg [1 ], data , data_len );
71
74
72
- if (crypto_hash_setkey (tfm_michael , key , MIC_KEYLEN ))
75
+ if (crypto_ahash_setkey (tfm_michael , key , MIC_KEYLEN ))
73
76
return -1 ;
74
77
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 ;
79
84
}
0 commit comments