Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2973633e authored by Antoine Tenart's avatar Antoine Tenart Committed by Herbert Xu
Browse files

crypto: inside-secure - do not use areq->result for partial results



This patches update the SafeXcel driver to stop using the crypto
ahash_request result field for partial results (i.e. on updates).
Instead the driver local safexcel_ahash_req state field is used, and
only on final operations the ahash_request result buffer is updated.

Fixes: 1b44c5a6 ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver")
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 7cad2fab
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ struct safexcel_ahash_req {
	bool needs_inv;

	u8 state_sz;    /* expected sate size, only set once */
	u32 state[SHA256_DIGEST_SIZE / sizeof(u32)];
	u32 state[SHA256_DIGEST_SIZE / sizeof(u32)] __aligned(sizeof(u32));

	u64 len;
	u64 processed;
@@ -128,7 +128,7 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int rin
	struct ahash_request *areq = ahash_request_cast(async);
	struct crypto_ahash *ahash = crypto_ahash_reqtfm(areq);
	struct safexcel_ahash_req *sreq = ahash_request_ctx(areq);
	int cache_len, result_sz = sreq->state_sz;
	int cache_len;

	*ret = 0;

@@ -149,8 +149,8 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int rin
	spin_unlock_bh(&priv->ring[ring].egress_lock);

	if (sreq->finish)
		result_sz = crypto_ahash_digestsize(ahash);
	memcpy(sreq->state, areq->result, result_sz);
		memcpy(areq->result, sreq->state,
		       crypto_ahash_digestsize(ahash));

	dma_unmap_sg(priv->dev, areq->src,
		     sg_nents_for_len(areq->src, areq->nbytes), DMA_TO_DEVICE);
@@ -274,7 +274,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring,
	/* Add the token */
	safexcel_hash_token(first_cdesc, len, req->state_sz);

	ctx->base.result_dma = dma_map_single(priv->dev, areq->result,
	ctx->base.result_dma = dma_map_single(priv->dev, req->state,
					      req->state_sz, DMA_FROM_DEVICE);
	if (dma_mapping_error(priv->dev, ctx->base.result_dma)) {
		ret = -EINVAL;