[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZGd2Y/EU30Yxw6kZ@corigine.com>
Date: Fri, 19 May 2023 15:15:15 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: Dmitry Safonov <dima@...sta.com>,
Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
linux-kernel@...r.kernel.org, David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Andy Lutomirski <luto@...capital.net>,
Ard Biesheuvel <ardb@...nel.org>,
Bob Gilligan <gilligan@...sta.com>,
Dan Carpenter <error27@...il.com>,
David Laight <David.Laight@...lab.com>,
Dmitry Safonov <0x7f454c46@...il.com>,
Eric Biggers <ebiggers@...nel.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Francesco Ruggeri <fruggeri05@...il.com>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Ivan Delalande <colona@...sta.com>,
Leonard Crestez <cdleonard@...il.com>,
Salam Noureddine <noureddine@...sta.com>, netdev@...r.kernel.org
Subject: Re: [PATCH 2/3] crypto: cipher - Add crypto_clone_cipher
On Fri, May 19, 2023 at 04:28:35PM +0800, Herbert Xu wrote:
> Allow simple ciphers to be cloned, if they don't have a cra_init
> function. This basically rules out those ciphers that require a
> fallback.
>
> In future simple ciphers will be eliminated, and replaced with a
> linear skcipher interface. When that happens this restriction will
> disappear.
>
> Signed-off-by: Herbert Xu <herbert@...dor.apana.org.au>
> ---
>
> crypto/cipher.c | 23 +++++++++++++++++++++++
> include/crypto/internal/cipher.h | 2 ++
> 2 files changed, 25 insertions(+)
>
> diff --git a/crypto/cipher.c b/crypto/cipher.c
> index b47141ed4a9f..d39ef5f72ab8 100644
> --- a/crypto/cipher.c
> +++ b/crypto/cipher.c
> @@ -90,3 +90,26 @@ void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
> cipher_crypt_one(tfm, dst, src, false);
> }
> EXPORT_SYMBOL_NS_GPL(crypto_cipher_decrypt_one, CRYPTO_INTERNAL);
> +
> +struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher)
> +{
> + struct crypto_tfm *tfm = crypto_cipher_tfm(cipher);
> + struct crypto_alg *alg = tfm->__crt_alg;
> + struct crypto_cipher *ncipher;
> + struct crypto_tfm *ntfm;
> +
> + if (alg->cra_init)
> + return ERR_PTR(-ENOSYS);
Hi Herbert,
I see ENOSYS used in similar ways elsewhere in crypto/,
but it strikes me that EOPNOTSUPP may well be more appropriate.
> +
> + ntfm = __crypto_alloc_tfm(alg, CRYPTO_ALG_TYPE_CIPHER,
> + CRYPTO_ALG_TYPE_MASK);
> + if (IS_ERR(ntfm))
> + return ERR_CAST(ntfm);
> +
> + ntfm->crt_flags = tfm->crt_flags;
> +
> + ncipher = __crypto_cipher_cast(ntfm);
> +
> + return ncipher;
> +}
> +EXPORT_SYMBOL_GPL(crypto_clone_cipher);
...
Powered by blists - more mailing lists