lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <18fdaf2c-827e-8d17-1eb7-cb1c12d15808@huawei.com>
Date:   Fri, 31 Dec 2021 15:05:31 +0800
From:   liulongfang <liulongfang@...wei.com>
To:     Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        Vitaly Chikunov <vt@...linux.org>,
        Eric Biggers <ebiggers@...gle.com>,
        "Eric Biggers" <ebiggers@...nel.org>,
        Gilad Ben-Yossef <gilad@...yossef.com>,
        "Ard Biesheuvel" <ardb@...nel.org>,
        Jussi Kivilinna <jussi.kivilinna@....fi>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, <linux-crypto@...r.kernel.org>,
        <x86@...nel.org>, <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] crypto: arm64/sm3-ce - make dependent on sm3
 library

On 2021/12/22 12:50, Tianjia Zhang Wrote:
> SM3 generic library is stand-alone implementation, sm3-ce can depend
> on the SM3 library instead of sm3-generic.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
> ---
>  arch/arm64/crypto/Kconfig       |  2 +-
>  arch/arm64/crypto/sm3-ce-glue.c | 20 ++++++++++++++------
>  2 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig
> index addfa413650b..2a965aa0188d 100644
> --- a/arch/arm64/crypto/Kconfig
> +++ b/arch/arm64/crypto/Kconfig
> @@ -45,7 +45,7 @@ config CRYPTO_SM3_ARM64_CE
>  	tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)"
>  	depends on KERNEL_MODE_NEON
>  	select CRYPTO_HASH
> -	select CRYPTO_SM3
> +	select CRYPTO_LIB_SM3
>  
>  config CRYPTO_SM4_ARM64_CE
>  	tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)"
> diff --git a/arch/arm64/crypto/sm3-ce-glue.c b/arch/arm64/crypto/sm3-ce-glue.c
> index d71faca322f2..3198f31c9446 100644
> --- a/arch/arm64/crypto/sm3-ce-glue.c
> +++ b/arch/arm64/crypto/sm3-ce-glue.c
> @@ -27,7 +27,7 @@ static int sm3_ce_update(struct shash_desc *desc, const u8 *data,
>  			 unsigned int len)
>  {
>  	if (!crypto_simd_usable())
> -		return crypto_sm3_update(desc, data, len);
> +		return sm3_update(shash_desc_ctx(desc), data, len);
>  
>  	kernel_neon_begin();
>  	sm3_base_do_update(desc, data, len, sm3_ce_transform);
> @@ -39,7 +39,7 @@ static int sm3_ce_update(struct shash_desc *desc, const u8 *data,
>  static int sm3_ce_final(struct shash_desc *desc, u8 *out)
>  {
>  	if (!crypto_simd_usable())
> -		return crypto_sm3_finup(desc, NULL, 0, out);
> +		return sm3_final(shash_desc_ctx(desc), out);
>  
>  	kernel_neon_begin();
>  	sm3_base_do_finalize(desc, sm3_ce_transform);
> @@ -51,14 +51,22 @@ static int sm3_ce_final(struct shash_desc *desc, u8 *out)
>  static int sm3_ce_finup(struct shash_desc *desc, const u8 *data,
>  			unsigned int len, u8 *out)
>  {
> -	if (!crypto_simd_usable())
> -		return crypto_sm3_finup(desc, data, len, out);
> +	if (!crypto_simd_usable()) {
> +		struct sm3_state *sctx = shash_desc_ctx(desc);
> +
> +		if (len)
> +			sm3_update(sctx, data, len);
> +		sm3_final(sctx, out);
> +		return 0;
> +	}
>  
>  	kernel_neon_begin();
> -	sm3_base_do_update(desc, data, len, sm3_ce_transform);
> +	if (len)
> +		sm3_base_do_update(desc, data, len, sm3_ce_transform);
> +	sm3_base_do_finalize(desc, sm3_ce_transform);
>  	kernel_neon_end();
>  
> -	return sm3_ce_final(desc, out);
> +	return sm3_base_finish(desc, out);
>  }
>  
>  static struct shash_alg sm3_alg = {
>You have modified the implementation of SM3 algorithm, so what benefits will be gained
after such modification?
What flaws are solved or can performance be improved?
Thanks.
Longfang.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ