ahash.c (1ffc9fbd1e5071948b6d48f9a27d845738ee890f) | ahash.c (d4a7a0fbe959e12bdd071b79b50ed34853a6db8f) |
---|---|
1/* 2 * Asynchronous Cryptographic Hash operations. 3 * 4 * This is the asynchronous version of hash.c with notification of 5 * completion via a callback. 6 * 7 * Copyright (c) 2008 Loc Ho <lho@amcc.com> 8 * --- 335 unchanged lines hidden (view full) --- 344 345 if (err == -EINPROGRESS) 346 return; 347 348 if (!err) 349 memcpy(priv->result, req->result, 350 crypto_ahash_digestsize(crypto_ahash_reqtfm(req))); 351 | 1/* 2 * Asynchronous Cryptographic Hash operations. 3 * 4 * This is the asynchronous version of hash.c with notification of 5 * completion via a callback. 6 * 7 * Copyright (c) 2008 Loc Ho <lho@amcc.com> 8 * --- 335 unchanged lines hidden (view full) --- 344 345 if (err == -EINPROGRESS) 346 return; 347 348 if (!err) 349 memcpy(priv->result, req->result, 350 crypto_ahash_digestsize(crypto_ahash_reqtfm(req))); 351 |
352 kzfree(priv); | 352 ahash_restore_req(req); |
353} 354 355static void ahash_def_finup_done2(struct crypto_async_request *req, int err) 356{ 357 struct ahash_request *areq = req->data; | 353} 354 355static void ahash_def_finup_done2(struct crypto_async_request *req, int err) 356{ 357 struct ahash_request *areq = req->data; |
358 struct ahash_request_priv *priv = areq->priv; 359 crypto_completion_t complete = priv->complete; 360 void *data = priv->data; | |
361 362 ahash_def_finup_finish2(areq, err); 363 | 358 359 ahash_def_finup_finish2(areq, err); 360 |
364 complete(data, err); | 361 areq->base.complete(&areq->base, err); |
365} 366 367static int ahash_def_finup_finish1(struct ahash_request *req, int err) 368{ 369 if (err) 370 goto out; 371 372 req->base.complete = ahash_def_finup_done2; 373 req->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; 374 err = crypto_ahash_reqtfm(req)->final(req); 375 376out: 377 ahash_def_finup_finish2(req, err); 378 return err; 379} 380 381static void ahash_def_finup_done1(struct crypto_async_request *req, int err) 382{ 383 struct ahash_request *areq = req->data; | 362} 363 364static int ahash_def_finup_finish1(struct ahash_request *req, int err) 365{ 366 if (err) 367 goto out; 368 369 req->base.complete = ahash_def_finup_done2; 370 req->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; 371 err = crypto_ahash_reqtfm(req)->final(req); 372 373out: 374 ahash_def_finup_finish2(req, err); 375 return err; 376} 377 378static void ahash_def_finup_done1(struct crypto_async_request *req, int err) 379{ 380 struct ahash_request *areq = req->data; |
384 struct ahash_request_priv *priv = areq->priv; 385 crypto_completion_t complete = priv->complete; 386 void *data = priv->data; | |
387 388 err = ahash_def_finup_finish1(areq, err); 389 | 381 382 err = ahash_def_finup_finish1(areq, err); 383 |
390 complete(data, err); | 384 areq->base.complete(&areq->base, err); |
391} 392 393static int ahash_def_finup(struct ahash_request *req) 394{ 395 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); | 385} 386 387static int ahash_def_finup(struct ahash_request *req) 388{ 389 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
396 unsigned long alignmask = crypto_ahash_alignmask(tfm); 397 unsigned int ds = crypto_ahash_digestsize(tfm); 398 struct ahash_request_priv *priv; | 390 int err; |
399 | 391 |
400 priv = kmalloc(sizeof(*priv) + ahash_align_buffer_size(ds, alignmask), 401 (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? 402 GFP_KERNEL : GFP_ATOMIC); 403 if (!priv) 404 return -ENOMEM; | 392 err = ahash_save_req(req, ahash_def_finup_done1); 393 if (err) 394 return err; |
405 | 395 |
406 priv->result = req->result; 407 priv->complete = req->base.complete; 408 priv->data = req->base.data; 409 410 req->result = PTR_ALIGN((u8 *)priv->ubuf, alignmask + 1); 411 req->base.complete = ahash_def_finup_done1; 412 req->base.data = req; 413 req->priv = priv; 414 415 return ahash_def_finup_finish1(req, tfm->update(req)); | 396 err = tfm->update(req); 397 return ahash_def_finup_finish1(req, err); |
416} 417 418static int ahash_no_export(struct ahash_request *req, void *out) 419{ 420 return -ENOSYS; 421} 422 423static int ahash_no_import(struct ahash_request *req, const void *in) --- 172 unchanged lines hidden --- | 398} 399 400static int ahash_no_export(struct ahash_request *req, void *out) 401{ 402 return -ENOSYS; 403} 404 405static int ahash_no_import(struct ahash_request *req, const void *in) --- 172 unchanged lines hidden --- |