diff options
Diffstat (limited to 'crypto/shash.c')
-rw-r--r-- | crypto/shash.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index d8e0f8f8d672..3b1b06b3dcf3 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -202,9 +202,8 @@ static int shash_async_init(struct ahash_request *req) | |||
202 | return crypto_shash_init(desc); | 202 | return crypto_shash_init(desc); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int shash_async_update(struct ahash_request *req) | 205 | int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc) |
206 | { | 206 | { |
207 | struct shash_desc *desc = ahash_request_ctx(req); | ||
208 | struct crypto_hash_walk walk; | 207 | struct crypto_hash_walk walk; |
209 | int nbytes; | 208 | int nbytes; |
210 | 209 | ||
@@ -214,13 +213,19 @@ static int shash_async_update(struct ahash_request *req) | |||
214 | 213 | ||
215 | return nbytes; | 214 | return nbytes; |
216 | } | 215 | } |
216 | EXPORT_SYMBOL_GPL(shash_ahash_update); | ||
217 | |||
218 | static int shash_async_update(struct ahash_request *req) | ||
219 | { | ||
220 | return shash_ahash_update(req, ahash_request_ctx(req)); | ||
221 | } | ||
217 | 222 | ||
218 | static int shash_async_final(struct ahash_request *req) | 223 | static int shash_async_final(struct ahash_request *req) |
219 | { | 224 | { |
220 | return crypto_shash_final(ahash_request_ctx(req), req->result); | 225 | return crypto_shash_final(ahash_request_ctx(req), req->result); |
221 | } | 226 | } |
222 | 227 | ||
223 | static int shash_async_digest(struct ahash_request *req) | 228 | int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc) |
224 | { | 229 | { |
225 | struct scatterlist *sg = req->src; | 230 | struct scatterlist *sg = req->src; |
226 | unsigned int offset = sg->offset; | 231 | unsigned int offset = sg->offset; |
@@ -228,34 +233,31 @@ static int shash_async_digest(struct ahash_request *req) | |||
228 | int err; | 233 | int err; |
229 | 234 | ||
230 | if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { | 235 | if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { |
231 | struct crypto_shash **ctx = | ||
232 | crypto_ahash_ctx(crypto_ahash_reqtfm(req)); | ||
233 | struct shash_desc *desc = ahash_request_ctx(req); | ||
234 | void *data; | 236 | void *data; |
235 | 237 | ||
236 | desc->tfm = *ctx; | ||
237 | desc->flags = req->base.flags; | ||
238 | |||
239 | data = crypto_kmap(sg_page(sg), 0); | 238 | data = crypto_kmap(sg_page(sg), 0); |
240 | err = crypto_shash_digest(desc, data + offset, nbytes, | 239 | err = crypto_shash_digest(desc, data + offset, nbytes, |
241 | req->result); | 240 | req->result); |
242 | crypto_kunmap(data, 0); | 241 | crypto_kunmap(data, 0); |
243 | crypto_yield(desc->flags); | 242 | crypto_yield(desc->flags); |
244 | goto out; | 243 | } else |
245 | } | 244 | err = crypto_shash_init(desc) ?: |
245 | shash_ahash_update(req, desc) ?: | ||
246 | crypto_shash_final(desc, req->result); | ||
246 | 247 | ||
247 | err = shash_async_init(req); | 248 | return err; |
248 | if (err) | 249 | } |
249 | goto out; | 250 | EXPORT_SYMBOL_GPL(shash_ahash_digest); |
250 | 251 | ||
251 | err = shash_async_update(req); | 252 | static int shash_async_digest(struct ahash_request *req) |
252 | if (err) | 253 | { |
253 | goto out; | 254 | struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req)); |
255 | struct shash_desc *desc = ahash_request_ctx(req); | ||
254 | 256 | ||
255 | err = shash_async_final(req); | 257 | desc->tfm = *ctx; |
258 | desc->flags = req->base.flags; | ||
256 | 259 | ||
257 | out: | 260 | return shash_ahash_digest(req, desc); |
258 | return err; | ||
259 | } | 261 | } |
260 | 262 | ||
261 | static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm) | 263 | static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm) |