Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1916481rdb; Sun, 19 Nov 2023 16:32:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnTprzHDt2f83daMG7XB5kUhtxhQchocOv9mgzLqdKnuKJ5Ajl4Uie4NiqvcGPS1zG919l X-Received: by 2002:a17:90b:4a0a:b0:27d:1972:136c with SMTP id kk10-20020a17090b4a0a00b0027d1972136cmr6618741pjb.38.1700440332581; Sun, 19 Nov 2023 16:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700440332; cv=none; d=google.com; s=arc-20160816; b=gRUZLopEyUb1gV0PnH3goaWfw2fBvHOFIXHRkG2WATs+KF+AtTFgRDcl1t0Yj8AnIx C4Z1M17TqfgCOaGr6yvpw5Au/CfXo+rSowT1Ob9xpYsV78LdxXmiURtHaCboGocjcO7+ e53zcYVJEemvy/1g4+2ZBPAjArGqUPU1swdIe1dpelMt5AIqZsuNlxb1Tz/qGgP1G6cV UDEbeieY1vcvSTwgEbo9FDQAATXfIzZqKxpjZeL0CccgohyMYaeXQgS2nFzm2K3qi5jz BFIqZCgbxNomeluxrVGsuHVh3KSX9UjhjJkeTl7MTLrfI847TlilerQ3mlJZXEpTv38L peHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=plyfbjXCWPnLRRVdcMszQ9r3Y0Q33cJPIt1nNRxE4Ls=; fh=BjgqlRnFgrOwhVUl8bcCHV66zzsIQxVgQ4EllNAjuB4=; b=kPzhproQrAwMLh64a/wDwnveKuz5mfN7/Jd+5wwHsizz1L6puFDnpKzPkIgfGk/uoF ZFvoAmsdSKkvrP+8BvVrfEcVx4eAqKCtiTgnfnYGIFReOxdo0To4jigFDPlVnBW811jx xQ2lkWmG8bzhu+o5tCj0TKT6Ejfe193KMMlBK4el9HRWcG1poWdxCY4oZ5HssCyZqDer xcOn1J0/jq4Cb13xH2b27zMLJ6dv2OBwRAXrqz0rd6M94qR8EqaU7k/4yG3CXNHzbCXt gmVVFs6a4cK0gEUCA+dmFWj3vzPdKhqibzH1UG3VSTYGtfjQ2F02dQAVCyV8xOip+NMk WBqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="al54fd/q"; spf=pass (google.com: domain of linux-crypto+bounces-194-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-194-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ce3-20020a17090aff0300b002800c1493c5si7057553pjb.29.2023.11.19.16.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 16:32:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-194-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="al54fd/q"; spf=pass (google.com: domain of linux-crypto+bounces-194-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-194-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1312B2809B2 for ; Mon, 20 Nov 2023 00:32:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B026E1860 for ; Mon, 20 Nov 2023 00:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="al54fd/q" X-Original-To: linux-crypto@vger.kernel.org Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BD3A107 for ; Sun, 19 Nov 2023 16:22:45 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700439764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=plyfbjXCWPnLRRVdcMszQ9r3Y0Q33cJPIt1nNRxE4Ls=; b=al54fd/qCsTxCLPQRo+bjKkW3wAmdH5oKZm4BBzBjNO+Bifq88D/CveqESwo9NuXSjruTo L4B2svHvcFPSPq+PwQa0pp/zxwhcMLNUQQRUcZqEIyYCJmIFb6H61LLbdhJwtl5x7ATUXW aD3rflQV4wt9gCRaHtCowzfgEUmw7l0= Date: Mon, 20 Nov 2023 00:22:41 +0000 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v5 1/2] bpf: add skcipher API support to TC/XDP programs Content-Language: en-US To: Alexei Starovoitov Cc: Vadim Fedorenko , Jakub Kicinski , Martin KaFai Lau , Andrii Nakryiko , Alexei Starovoitov , Mykola Lysenko , Herbert Xu , Network Development , Linux Crypto Mailing List , bpf References: <20231118225451.2132137-1-vadfed@meta.com> <862c832a-da98-4bef-80ef-8294be1d4601@linux.dev> <312531ec-aba5-4050-b236-dc9b456c7280@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 19.11.2023 16:56, Alexei Starovoitov wrote: > On Sat, Nov 18, 2023 at 3:46 PM Vadim Fedorenko > wrote: >> >> On 18/11/2023 18:35, Alexei Starovoitov wrote: >>> On Sat, Nov 18, 2023 at 3:32 PM Vadim Fedorenko >>> wrote: >>>> >>>> On 18/11/2023 18:23, Alexei Starovoitov wrote: >>>>> On Sat, Nov 18, 2023 at 2:55 PM Vadim Fedorenko 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.