13
13
14
14
#include <crypto/hmac.h>
15
15
#include <crypto/internal/hash.h>
16
- #include <crypto/scatterwalk.h>
17
16
#include <linux/err.h>
18
17
#include <linux/fips.h>
19
- #include <linux/init.h>
20
18
#include <linux/kernel.h>
21
19
#include <linux/module.h>
22
- #include <linux/scatterlist .h>
20
+ #include <linux/slab .h>
23
21
#include <linux/string.h>
24
22
25
23
struct hmac_ctx {
@@ -39,7 +37,7 @@ static int hmac_setkey(struct crypto_shash *parent,
39
37
u8 * ipad = & tctx -> pads [0 ];
40
38
u8 * opad = & tctx -> pads [ss ];
41
39
SHASH_DESC_ON_STACK (shash , hash );
42
- unsigned int i ;
40
+ int err , i ;
43
41
44
42
if (fips_enabled && (keylen < 112 / 8 ))
45
43
return - EINVAL ;
@@ -65,12 +63,14 @@ static int hmac_setkey(struct crypto_shash *parent,
65
63
opad [i ] ^= HMAC_OPAD_VALUE ;
66
64
}
67
65
68
- return crypto_shash_init (shash ) ?:
69
- crypto_shash_update (shash , ipad , bs ) ?:
70
- crypto_shash_export (shash , ipad ) ?:
71
- crypto_shash_init (shash ) ?:
72
- crypto_shash_update (shash , opad , bs ) ?:
73
- crypto_shash_export (shash , opad );
66
+ err = crypto_shash_init (shash ) ?:
67
+ crypto_shash_update (shash , ipad , bs ) ?:
68
+ crypto_shash_export (shash , ipad ) ?:
69
+ crypto_shash_init (shash ) ?:
70
+ crypto_shash_update (shash , opad , bs ) ?:
71
+ crypto_shash_export (shash , opad );
72
+ shash_desc_zero (shash );
73
+ return err ;
74
74
}
75
75
76
76
static int hmac_export (struct shash_desc * pdesc , void * out )
@@ -105,20 +105,6 @@ static int hmac_update(struct shash_desc *pdesc,
105
105
return crypto_shash_update (desc , data , nbytes );
106
106
}
107
107
108
- static int hmac_final (struct shash_desc * pdesc , u8 * out )
109
- {
110
- struct crypto_shash * parent = pdesc -> tfm ;
111
- int ds = crypto_shash_digestsize (parent );
112
- int ss = crypto_shash_statesize (parent );
113
- const struct hmac_ctx * tctx = crypto_shash_ctx (parent );
114
- const u8 * opad = & tctx -> pads [ss ];
115
- struct shash_desc * desc = shash_desc_ctx (pdesc );
116
-
117
- return crypto_shash_final (desc , out ) ?:
118
- crypto_shash_import (desc , opad ) ?:
119
- crypto_shash_finup (desc , out , ds , out );
120
- }
121
-
122
108
static int hmac_finup (struct shash_desc * pdesc , const u8 * data ,
123
109
unsigned int nbytes , u8 * out )
124
110
{
@@ -222,7 +208,6 @@ static int hmac_create(struct crypto_template *tmpl, struct rtattr **tb)
222
208
inst -> alg .descsize = sizeof (struct shash_desc ) + salg -> descsize ;
223
209
inst -> alg .init = hmac_init ;
224
210
inst -> alg .update = hmac_update ;
225
- inst -> alg .final = hmac_final ;
226
211
inst -> alg .finup = hmac_finup ;
227
212
inst -> alg .export = hmac_export ;
228
213
inst -> alg .import = hmac_import ;
0 commit comments