diff options
author | Dmitry Kasatkin <dmitry.kasatkin@nokia.com> | 2010-11-19 09:04:22 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-11-27 03:37:16 -0500 |
commit | 0c3cf4cc9abd854dcc6488719348a75b8f328c54 (patch) | |
tree | 3883a2763b471a05b39890715bb9bafa8e2410a9 /drivers/crypto | |
parent | 0d258efb6a58fe047197c3b9cff8746bb176d58a (diff) |
crypto: omap-sham - uses digest buffer in request context
Currently driver storred digest results in req->results
provided by the client. But some clients do not set it
until final() call. It leads to crash.
Changed to use internal buffer to store temporary digest results.
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/omap-sham.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index a081c7c7d03f..222237014007 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c | |||
@@ -97,6 +97,7 @@ struct omap_sham_reqctx { | |||
97 | unsigned long flags; | 97 | unsigned long flags; |
98 | unsigned long op; | 98 | unsigned long op; |
99 | 99 | ||
100 | u8 digest[SHA1_DIGEST_SIZE]; | ||
100 | size_t digcnt; | 101 | size_t digcnt; |
101 | u8 *buffer; | 102 | u8 *buffer; |
102 | size_t bufcnt; | 103 | size_t bufcnt; |
@@ -194,7 +195,7 @@ static inline int omap_sham_wait(struct omap_sham_dev *dd, u32 offset, u32 bit) | |||
194 | static void omap_sham_copy_hash(struct ahash_request *req, int out) | 195 | static void omap_sham_copy_hash(struct ahash_request *req, int out) |
195 | { | 196 | { |
196 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); | 197 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
197 | u32 *hash = (u32 *)req->result; | 198 | u32 *hash = (u32 *)ctx->digest; |
198 | int i; | 199 | int i; |
199 | 200 | ||
200 | if (likely(ctx->flags & FLAGS_SHA1)) { | 201 | if (likely(ctx->flags & FLAGS_SHA1)) { |
@@ -453,8 +454,11 @@ static void omap_sham_cleanup(struct ahash_request *req) | |||
453 | ctx->flags |= FLAGS_CLEAN; | 454 | ctx->flags |= FLAGS_CLEAN; |
454 | spin_unlock_irqrestore(&dd->lock, flags); | 455 | spin_unlock_irqrestore(&dd->lock, flags); |
455 | 456 | ||
456 | if (ctx->digcnt) | 457 | if (ctx->digcnt) { |
457 | clk_disable(dd->iclk); | 458 | clk_disable(dd->iclk); |
459 | memcpy(req->result, ctx->digest, (ctx->flags & FLAGS_SHA1) ? | ||
460 | SHA1_DIGEST_SIZE : MD5_DIGEST_SIZE); | ||
461 | } | ||
458 | 462 | ||
459 | if (ctx->dma_addr) | 463 | if (ctx->dma_addr) |
460 | dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen, | 464 | dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen, |
@@ -576,6 +580,7 @@ static int omap_sham_final_req(struct omap_sham_dev *dd) | |||
576 | 580 | ||
577 | static int omap_sham_finish_req_hmac(struct ahash_request *req) | 581 | static int omap_sham_finish_req_hmac(struct ahash_request *req) |
578 | { | 582 | { |
583 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); | ||
579 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); | 584 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); |
580 | struct omap_sham_hmac_ctx *bctx = tctx->base; | 585 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
581 | int bs = crypto_shash_blocksize(bctx->shash); | 586 | int bs = crypto_shash_blocksize(bctx->shash); |
@@ -590,7 +595,7 @@ static int omap_sham_finish_req_hmac(struct ahash_request *req) | |||
590 | 595 | ||
591 | return crypto_shash_init(&desc.shash) ?: | 596 | return crypto_shash_init(&desc.shash) ?: |
592 | crypto_shash_update(&desc.shash, bctx->opad, bs) ?: | 597 | crypto_shash_update(&desc.shash, bctx->opad, bs) ?: |
593 | crypto_shash_finup(&desc.shash, req->result, ds, req->result); | 598 | crypto_shash_finup(&desc.shash, ctx->digest, ds, ctx->digest); |
594 | } | 599 | } |
595 | 600 | ||
596 | static void omap_sham_finish_req(struct ahash_request *req, int err) | 601 | static void omap_sham_finish_req(struct ahash_request *req, int err) |