linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pascal Van Leeuwen <pvanleeuwen@insidesecure.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: Iuliana Prodan <iuliana.prodan@nxp.com>,
	Eric Biggers <ebiggers@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Horia Geanta <horia.geanta@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	"open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
	<linux-crypto@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: RE: [PATCH] crypto: gcm - fix cacheline sharing
Date: Thu, 30 May 2019 14:29:26 +0000	[thread overview]
Message-ID: <AM6PR09MB3523C09EFDE90A8A8ECFCA09D2180@AM6PR09MB3523.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <CAKv+Gu-3zzN=cikd4PftCVo2fJi9t_0kqZHBQncjokYQV5wVnA@mail.gmail.com>

> On Thu, 30 May 2019 at 15:58, Herbert Xu <herbert@gondor.apana.org.au>
> wrote:
> >
> > On Thu, May 30, 2019 at 01:45:47PM +0000, Iuliana Prodan wrote:
> > >
> > > 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.
> >
> > All the copying does is:
> >
> >         if (ivsize)
> >                 scatterwalk_map_and_copy(req->iv, req->src, req-
> >cryptlen -
> >                                          ivsize, ivsize, 0);
> >
> > Why do you need to allocate the edesc before doing this?
> >
> 
> Because that is where the incoming iv is currently consumed. Copying
> it out like this wipes the input IV from memory.

I had a similar problem for the Inside Secure driver: for decrypt operations,
you need to copy the output IV from your input data buffer (it's the last 
input data cipher block) but you need to do that *before* you start the
hardware, as for in-place operations, it is overwritten.

At the same time, you cannot store it to req->iv yet, because that still
contains the input IV that you need for processing the first block.

The only solution I could come up with, is to park it in some temporary
buffer in the skcipher_request_ctx *before* starting the hardware and copy 
it to req->iv *after* the operation completes.

Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Inside Secure
www.insidesecure.com

  reply	other threads:[~2019-05-30 14:29 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 17:10 [PATCH] crypto: gcm - fix cacheline sharing Iuliana Prodan
2019-05-29 20:27 ` Eric Biggers
2019-05-29 22:16   ` Ard Biesheuvel
2019-05-30 13:29     ` Iuliana Prodan
2019-05-30 13:34       ` Herbert Xu
2019-05-30 13:45         ` Iuliana Prodan
2019-05-30 13:53           ` Ard Biesheuvel
2019-05-30 13:55             ` Ard Biesheuvel
2019-05-30 14:27               ` Herbert Xu
2019-05-30 14:28                 ` Ard Biesheuvel
2019-05-30 14:31                   ` Ard Biesheuvel
2019-05-30 14:34                     ` Herbert Xu
2019-05-30 15:04                       ` Ard Biesheuvel
2019-05-30 15:06                         ` Herbert Xu
2019-05-30 15:10                           ` Ard Biesheuvel
2019-05-30 15:13                             ` Herbert Xu
2019-05-30 15:17                               ` Ard Biesheuvel
2019-05-30 22:00                         ` Iuliana Prodan
2019-05-31  5:54                           ` Horia Geanta
2019-05-30 14:53                     ` Pascal Van Leeuwen
2019-05-30 15:13                       ` Ard Biesheuvel
2019-06-06  6:37                     ` Herbert Xu
2019-06-06  6:42                       ` Ard Biesheuvel
2019-06-06  6:46                         ` Herbert Xu
2019-06-06  6:53                           ` Ard Biesheuvel
2019-06-06  6:57                             ` Herbert Xu
2019-06-06  7:10                               ` Horia Geanta
2019-06-06  7:15                                 ` Herbert Xu
2019-06-06  8:36                                   ` Horia Geanta
2019-06-06  9:33                                     ` Herbert Xu
2019-05-30 13:58           ` Herbert Xu
2019-05-30 14:11             ` Ard Biesheuvel
2019-05-30 14:29               ` Pascal Van Leeuwen [this message]
2019-05-30  5:34   ` Herbert Xu
2019-05-30  7:46     ` Horia Geanta
2019-05-30  8:08       ` Ard Biesheuvel
2019-05-30 13:18         ` Horia Geanta
2019-05-30 13:25           ` Ard Biesheuvel
2019-05-31  6:05             ` Horia Geanta
2019-05-30 13:26           ` Herbert Xu
2019-05-31  5:22             ` Horia Geanta
2019-05-31  5:42               ` Herbert Xu
2019-05-31  6:10                 ` Horia Geanta
2019-05-31  6:14                   ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR09MB3523C09EFDE90A8A8ECFCA09D2180@AM6PR09MB3523.eurprd09.prod.outlook.com \
    --to=pvanleeuwen@insidesecure.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=iuliana.prodan@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).