Re: [PATCH] crypto: gcm - fix cacheline sharing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 30 May 2019 at 15:53, Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> wrote:
>
> On Thu, 30 May 2019 at 15:45, Iuliana Prodan <iuliana.prodan@xxxxxxx> wrote:
> >
> > On 5/30/2019 4:34 PM, Herbert Xu wrote:
> > > On Thu, May 30, 2019 at 01:29:41PM +0000, Iuliana Prodan wrote:
> > >>
> > >> I've tried coping the IV before the extended descriptor allocation, but
> > >> is not working and to make it work will need to make more changes in
> > >> CAAM. We need the original iv, and if we move it before
> > >> skcipher_edesc_alloc we lose it.
> > >> The fix exclusively in CAAM drv, to copy iv before DMA map, is more complex.
> > >
> > > Why doesn't it work (apart from the fact that this only makes sense
> > > for CBC and yet you're doing it for everything including CTR)?
> > >
> > > Cheers,
> > >
> >
> > On the current structure of caamalg, to work, iv needs to be copied
> > before memcpy(iv, req->iv, ivsize), from skcipher_edesc_alloc function.
> > For this we need edesc, but this cannot be allocated before knowing how
> > much memory we need. So, to make it work, we'll need to modify more in CAAM.
> >
>
> Would this work?
>
> diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
> index c0ece44f303b..2ef2f76a3cb8 100644
> --- a/drivers/crypto/caam/caamalg.c
> +++ b/drivers/crypto/caam/caamalg.c
> @@ -1832,22 +1832,25 @@ static int skcipher_decrypt(struct
> skcipher_request *req)
>         struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
>         int ivsize = crypto_skcipher_ivsize(skcipher);
>         struct device *jrdev = ctx->jrdev;
> +       u8 out_iv[AES_BLOCK_SIZE];
>         u32 *desc;
>         int ret = 0;
>
> -       /* allocate extended descriptor */
> -       edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ);
> -       if (IS_ERR(edesc))
> -               return PTR_ERR(edesc);
> -
>         /*
>          * The crypto API expects us to set the IV (req->iv) to the last
>          * ciphertext block.
>          */
>         if (ivsize)
> -               scatterwalk_map_and_copy(req->iv, req->src, req->cryptlen -
> +               scatterwalk_map_and_copy(out_iv, req->src, req->cryptlen -
>                                          ivsize, ivsize, 0);
>
> +       /* allocate extended descriptor */
> +       edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ);
> +       if (IS_ERR(edesc))
> +               return PTR_ERR(edesc);
> +
> +       memcpy(req->iv, out_iv, ivsize);
> +
>         /* Create and submit job descriptor*/
>         init_skcipher_job(req, edesc, false);
>         desc = edesc->hw_desc;

Umm never mind

/me hides in shame



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux