lkml.org 
[lkml]   [2024]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/3] crypto: stm32/cryp - use dma when possible.
On Tue, Apr 23, 2024 at 05:14:07PM +0200, Maxime MERE wrote:
>
> @@ -1239,12 +1758,35 @@ static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq)
> struct stm32_cryp_ctx *ctx = crypto_skcipher_ctx(
> crypto_skcipher_reqtfm(req));
> struct stm32_cryp *cryp = ctx->cryp;
> + int ret;
>
> if (!cryp)
> return -ENODEV;
>
> - return stm32_cryp_prepare_req(req, NULL) ?:
> - stm32_cryp_cpu_start(cryp);
> + ret = stm32_cryp_prepare_req(req, NULL);
> + if (ret)
> + return ret;
> +
> + /* Avoid to use DMA if peripheral 32 bit counter is about to overflow with ctr(aes) */
> + if (is_aes(cryp) && is_ctr(cryp)) {
> + u32 iv_overflow[4];
> +
> + memcpy(iv_overflow, req->iv, sizeof(__be32) * 4);
> + iv_overflow[3] = 0xffffffff - be32_to_cpu((__be32)iv_overflow[3]);

This triggers a new warning:

./drivers/crypto/stm32/stm32-cryp.c:1775:47: warning: cast to restricted __be32

The logic seems to be broken as the counter counts blocks but you're
testing against bytes (req->src->length)? What's more req->src->length
isn't even the length of the request as it's clamped by req->cryptlen.

Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2024-05-03 12:52    [W:0.095 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site