From: Stephan Mueller <smueller@chronox.de>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Eric Biggers <ebiggers@kernel.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: ARM CE: CTS IV handling
Date: Tue, 19 May 2020 20:11:33 +0200 [thread overview]
Message-ID: <1997915.ptA6GT1cFu@tauon.chronox.de> (raw)
In-Reply-To: <CAMj1kXEiijbgq=P53+qKjEzuneiinDbwyBacpMWtcN2YwEKWKA@mail.gmail.com>
Am Dienstag, 19. Mai 2020, 19:53:57 CEST schrieb Ard Biesheuvel:
Hi Ard,
> On Tue, 19 May 2020 at 19:50, Ard Biesheuvel <ardb@kernel.org> wrote:
> > On Tue, 19 May 2020 at 19:35, Stephan Mueller <smueller@chronox.de> wrote:
> > > Am Dienstag, 19. Mai 2020, 18:21:01 CEST schrieb Ard Biesheuvel:
> > >
> > > Hi Ard,
> > >
> > > > To be honest, this looks like the API is being used incorrectly. Is
> > > > this a similar issue to the one Herbert spotted recently with the CTR
> > > > code?
> > > >
> > > > When you say 'leaving the TFM untouched' do you mean the skcipher
> > > > request? The TFM should not retain any per-request state in the first
> > > > place.
> > > >
> > > > The skcipher request struct is not meant to retain any state either -
> > > > the API simply does not support incremental encryption if the input is
> > > > not a multiple of the chunksize.
> > > >
> > > > Could you give some sample code on how you are using the API in this
> > > > case?
> > >
> > > What I am doing technically is to allocate a new tfm and request at the
> > > beginning and then reuse the TFM and request. In that sense, I think I
> > > violate that constraint.
> > >
> > > But in order to implement such repetition, I can surely clear / allocate
> > > a new TFM. But in order to get that right, I need the resulting IV
> > > after the cipher operation.
> > >
> > > This IV that I get after the cipher operation completes is different
> > > between C and CE.
> >
> > So is the expected output IV simply the last block of ciphertext that
> > was generated (as usual), but located before the truncated block in
> > the output?
>
> If so, does the below fix the encrypt case?
I think it is.
But, allow me to take that patch to my test system for verification.
>
> index cf618d8f6cec..22f190a44689 100644
> --- a/arch/arm64/crypto/aes-modes.S
> +++ b/arch/arm64/crypto/aes-modes.S
> @@ -275,6 +275,7 @@ AES_FUNC_START(aes_cbc_cts_encrypt)
> add x4, x0, x4
> st1 {v0.16b}, [x4] /* overlapping
> stores */ st1 {v1.16b}, [x0]
> + st1 {v1.16b}, [x5]
> ret
> AES_FUNC_END(aes_cbc_cts_encrypt)
Ciao
Stephan
prev parent reply other threads:[~2020-05-19 18:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 15:31 ARM CE: CTS IV handling Stephan Mueller
2020-05-19 16:21 ` Ard Biesheuvel
2020-05-19 17:35 ` Stephan Mueller
2020-05-19 17:50 ` Ard Biesheuvel
2020-05-19 17:53 ` Ard Biesheuvel
2020-05-19 18:11 ` Stephan Mueller [this message]
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=1997915.ptA6GT1cFu@tauon.chronox.de \
--to=smueller@chronox.de \
--cc=ard.biesheuvel@linaro.org \
--cc=ardb@kernel.org \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
/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