From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Vadim Fedorenko <vadfed@meta.com>,
Jakub Kicinski <kuba@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Andrii Nakryiko <andrii@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Mykola Lysenko <mykolal@fb.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Network Development <netdev@vger.kernel.org>,
Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v5 1/2] bpf: add skcipher API support to TC/XDP programs
Date: Mon, 20 Nov 2023 00:22:41 +0000 [thread overview]
Message-ID: <c1e3db50-50bd-d728-a911-58fa1c77506a@linux.dev> (raw)
In-Reply-To: <CAADnVQLKsOs7LSFWGbAtJ8WfZjnQ0B_7gwFA-ZMdLPmukMGZ1A@mail.gmail.com>
On 19.11.2023 16:56, Alexei Starovoitov wrote:
> On Sat, Nov 18, 2023 at 3:46 PM Vadim Fedorenko
> <vadim.fedorenko@linux.dev> wrote:
>>
>> On 18/11/2023 18:35, Alexei Starovoitov wrote:
>>> On Sat, Nov 18, 2023 at 3:32 PM Vadim Fedorenko
>>> <vadim.fedorenko@linux.dev> wrote:
>>>>
>>>> On 18/11/2023 18:23, Alexei Starovoitov wrote:
>>>>> On Sat, Nov 18, 2023 at 2:55 PM Vadim Fedorenko <vadfed@meta.com> wrote:
>>>>>>
>>>>>> +/**
>>>>>> + * struct bpf_crypto_lskcipher_ctx - refcounted BPF sync skcipher context structure
>>>>>> + * @tfm: The pointer to crypto_sync_skcipher struct.
>>>>>> + * @rcu: The RCU head used to free the crypto context with RCU safety.
>>>>>> + * @usage: Object reference counter. When the refcount goes to 0, the
>>>>>> + * memory is released back to the BPF allocator, which provides
>>>>>> + * RCU safety.
>>>>>> + */
>>>>>> +struct bpf_crypto_lskcipher_ctx {
>>>>>> + struct crypto_lskcipher *tfm;
>>>>>> + struct rcu_head rcu;
>>>>>> + refcount_t usage;
>>>>>> +};
>>>>>> +
>>>>>> +__bpf_kfunc_start_defs();
>>>>>> +
>>>>>> +/**
>>>>>> + * bpf_crypto_lskcipher_ctx_create() - Create a mutable BPF crypto context.
>>>>>
>>>>> Let's drop 'lskcipher' from the kfunc names and ctx struct.
>>>>> bpf users don't need to know the internal implementation details.
>>>>> bpf_crypto_encrypt/decrypt() is clear enough.
>>>>
>>>> The only reason I added it was the existence of AEAD subset of crypto
>>>> API. And this subset can also be implemented in bpf later, and there
>>>> will be inconsistency in naming then if we add aead in future names.
>>>> WDYT?
>>>
>>> You mean future async apis ? Just bpf_crypto_encrypt_async() ?
>>
>> Well, not only async. It's about Authenticated Encryption With
>> Associated Data (AEAD) Cipher API defined in crypto/aead.h. It's
>> ciphers with additional hmac function, like
>> 'authenc(hmac(sha256),cbc(aes))'. It has very similar API with only
>> difference of having Authenticated data in the encrypted block.
>
> and ? I'm not following what you're trying to say.
> Where is the inconsistency ?
> My point again is that lskcipher vs skcipher vs foo is an implementation
> detail that shouldn't be exposed in the name.
Well, I was trying to follow crypto subsystem naming. It might be easier for
users to understand what part of crypto API is supported by BPF kfuncs.
At the same we can agree that current implementation will be used for simple
buffer encryption/decryption and any further implementations will have additions
in the name of functions (like
bpf_crypto_aead_crypt/bpf_crypto_shash_final/bpf_crypto_scomp_compress).
It will be slightly inconsistent, but we will have to expose some implementation
details unfortunately. If you are ok with this way, I'm ok to implement it.
next prev parent reply other threads:[~2023-11-20 0:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 22:54 [PATCH bpf-next v5 1/2] bpf: add skcipher API support to TC/XDP programs Vadim Fedorenko
2023-11-18 22:54 ` [PATCH bpf-next v5 2/2] selftests: bpf: crypto skcipher algo selftests Vadim Fedorenko
2023-11-19 21:58 ` Alexei Starovoitov
2023-11-19 23:52 ` Vadim Fedorenko
2023-11-18 23:23 ` [PATCH bpf-next v5 1/2] bpf: add skcipher API support to TC/XDP programs Alexei Starovoitov
2023-11-18 23:32 ` Vadim Fedorenko
2023-11-18 23:35 ` Alexei Starovoitov
2023-11-18 23:46 ` Vadim Fedorenko
2023-11-19 16:56 ` Alexei Starovoitov
2023-11-20 0:22 ` Vadim Fedorenko [this message]
2023-11-20 1:13 ` Alexei Starovoitov
2023-11-20 18:08 ` Vadim Fedorenko
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=c1e3db50-50bd-d728-a911-58fa1c77506a@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=vadfed@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox