linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Cabiddu, Giovanni" <giovanni.cabiddu@intel.com>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH 2/3] crypto: acomp - Add setparam interface
Date: Wed, 7 May 2025 10:16:44 -0700	[thread overview]
Message-ID: <20250507171644.GB181648@sol> (raw)
In-Reply-To: <aBrDihaynGkKIFj8@gondor.apana.org.au>

On Wed, May 07, 2025 at 10:20:58AM +0800, Herbert Xu wrote:
> On Tue, May 06, 2025 at 05:01:27PM +0100, Cabiddu, Giovanni wrote:
> >
> > > diff --git a/crypto/acompress.c b/crypto/acompress.c
> > > index 6fdf0ff9f3c0..cf37243a2a3c 100644
> > > --- a/crypto/acompress.c
> > > +++ b/crypto/acompress.c
> > ...
> > > +int crypto_acomp_setparam(struct crypto_acomp *tfm, const u8 *param,
> > > +			  unsigned int len)
> > Is the intent here to use strings to identify parameters? In such case,
> > `len` should be called `value`.
> > Or, is `param` a pointer to a structure?
> 
> param is just an arbitrary buffer with a length.  It's up to each
> algorithm to put an interpretation on param.
> 
> But I would recommend going with the existing Crypto API norm of
> using rtnl serialisation.
> 
> For example the existing struct zcomp_params (for zstd) would then
> look like this under rtnl (copied from authenc):
> 
> 	struct rtattr *rta = (struct rtattr *)param;
> 	struct crypto_zstd_param {
> 		__le32 dictlen;
> 		__le32 level;
> 	};
> 
> 	struct crypto_zstd_param *zstd_param;
> 
> 	if (!RTA_OK(rta, keylen))
> 		return -EINVAL;
> 	if (rta->rta_type != CRYPTO_AUTHENC_ZSTD_PARAM)
> 		return -EINVAL;
> 
> 	if (RTA_PAYLOAD(rta) != sizeof(*param))
> 		return -EINVAL;
> 
> 	zstd_param = RTA_DATA(rta);
> 	dictlen = le32_to_cpu(zstd_param->dictlen);
> 	level = le32_to_cpu(zstd_param->level);
> 
> 	param += rta->rta_len;
> 	len -= rta->rta_len;
> 
> 	if (len < dictlen)
> 		return -EINVAL;
> 
> 	dict = param;

That sounds crazy.  There's no need to serialize and deserialize byte streams
just for different parts of the kernel to talk to each other.

I'm still skeptical about the whole idea of trying to force people to go through
the Crypto API for compression.  It just results in the adoption of all the bad
ideas from the Crypto API.

- Eric

  parent reply	other threads:[~2025-05-07 17:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-20 11:04 [PATCH 0/3] crypto: acomp - Add interface to set parameters Herbert Xu
2024-05-20 11:04 ` [PATCH 1/3] crypto: scomp - Add setparam interface Herbert Xu
2024-05-31  5:47   ` Sergey Senozhatsky
2024-05-31  6:34     ` Sergey Senozhatsky
2024-05-31  8:29       ` Herbert Xu
2024-06-01  0:24         ` Sergey Senozhatsky
2024-06-01  3:54           ` Herbert Xu
2024-06-03  2:34             ` Sergey Senozhatsky
2024-06-03  8:28               ` Sergey Senozhatsky
2024-06-03  8:34                 ` Herbert Xu
2024-06-04  5:09                   ` Sergey Senozhatsky
2024-06-04  8:48                     ` Herbert Xu
2024-05-31  8:30     ` Herbert Xu
2024-05-20 11:04 ` [PATCH 2/3] crypto: acomp " Herbert Xu
2025-05-06 16:01   ` Cabiddu, Giovanni
2025-05-07  2:20     ` Herbert Xu
2025-05-07 13:16       ` Cabiddu, Giovanni
2025-05-08  5:01         ` Sergey Senozhatsky
2025-05-07 17:16       ` Eric Biggers [this message]
2025-05-08  5:42         ` Sergey Senozhatsky
2025-05-08 19:21           ` Kanchana P Sridhar
2024-05-20 11:04 ` [PATCH 3/3] crypto: acomp - Add comp_params helpers Herbert Xu
2024-05-31  5:49   ` Sergey Senozhatsky
2024-05-31  8:32     ` Herbert Xu
2024-05-31  5:07 ` [PATCH 0/3] crypto: acomp - Add interface to set parameters Herbert Xu
2024-05-31  5:12   ` Sergey Senozhatsky
2024-05-31  5:18     ` Sergey Senozhatsky

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=20250507171644.GB181648@sol \
    --to=ebiggers@kernel.org \
    --cc=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    /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;
as well as URLs for NNTP newsgroup(s).