提交 898d86a5 编写于 作者: T Tero Kristo 提交者: Herbert Xu

crypto: omap-sham - fix closing of hash with separate finalize call

Currently there is an interesting corner case failure with omap-sham
driver, if the finalize call is done separately with no data, but
all previous data has already been processed. In this case, it is not
possible to close the hash with the hardware without providing any data,
so we get incorrect results. Fix this by adjusting the size of data
sent to the hardware crypto engine in case the non-final data size falls
on the block size boundary, by reducing the amount of data sent by one
full block. This makes it sure that we always have some data available
for the finalize call and we can close the hash properly.
Signed-off-by: NTero Kristo <t-kristo@ti.com>
Reported-by: NAparna Balasubramanian <aparnab@ti.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 5d78d57e
...@@ -751,7 +751,10 @@ static int omap_sham_align_sgs(struct scatterlist *sg, ...@@ -751,7 +751,10 @@ static int omap_sham_align_sgs(struct scatterlist *sg,
if (final) if (final)
new_len = DIV_ROUND_UP(new_len, bs) * bs; new_len = DIV_ROUND_UP(new_len, bs) * bs;
else else
new_len = new_len / bs * bs; new_len = (new_len - 1) / bs * bs;
if (nbytes != new_len)
list_ok = false;
while (nbytes > 0 && sg_tmp) { while (nbytes > 0 && sg_tmp) {
n++; n++;
...@@ -847,6 +850,8 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) ...@@ -847,6 +850,8 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
xmit_len = DIV_ROUND_UP(xmit_len, bs) * bs; xmit_len = DIV_ROUND_UP(xmit_len, bs) * bs;
else else
xmit_len = xmit_len / bs * bs; xmit_len = xmit_len / bs * bs;
} else if (!final) {
xmit_len -= bs;
} }
hash_later = rctx->total - xmit_len; hash_later = rctx->total - xmit_len;
...@@ -1138,7 +1143,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd, ...@@ -1138,7 +1143,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
ctx = ahash_request_ctx(req); ctx = ahash_request_ctx(req);
err = omap_sham_prepare_request(req, ctx->op == OP_UPDATE); err = omap_sham_prepare_request(req, ctx->op == OP_UPDATE);
if (err) if (err || !ctx->total)
goto err1; goto err1;
dev_dbg(dd->dev, "handling new req, op: %lu, nbytes: %d\n", dev_dbg(dd->dev, "handling new req, op: %lu, nbytes: %d\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册