From: Eric Biggers <ebiggers@kernel.org>
To: Mike Lothian <mike@fireburn.co.uk>
Cc: linux-crypto@vger.kernel.org, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
dakr@kernel.org, daniel.almeida@collabora.com, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev, lyude@redhat.com,
gregkh@linuxfoundation.org, lina+kernel@asahilina.net,
mmaurer@google.com, ljs@kernel.org, joelagnelf@nvidia.com,
bqe@google.com, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v3 1/2] rust: crypto: add AES-128, AES-CMAC, SHA-256, and HMAC bindings
Date: Mon, 31 Aug 2026 17:05:46 +0000 [thread overview]
Message-ID: <20260831170546.GA239479@google.com> (raw)
In-Reply-To: <CAHbf0-H-nZzg=kGkN-yrUdfUUrruyN0x2inQjhXxOy4RAauDOg@mail.gmail.com>
On Mon, Aug 31, 2026 at 05:51:11PM +0100, Mike Lothian wrote:
> On Wed, 26 Aug 2026, Eric Biggers wrote:
> > There's an aes_ctr() function now.
> >
> > With that, is bare AES still needed?
>
> Not for the CTR, no. It is not in the tree this was based on --
> drm-rust-next as of 2026-08-06, where lib/crypto has aes.c, aescfb.c and
> aesgcm.c and no CTR at all -- which is why I built it out of a prepared
> key schedule instead.
>
> The driver's two CTR sites are plain SP 800-38A: a 64-bit nonce, four
> zero bytes, and a 32-bit big-endian block counter. aes_ctr() replaces
> both loops outright, and the key-schedule reuse that this patch was
> partly justifying stops mattering.
>
> That leaves exactly one caller of the bare block cipher: the HDCP 2.2
> dKey derivation, which is a single AES-128 ECB block encrypt. So the
> question I would put back to you is whether lib/crypto is willing to
> expose a one-shot single-block encrypt for that, or whether you would
> rather that one caller kept using aes_prepareenckey() and aes_encrypt()
> directly. Either way I will cut the rest of the AES from this patch.
>
> Mike
I'm not currently planning to make the crypto library expose AES
functions that take raw keys, since computing the AES round keys is
fairly slow and most users use their AES keys multiple times. So in
this case I guess keep planning to use the sequence that is already
supported: aes_prepareenckey() + aes_encrypt() + memzero_explicit().
For CTR mode, use aes_prepareenckey() + aes_ctr() + memzero_explicit().
But if you're using either key multiple times you should call
aes_prepareenckey() just once and cache the result, as that is what it
is for.
- Eric
next prev parent reply other threads:[~2026-08-31 17:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 16:29 [PATCH v3 0/2] rust: crypto: AES, CMAC, SHA-256, HMAC and RSA bindings Mike Lothian
2026-08-26 16:29 ` [PATCH v3 1/2] rust: crypto: add AES-128, AES-CMAC, SHA-256, and HMAC bindings Mike Lothian
2026-08-26 22:09 ` Eric Biggers
[not found] ` <CAHbf0-H-nZzg=kGkN-yrUdfUUrruyN0x2inQjhXxOy4RAauDOg@mail.gmail.com>
2026-08-31 17:05 ` Eric Biggers [this message]
[not found] ` <20260826163004.3365-3-mike@fireburn.co.uk>
2026-08-27 3:03 ` [PATCH v3 2/2] rust: crypto: add synchronous RSA akcipher support Eric Biggers
2026-08-27 14:46 ` Miguel Ojeda
2026-08-27 18:29 ` Eric Biggers
2026-08-27 23:00 ` Miguel Ojeda
2026-08-31 17:04 ` Mike Lothian
2026-08-27 14:59 ` Miguel Ojeda
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=20260831170546.GA239479@google.com \
--to=ebiggers@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bqe@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=joelagnelf@nvidia.com \
--cc=lina+kernel@asahilina.net \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mike@fireburn.co.uk \
--cc=mmaurer@google.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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