[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <xn3on5azk5ip4x365mz52ejoxlfls63ykhhz4nautyeafd3fo3@ei5v476jxuyz>
Date: Sun, 7 Dec 2025 20:29:37 -0500
From: Daniel Hodges <daniel@...ielhodges.dev>
To: Song Liu <song@...nel.org>
Cc: Daniel Hodges <git@...ielhodges.dev>, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, vadim.fedorenko@...ux.dev,
martin.lau@...ux.dev, eddyz87@...il.com, yonghong.song@...ux.dev,
john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me, haoluo@...gle.com,
jolsa@...nel.org, herbert@...dor.apana.org.au, davem@...emloft.net,
shuah@...nel.org, bpf@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 1/5] crypto: Add BPF hash algorithm type
registration module
On Fri, Dec 05, 2025 at 05:00:47PM -0800, Song Liu wrote:
> On Fri, Dec 5, 2025 at 9:40 AM Daniel Hodges <git@...ielhodges.dev> wrote:
> >
> > Add bpf_crypto_shash module that registers a hash type with the BPF
> > crypto infrastructure, enabling BPF programs to access kernel hash
> > algorithms through a unified interface.
> >
> > Update the bpf_crypto_type interface with hash-specific callbacks:
> > - alloc_tfm: Allocates crypto_shash context with proper descriptor size
> > - free_tfm: Releases hash transform and context memory
> > - has_algo: Checks algorithm availability via crypto_has_shash()
> > - hash: Performs single-shot hashing via crypto_shash_digest()
> > - digestsize: Returns the output size for the hash algorithm
> > - get_flags: Exposes transform flags to BPF programs
> >
> > Update bpf_shash_ctx to contain crypto_shash transform and shash_desc
> > descriptor to accommodate algorithm-specific descriptor requirements.
> >
> > Signed-off-by: Daniel Hodges <git@...ielhodges.dev>
> > ---
> > crypto/Makefile | 3 ++
> > crypto/bpf_crypto_shash.c | 94 +++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 97 insertions(+)
> > create mode 100644 crypto/bpf_crypto_shash.c
> >
> > diff --git a/crypto/Makefile b/crypto/Makefile
> > index 16a35649dd91..853dff375906 100644
> > --- a/crypto/Makefile
> > +++ b/crypto/Makefile
> > @@ -30,6 +30,9 @@ obj-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o
> > crypto_hash-y += ahash.o
> > crypto_hash-y += shash.o
> > obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
> > +ifeq ($(CONFIG_BPF_SYSCALL),y)
> > +obj-$(CONFIG_CRYPTO_HASH2) += bpf_crypto_shash.o
> > +endif
> >
> > obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
> > obj-$(CONFIG_CRYPTO_SIG2) += sig.o
> > diff --git a/crypto/bpf_crypto_shash.c b/crypto/bpf_crypto_shash.c
> > new file mode 100644
> > index 000000000000..39032e7dd602
> > --- /dev/null
> > +++ b/crypto/bpf_crypto_shash.c
> > @@ -0,0 +1,94 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +#include <linux/types.h>
> > +#include <linux/module.h>
> > +#include <linux/bpf_crypto.h>
> > +#include <crypto/hash.h>
> > +
> > +struct bpf_shash_ctx {
> > + struct crypto_shash *tfm;
> > + struct shash_desc desc;
> > +};
>
> Instead of adding bpf_shash_ctx and bpf_ecdsa_ctx, can we extend
> bpf_crypto_ctx to cover all hash and ECDSA? bpf_crypto_ctx has a
> const pointer to bpf_crypto_type, so this should be possible?
>
> Thanks,
> Song
Sounds good!
Powered by blists - more mailing lists