From: Eric Biggers <ebiggers@kernel.org>
To: Simon Richter <Simon.Richter@hogyros.de>
Cc: Thomas Huth <thuth@redhat.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
Simo Sorce <simo@redhat.com>
Subject: Re: [PATCH v2 1/9] crypto: Provide a wrapper for zeroizing crypto_aes_ctx
Date: Mon, 3 Aug 2026 19:37:14 -0700 [thread overview]
Message-ID: <20260804023714.GA1940@sol> (raw)
In-Reply-To: <d7764cb3-152e-4b52-bed3-d23b45fce540@hogyros.de>
On Tue, Aug 04, 2026 at 11:21:30AM +0900, Simon Richter wrote:
> Hi,
>
> On 8/4/26 4:05 AM, Eric Biggers wrote:
>
> > I guess we should start using __cleanup with type-specific zeroization
> > functions like this more often.
> Frame challenge: should key material be copied that often that we need a
> mechanism to keep track of it?
This seems to be yet another case where you are responding to some
thread and trying to start a mostly unrelated discussion.
There are many cases where data on the stack can be sensitive, and this
has always been the case. If __cleanup helps to manage such data, it's
probably worth using more often.
> My feeling is that this wasn't a conscious decision, but is the result of
> two other decisions (that individually make sense): contexts need to be
> self-contained (so need to include key material), and context creation
> should be cheap (so stack contexts are allowed).
The entire point of "crypto_aes_ctx" is that it is an expanded AES key.
The callers of it are using it to compute the round keys.
If you're actually referring to the contexts for per-message incremental
calculation (e.g. sha256_ctx) offered by the library API, those are a
bit different. Sometimes they contain key material, sometimes they
don't. Even if the algorithm is unkeyed, it may still contain key
material, since the user could be hashing a key. Either way, the
finalization function for each algorithm zeroizes it. The caller needs
to zeroize only if it abandons a context without zeroizing it.
> 2. allow contexts to refer to key material stored elsewhere to avoid the
> copy. That opens the lifetime tracking can of worms, but the on-stack crypto
> context is rather short-lived.
That is already what is being done in most cases. The exception is the
HMAC library code since the 'ostate' is not very large. But again the
per-message contexts are supposed to be zeroized anyway. Also, if the
one-shot functions are used, then no context is exposed to the caller...
- Eric
next prev parent reply other threads:[~2026-08-04 2:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 9:44 [PATCH v2 0/9] crypto: Provide a function for zeroizing crypto_aes_ctx Thomas Huth
2026-08-03 9:44 ` [PATCH v2 1/9] crypto: Provide a wrapper " Thomas Huth
2026-08-03 19:05 ` Eric Biggers
2026-08-04 2:21 ` Simon Richter
2026-08-04 2:37 ` Eric Biggers [this message]
2026-08-04 7:42 ` Thomas Huth
2026-08-04 18:54 ` Eric Biggers
2026-08-03 9:44 ` [PATCH v2 2/9] crypto: aspeed - clear the crypto_aes_ctx when done Thomas Huth
2026-08-03 9:44 ` [PATCH v2 3/9] crypto: inside-secure/eip93 " Thomas Huth
2026-08-03 9:44 ` [PATCH v2 4/9] crypto: padlock-aes " Thomas Huth
2026-08-03 9:44 ` [PATCH v2 5/9] crypto: sa2ul " Thomas Huth
2026-08-03 9:44 ` [PATCH v2 6/9] crypto: arm/aes-neonbs " Thomas Huth
2026-08-03 9:44 ` [PATCH v2 7/9] crypto: arm64/aes-neonbs " Thomas Huth
2026-08-03 9:44 ` [PATCH v2 8/9] crypto: safexcel - zeroize crypto_aes_ctx with __cleanup(aes_clear_ctx) Thomas Huth
2026-08-03 9:44 ` [PATCH v2 9/9] crypto: qat " Thomas Huth
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=20260804023714.GA1940@sol \
--to=ebiggers@kernel.org \
--cc=Simon.Richter@hogyros.de \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simo@redhat.com \
--cc=thuth@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.