Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 247775
b: refs/heads/master
c: bf36275
h: refs/heads/master
i:
  247773: d8a6d59
  247771: 5eb9c41
  247767: 7fa314c
  247759: c33f644
  247743: 32477df
v: v3
  • Loading branch information
Dmitry Kasatkin authored and Herbert Xu committed Apr 26, 2011
1 parent 7e3886d commit 12e78ec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 528d26f57acd112fef78cd455db78e69a1ac39fd
refs/heads/master: bf362759034cf208966dff262c7d740a6b1b3edd
71 changes: 31 additions & 40 deletions trunk/drivers/crypto/omap-sham.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#define FLAGS_SHA1 0x0010
#define FLAGS_DMA_ACTIVE 0x0020
#define FLAGS_OUTPUT_READY 0x0040
#define FLAGS_CLEAN 0x0080
#define FLAGS_INIT 0x0100
#define FLAGS_CPU 0x0200
#define FLAGS_HMAC 0x0400
Expand Down Expand Up @@ -511,26 +510,6 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
return 0;
}

static void omap_sham_cleanup(struct ahash_request *req)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
struct omap_sham_dev *dd = ctx->dd;
unsigned long flags;

spin_lock_irqsave(&dd->lock, flags);
if (ctx->flags & FLAGS_CLEAN) {
spin_unlock_irqrestore(&dd->lock, flags);
return;
}
ctx->flags |= FLAGS_CLEAN;
spin_unlock_irqrestore(&dd->lock, flags);

if (ctx->digcnt)
omap_sham_copy_ready_hash(req);

dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt);
}

static int omap_sham_init(struct ahash_request *req)
{
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
Expand Down Expand Up @@ -618,9 +597,8 @@ static int omap_sham_final_req(struct omap_sham_dev *dd)
return err;
}

static int omap_sham_finish_req_hmac(struct ahash_request *req)
static int omap_sham_finish_hmac(struct ahash_request *req)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
struct omap_sham_hmac_ctx *bctx = tctx->base;
int bs = crypto_shash_blocksize(bctx->shash);
Expand All @@ -635,7 +613,24 @@ static int omap_sham_finish_req_hmac(struct ahash_request *req)

return crypto_shash_init(&desc.shash) ?:
crypto_shash_update(&desc.shash, bctx->opad, bs) ?:
crypto_shash_finup(&desc.shash, ctx->digest, ds, ctx->digest);
crypto_shash_finup(&desc.shash, req->result, ds, req->result);
}

static int omap_sham_finish(struct ahash_request *req)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
struct omap_sham_dev *dd = ctx->dd;
int err = 0;

if (ctx->digcnt) {
omap_sham_copy_ready_hash(req);
if (ctx->flags & FLAGS_HMAC)
err = omap_sham_finish_hmac(req);
}

dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt);

return err;
}

static void omap_sham_finish_req(struct ahash_request *req, int err)
Expand All @@ -645,15 +640,12 @@ static void omap_sham_finish_req(struct ahash_request *req, int err)

if (!err) {
omap_sham_copy_hash(ctx->dd->req, 1);
if (ctx->flags & FLAGS_HMAC)
err = omap_sham_finish_req_hmac(req);
if (ctx->flags & FLAGS_FINAL)
err = omap_sham_finish(req);
} else {
ctx->flags |= FLAGS_ERROR;
}

if ((ctx->flags & FLAGS_FINAL) || err)
omap_sham_cleanup(req);

clk_disable(dd->iclk);
dd->flags &= ~FLAGS_BUSY;

Expand Down Expand Up @@ -809,22 +801,21 @@ static int omap_sham_final_shash(struct ahash_request *req)
static int omap_sham_final(struct ahash_request *req)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
int err = 0;

ctx->flags |= FLAGS_FINUP;

if (!(ctx->flags & FLAGS_ERROR)) {
/* OMAP HW accel works only with buffers >= 9 */
/* HMAC is always >= 9 because of ipad */
if ((ctx->digcnt + ctx->bufcnt) < 9)
err = omap_sham_final_shash(req);
else if (ctx->bufcnt)
return omap_sham_enqueue(req, OP_FINAL);
}
if (ctx->flags & FLAGS_ERROR)
return 0; /* uncompleted hash is not needed */

omap_sham_cleanup(req);
/* OMAP HW accel works only with buffers >= 9 */
/* HMAC is always >= 9 because ipad == block size */
if ((ctx->digcnt + ctx->bufcnt) < 9)
return omap_sham_final_shash(req);
else if (ctx->bufcnt)
return omap_sham_enqueue(req, OP_FINAL);

return err;
/* copy ready hash (+ finalize hmac) */
return omap_sham_finish(req);
}

static int omap_sham_finup(struct ahash_request *req)
Expand Down

0 comments on commit 12e78ec

Please sign in to comment.