[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZWmnAPlJrkaNE4QF@gondor.apana.org.au>
Date: Fri, 1 Dec 2023 17:27:28 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: LeoLiu-oc <LeoLiu-oc@...oxin.com>
Cc: davem@...emloft.net, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, dave.hansen@...ux.intel.com, x86@...nel.org,
hpa@...or.com, seanjc@...gle.com, kim.phillips@....com,
pbonzini@...hat.com, babu.moger@....com,
jiaxi.chen@...ux.intel.com, jmattson@...gle.com,
pawan.kumar.gupta@...ux.intel.com, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, CobeChen@...oxin.com,
TonyWWang@...oxin.com, YunShen@...oxin.com, Leoliu@...oxin.com
Subject: Re: [PATCH v3] crypto: x86/sm2 -add Zhaoxin SM2 algorithm
implementation
On Wed, Nov 22, 2023 at 02:43:55PM +0800, LeoLiu-oc wrote:
> From: LeoLiuoc <LeoLiu-oc@...oxin.com>
>
> Add support for SM2 (ShangMi 2) public key algorithm by Zhaoxin GMI
> Instruction. The purpose of this driver is to ensure that the application
> has both high performance and high security.
>
> ---
>
> v1 -> v2:
> 1. The assembly code is modified to be embedded in the .c file.
> 2. Optimize code style and details.
>
> v2 -> v3:
> 1. Increase compatibility with i386 architecture.
> 2. Optimize variable and return value types in some functions..
>
> Signed-off-by: LeoLiuoc <LeoLiu-oc@...oxin.com>
> ---
> arch/x86/crypto/Kconfig | 11 ++
> arch/x86/crypto/Makefile | 2 +
> arch/x86/crypto/sm2-zhaoxin-gmi_glue.c | 158 +++++++++++++++++++++++++
> arch/x86/include/asm/cpufeatures.h | 2 +
> 4 files changed, 173 insertions(+)
> create mode 100644 arch/x86/crypto/sm2-zhaoxin-gmi_glue.c
>
> diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig
> index 9bbfd01cfa2f..974d4c3806ff 100644
> --- a/arch/x86/crypto/Kconfig
> +++ b/arch/x86/crypto/Kconfig
> @@ -519,4 +519,15 @@ config CRYPTO_CRCT10DIF_PCLMUL
> Architecture: x86_64 using:
> - PCLMULQDQ (carry-less multiplication)
>
> +config CRYPTO_SM2_ZHAOXIN_GMI
> + tristate "SM2 Cipher algorithm (Zhaoxin GMI Instruction)"
> + depends on X86 && (CPU_SUP_CENTAUR || CPU_SUP_ZHAOXIN)
> + select CRYPTO_AKCIPHER
> + select CRYPTO_MANAGER
Why does this depend on CRYPTO_MANAGER?
> +static int zhaoxin_sm2_verify(struct akcipher_request *req)
> +{
> + struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
> + struct sm2_cipher_data *ec = akcipher_tfm_ctx(tfm);
> + unsigned char *buffer;
> + int ret, buf_len;
> +
> + buf_len = req->src_len + req->dst_len;
What if this overflows? I know you copied this from the generic sm2
code, but that's still broken and both should be fixed up.
Thanks,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists