Re: [v3 PATCH] crypto: chacha - Add DEFINE_CHACHA_STATE macro

2020-07-08 Thread Martin Willi
> > Also, I wonder if we shouldn't simply change the chacha code to use > > unaligned loads for the state array, as it likely makes very little > > difference in practice (the state is not accessed from inside the > > round processing loop) > > I am seeing a 0.25% slowdown on 1k blocks in the SS

Re: [PATCH v4 05/13] crypto: sun8i-ce - permit asynchronous skcipher as fallback

2020-07-08 Thread Corentin Labbe
On Tue, Jul 07, 2020 at 09:31:55AM +0300, Ard Biesheuvel wrote: > Even though the sun8i-ce driver implements asynchronous versions of > ecb(aes) and cbc(aes), the fallbacks it allocates are required to be > synchronous. Given that SIMD based software implementations are usually > asynchronous as we

[PATCH v4 5/8] crypto: testmgr - support test with different ciphertext per encryption

2020-07-08 Thread Tianjia Zhang
Some asymmetric algorithms will get different ciphertext after each encryption, such as SM2, and let testmgr support the testing of such algorithms. In struct akcipher_testvec, set c and c_size to be empty, skip the comparison of the ciphertext, and compare the decrypted plaintext with m to achiev

[PATCH v4 0/8] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm

2020-07-08 Thread Tianjia Zhang
Hello all, This new module implement the OSCCA certificate and SM2 public key algorithm. It was published by State Encryption Management Bureau, China. List of specifications for OSCCA certificate and SM2 elliptic curve public key cryptography: * GM/T 0003.1-2012 * GM/T 0003.2-2012 * GM/T 0003.3-

[PATCH v4 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm

2020-07-08 Thread Tianjia Zhang
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang --- security/integrity/digsig_asymmetric.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/security/integrity/digsig_a

[PATCH v4 7/8] X.509: support OSCCA sm2-with-sm3 certificate verification

2020-07-08 Thread Tianjia Zhang
The digital certificate format based on SM2 crypto algorithm as specified in GM/T 0015-2012. It was published by State Encryption Management Bureau, China. The method of generating Other User Information is defined as ZA=H256(ENTLA || IDA || a || b || xG || yG || xA || yA), it also specified in ht

[PATCH v4 3/8] lib/mpi: Introduce ec implementation to MPI library

2020-07-08 Thread Tianjia Zhang
The implementation of EC is introduced from libgcrypt as the basic algorithm of elliptic curve, which can be more perfectly integrated with MPI implementation. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h | 105 +++

[PATCH v4 4/8] crypto: sm2 - introduce OSCCA SM2 asymmetric cipher algorithm

2020-07-08 Thread Tianjia Zhang
This new module implement the SM2 public key algorithm. It was published by State Encryption Management Bureau, China. List of specifications for SM2 elliptic curve public key cryptography: * GM/T 0003.1-2012 * GM/T 0003.2-2012 * GM/T 0003.3-2012 * GM/T 0003.4-2012 * GM/T 0003.5-2012 IETF: https:

[PATCH v4 6/8] X.509: support OSCCA certificate parse

2020-07-08 Thread Tianjia Zhang
The digital certificate format based on SM2 crypto algorithm as specified in GM/T 0015-2012. It was published by State Encryption Management Bureau, China. This patch adds the OID object identifier defined by OSCCA. The x509 certificate supports sm2-with-sm3 type certificate parsing. It uses the s

[PATCH v4 2/8] lib/mpi: Extend the MPI library

2020-07-08 Thread Tianjia Zhang
Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on mpi ecc, such as SM2. Signed-off-by: Tianjia Zhang --- include/linux/mpi.h| 88 +++ lib/mpi/Makefile | 5 + l

[PATCH v4 1/8] crypto: sm3 - export crypto_sm3_final function

2020-07-08 Thread Tianjia Zhang
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang --- crypto/sm3_generic.c | 7 --- include/crypto/sm3.h | 2 ++ 2 files ch

question regarding crypto driver DMA issue

2020-07-08 Thread Van Leeuwen, Pascal
Hi, I have a question on behalf of a customer of ours trying to use the inside-secure crypto API driver. They are experiencing issues with result data not arriving in the result buffer. This seems to have something to do with not being able to DMA to said buffer, as they can workaround the issu

[PATCH] crypto: x86/chacha-sse3 - use unaligned loads for state array

2020-07-08 Thread Ard Biesheuvel
Due to the fact that the x86 port does not support allocating objects on the stack with an alignment that exceeds 8 bytes, we have a rather ugly hack in the x86 code for ChaCha to ensure that the state array is aligned to 16 bytes, allowing the SSE3 implementation of the algorithm to use aligned lo

Re: question regarding crypto driver DMA issue

2020-07-08 Thread Ard Biesheuvel
On Wed, 8 Jul 2020 at 11:56, Van Leeuwen, Pascal wrote: > > Hi, > > I have a question on behalf of a customer of ours trying to use the > inside-secure crypto > API driver. They are experiencing issues with result data not arriving in the > result buffer. > This seems to have something to do wit

Re: [PATCH v2 2/2] kbuild: trace functions in subdirectories of lib/

2020-07-08 Thread Petr Mladek
On Wed 2020-07-08 08:52:23, Petr Mladek wrote: > > PS: BTW: The livepatch selftests fail in Linus's master now. But it > seems to be for another reason. I am going to dig into it. JFYI, the livepatch selftests are actually working. I have messed the testing here. I am sorry for the noise. Best Re

Re: [PATCH 0/4] crypto: add sha256() function

2020-07-08 Thread Hans de Goede
Hi, On 7/7/20 8:58 PM, Eric Biggers wrote: This series adds a function sha256() to the sha256 library so that users who want to compute a hash in one step can just call sha256() instead of sha256_init() + sha256_update() + sha256_final(). Patches 2-4 then convert some users to use it. Eric Big

Re: [PATCH 3/4] mptcp: use sha256() instead of open coding

2020-07-08 Thread Matthieu Baerts
Hi Eric, On 07/07/2020 20:58, Eric Biggers wrote: From: Eric Biggers Now that there's a function that calculates the SHA-256 digest of a buffer in one step, use it instead of sha256_init() + sha256_update() + sha256_final(). Cc: mp...@lists.01.org Cc: Mat Martineau Cc: Matthieu Baerts Signe

Re: [PATCH] crypto: x86/chacha-sse3 - use unaligned loads for state array

2020-07-08 Thread Martin Willi
> Due to the fact that the x86 port does not support allocating objects > on the stack with an alignment that exceeds 8 bytes, we have a rather > ugly hack in the x86 code for ChaCha to ensure that the state array > is aligned to 16 bytes, allowing the SSE3 implementation of the > algorithm to us

RE: question regarding crypto driver DMA issue

2020-07-08 Thread Van Leeuwen, Pascal
Hi Ard, Thanks for responding! > > For the situation where this problem is occuring, the actual buffers are > > stored inside > > the ahash_req structure. So my question is: is there any reason why this > > structure may > > not be DMA-able on some systems? (as I have a hunch that may be the pr

Re: question regarding crypto driver DMA issue

2020-07-08 Thread Ard Biesheuvel
On Wed, 8 Jul 2020 at 16:35, Van Leeuwen, Pascal wrote: > > Hi Ard, > > Thanks for responding! > > > > For the situation where this problem is occuring, the actual buffers are > > > stored inside > > > the ahash_req structure. So my question is: is there any reason why this > > > structure may >

Re: [PATCH v4] mm/zswap: move to use crypto_acomp API for hardware acceleration

2020-07-08 Thread Sebastian Andrzej Siewior
On 2020-07-08 00:52:10 [+1200], Barry Song wrote: … > @@ -127,9 +129,17 @@ module_param_named(same_filled_pages_enabled, > zswap_same_filled_pages_enabled, > * data structures > **/ > > +struct crypto_acomp_ctx { > + struct crypto_acomp *acomp; > + struc

[PATCH v1] fixes

2020-07-08 Thread sven . auhagen
From: Sven Auhagen --- drivers/crypto/inside-secure/safexcel.h| 1 + drivers/crypto/inside-secure/safexcel_cipher.c | 6 +- drivers/crypto/inside-secure/safexcel_hash.c | 6 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/inside-secure/safexcel.

[PATCH 1/1] inside-secure irq balance

2020-07-08 Thread Sven Auhagen
Balance the irqs of the inside secure driver over all available cpus. Currently all interrupts are handled by the first CPU. >From my testing with IPSec AES-GCM 256 on my MCbin with 4 Cores I get a 50% speed increase: Before the patch: 99.73 Kpps With the patch: 151.25 Kpps Signed-off-by: Sven A

Re: [PATCH v1] fixes

2020-07-08 Thread Sven Auhagen
Hi, I am sorry, please ignore this email. It was send by mistake. Best Sven On Wed, Jul 08, 2020 at 05:06:05PM +0200, sven.auha...@voleatech.de wrote: > From: Sven Auhagen > > --- > drivers/crypto/inside-secure/safexcel.h| 1 + > drivers/crypto/inside-secure/safexcel_cipher.c | 6

Re: [PATCH] crypto: x86/chacha-sse3 - use unaligned loads for state array

2020-07-08 Thread Eric Biggers
On Wed, Jul 08, 2020 at 12:11:18PM +0300, Ard Biesheuvel wrote: > Due to the fact that the x86 port does not support allocating objects > on the stack with an alignment that exceeds 8 bytes, we have a rather > ugly hack in the x86 code for ChaCha to ensure that the state array is > aligned to 16 by

Re: [PATCH] crypto: caam - Remove broken arc4 support

2020-07-08 Thread Horia Geantă
On 7/6/2020 4:43 PM, Ard Biesheuvel wrote: > On Sun, 5 Jul 2020 at 22:11, Horia Geantă wrote: >> >> On 7/2/2020 7:36 AM, Herbert Xu wrote: >>> The arc4 algorithm requires storing state in the request context >>> in order to allow more than one encrypt/decrypt operation. As this >>> driver does no

[PATCH v2 2/5] crypto: lib/sha256 - add sha256() function

2020-07-08 Thread Eric Biggers
From: Eric Biggers Add a function sha256() which computes a SHA-256 digest in one step, combining sha256_init() + sha256_update() + sha256_final(). This is similar to how we also have blake2s(). Reviewed-by: Ard Biesheuvel Tested-by: Hans de Goede Signed-off-by: Eric Biggers --- include/cry

[PATCH v2 1/5] crypto: sparc - rename sha256 to sha256_alg

2020-07-08 Thread Eric Biggers
From: Eric Biggers To avoid a naming collision when we add a sha256() library function, rename the "sha256" static variable in sha256_glue.c to "sha256_alg". For consistency, also rename "sha224" to "sha224_alg". Reported-by: kernel test robot Cc: sparcli...@vger.kernel.org Signed-off-by: Eric

[PATCH v2 0/5] crypto: add sha256() function

2020-07-08 Thread Eric Biggers
This series adds a function sha256() to the sha256 library so that users who want to compute a hash in one step can just call sha256() instead of sha256_init() + sha256_update() + sha256_final(). Patches 3-5 then convert some users to use it. Changed v1 => v2: - Added sparc patch to fix a build

[PATCH v2 4/5] mptcp: use sha256() instead of open coding

2020-07-08 Thread Eric Biggers
From: Eric Biggers Now that there's a function that calculates the SHA-256 digest of a buffer in one step, use it instead of sha256_init() + sha256_update() + sha256_final(). Reviewed-by: Ard Biesheuvel Acked-by: Matthieu Baerts Cc: mp...@lists.01.org Cc: Mat Martineau Cc: Matthieu Baerts Si

[PATCH v2 3/5] efi: use sha256() instead of open coding

2020-07-08 Thread Eric Biggers
From: Eric Biggers Now that there's a function that calculates the SHA-256 digest of a buffer in one step, use it instead of sha256_init() + sha256_update() + sha256_final(). Reviewed-by: Ard Biesheuvel Tested-by: Hans de Goede Cc: linux-...@vger.kernel.org Cc: Ard Biesheuvel Cc: Hans de Goed

[PATCH v2 5/5] ASoC: cros_ec_codec: use sha256() instead of open coding

2020-07-08 Thread Eric Biggers
From: Eric Biggers Now that there's a function that calculates the SHA-256 digest of a buffer in one step, use it instead of sha256_init() + sha256_update() + sha256_final(). Also simplify the code by inlining calculate_sha256() into its caller and switching a debug log statement to use %*phN in

Re: [PATCH v2] Remove __init from padata_do_multithreaded and padata_mt_helper.

2020-07-08 Thread Daniel Jordan
(I was away for a while) On Thu, Jul 02, 2020 at 11:55:48AM -0400, Nico Pache wrote: > Allow padata_do_multithreaded function to be called after bootstrap. The functions are __init because they're currently only needed during boot, and using __init allows the text to be freed once it's over, savi

RE: [PATCH v4] mm/zswap: move to use crypto_acomp API for hardware acceleration

2020-07-08 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: linux-crypto-ow...@vger.kernel.org > [mailto:linux-crypto-ow...@vger.kernel.org] On Behalf Of Sebastian Andrzej > Siewior > Sent: Thursday, July 9, 2020 3:00 AM > To: Song Bao Hua (Barry Song) > Cc: a...@linux-foundation.org; herb...@gondor.apana.org.au; > da

Re: [PATCH] crypto: caam - Remove broken arc4 support

2020-07-08 Thread Herbert Xu
On Wed, Jul 08, 2020 at 07:24:08PM +0300, Horia Geantă wrote: > > I think the commit message should be updated to reflect this logic: > indeed, caam's implementation of ecb(arc4) is broken, > but instead of fixing it, crypto API-based ecb(arc4) > is removed completely from the kernel (hence from c

RE: [PATCH v4] mm/zswap: move to use crypto_acomp API for hardware acceleration

2020-07-08 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: linux-crypto-ow...@vger.kernel.org > [mailto:linux-crypto-ow...@vger.kernel.org] On Behalf Of Sebastian Andrzej > Siewior > Sent: Thursday, July 9, 2020 3:00 AM > To: Song Bao Hua (Barry Song) > Cc: a...@linux-foundation.org; herb...@gondor.apana.org.au; > da

Re: [PATCH 2/6] crypto: algapi - use common mechanism for inheriting flags

2020-07-08 Thread Herbert Xu
Eric Biggers wrote: > > @@ -875,14 +873,21 @@ static void cbcmac_exit_tfm(struct crypto_tfm *tfm) > > static int cbcmac_create(struct crypto_template *tmpl, struct rtattr **tb) > { > + struct crypto_attr_type *algt; >struct shash_instance *inst; >struct crypto_cipher_spawn *

Re: [Patch v2 8/9] crypto: hisilicon/qm - fix the process of register algorithms to crypto

2020-07-08 Thread Herbert Xu
On Wed, Jul 01, 2020 at 03:19:54PM +0800, Yang Shen wrote: > When the devices are removed or not existing, the corresponding algorithms > which are registered by 'hisi-zip' driver can't be used. > > Move 'hisi_zip_register_to_crypto' from 'hisi_zip_init' to > 'hisi_zip_probe'. The algorithms will