[PATCH v2 5/9] crypto: skcipher - disallow en/decrypt for non-task or non-softirq context

2021-03-02 Thread Ard Biesheuvel
In order to ensure that kernel mode SIMD routines will not need a scalar fallback if they run with softirqs disabled, disallow any use of the skcipher encrypt and decrypt routines from outside of task or softirq context. Signed-off-by: Ard Biesheuvel --- crypto/skcipher.c | 10 ++ 1

[PATCH v7 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher

2021-02-11 Thread Thara Gopinath
The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > Q

[PATCH v7 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-11 Thread Thara Gopinath
Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- v5->v6: - Return 0 for zero length messages instead of -EOPNOTSUPP in the cipher algorithms as pointed out by Eric B

[PATCH v7 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes)

2021-02-11 Thread Thara Gopinath
ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index c2f0469ffb22..

[PATCH v7 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-11 Thread Thara Gopinath
ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- v5->v6: - Remove the wrong TO

[PATCH v7 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms

2021-02-11 Thread Thara Gopinath
Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- v6->v7: - Fixed sparse warning in patch 4 as pointed out by Herbert Xu. This means the checking if any

[PATCH v7 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm

2021-02-11 Thread Thara Gopinath
Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff -

Re: [PATCH v6 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms

2021-02-09 Thread Herbert Xu
On Sun, Feb 07, 2021 at 09:39:39AM -0500, Thara Gopinath wrote: > > + /* > + * The crypto engine does not support any two keys > + * being the same for triple des algorithms. The > + * verify_skcipher_des3_key does not check for all the > + * below conditions. Return -ENOKEY

[PATCH v6 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher

2021-02-07 Thread Thara Gopinath
The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > Q

[PATCH v6 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes)

2021-02-07 Thread Thara Gopinath
ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index d24d96ed5be9..

[PATCH v6 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-07 Thread Thara Gopinath
Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- v5->v6: - Return 0 for zero length messages instead of -EOPNOTSUPP in the cipher algorithms as pointed out by Eric B

[PATCH v6 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm

2021-02-07 Thread Thara Gopinath
Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff -

[PATCH v6 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-07 Thread Thara Gopinath
ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- v5->v6: - Remove the wrong TO

[PATCH v6 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms

2021-02-07 Thread Thara Gopinath
Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/crypto/qce/sk

Re: [PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-05 Thread Thara Gopinath
On 2/4/21 7:26 PM, Eric Biggers wrote: On Thu, Feb 04, 2021 at 07:09:53PM -0500, Thara Gopinath wrote: @@ -260,6 +261,10 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) rctx->flags |= encrypt ? QCE_ENCRYPT : QCE_DECRYPT; keylen = IS_XTS(rctx->flags

Re: [PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-04 Thread Eric Biggers
On Thu, Feb 04, 2021 at 07:09:53PM -0500, Thara Gopinath wrote: > > > @@ -260,6 +261,10 @@ static int qce_skcipher_crypt(struct > > > skcipher_request *req, int encrypt) > > > rctx->flags |= encrypt ? QCE_ENCRYPT : QCE_DECRYPT; > > > keylen = IS_XTS(rctx->flags) ? ctx->enc_keyl

Re: [PATCH v5 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-04 Thread Thara Gopinath
On 2/4/21 5:50 PM, Eric Biggers wrote: On Thu, Feb 04, 2021 at 04:43:54PM -0500, Thara Gopinath wrote: + /* +* ECB and CBC algorithms require message lengths to be +* multiples of block size. +* TODO: The spec says AES CBC mode for certain versions +* of

Re: [PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-04 Thread Thara Gopinath
Hi Eric, On 2/4/21 5:48 PM, Eric Biggers wrote: On Thu, Feb 04, 2021 at 04:43:53PM -0500, Thara Gopinath wrote: Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- drivers/crypto/qc

Re: [PATCH v5 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-04 Thread Eric Biggers
On Thu, Feb 04, 2021 at 04:43:54PM -0500, Thara Gopinath wrote: > + /* > + * ECB and CBC algorithms require message lengths to be > + * multiples of block size. > + * TODO: The spec says AES CBC mode for certain versions > + * of crypto engine can handle partial blocks as we

Re: [PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-04 Thread Eric Biggers
On Thu, Feb 04, 2021 at 04:43:53PM -0500, Thara Gopinath wrote: > Crypto engine BAM dma does not support 0 length data. Return unsupported > if zero length messages are passed for transformation. > > Signed-off-by: Thara Gopinath > --- > drivers/crypto/qce/skcipher.c | 5 + > 1 file changed,

[PATCH v5 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms

2021-02-04 Thread Thara Gopinath
Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/crypto/qce/sk

[PATCH v5 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes)

2021-02-04 Thread Thara Gopinath
ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 28bea9584c33..

[PATCH v5 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-04 Thread Thara Gopinath
ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 12 ++

[PATCH v5 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher

2021-02-04 Thread Thara Gopinath
The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > Q

[PATCH v5 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm

2021-02-04 Thread Thara Gopinath
Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff -

[PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-04 Thread Thara Gopinath
Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/

[PATCH v4 05/11] crypto: qce: skcipher: Return error for zero length messages

2021-02-03 Thread Thara Gopinath
Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/

[PATCH v4 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher

2021-02-03 Thread Thara Gopinath
The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > Q

[PATCH v4 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes)

2021-02-03 Thread Thara Gopinath
ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 28bea9584c33..

[PATCH v4 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms

2021-02-03 Thread Thara Gopinath
Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/crypto/qce/sk

[PATCH v4 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms)

2021-02-03 Thread Thara Gopinath
ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 12 ++

[PATCH v4 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm

2021-02-03 Thread Thara Gopinath
Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff -

Re: [PATCH v3 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing

2021-01-25 Thread Bjorn Andersson
On Wed 20 Jan 12:48 CST 2021, Thara Gopinath wrote: > This patch contains the following fixes for the supported encryption > algorithms in the Qualcomm crypto engine(CE) > 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE > does not support this and the operation causes the engin

[PATCH v3 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing

2021-01-20 Thread Thara Gopinath
This patch contains the following fixes for the supported encryption algorithms in the Qualcomm crypto engine(CE) 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE does not support this and the operation causes the engine to hang. 2. Return unsupported if any three keys are same f

[PATCH 2/2] crypto: aesni - release FPU during skcipher walk API calls

2021-01-16 Thread Ard Biesheuvel
for skcipher implementations, by moving the FPU begin/end calls inside the skcipher walk processing loop. Considering that skcipher walks operate on at most one page at a time, doing so fully mitigates this issue. This also permits the skcipher walk logic to use non-atomic kmalloc() calls etc so we

[PATCH v2 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing

2021-01-11 Thread Thara Gopinath
This patch contains the following fixes for the supported encryption algorithms in the Qualcomm crypto engine(CE) 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE does not support this and the operation causes the engine to hang. 2. Return unsupprted if any three keys are same fo

[PATCH 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing

2020-12-18 Thread Thara Gopinath
This patch contains the following fixes for the supported encryption algorithms in the Qualcomm crypto engine(CE) 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE does not support this and the operation causes the engine to hang. 2. Return unsupprted if any three keys are same fo

[RFC PATCH 2/5] crypto: skcipher - disallow en/decrypt for non-task or non-softirq context

2020-12-18 Thread Ard Biesheuvel
In order to ensure that kernel mode SIMD routines will not need a scalar fallback if they run with softirqs disabled, disallow any use of the skcipher encrypt and decrypt routines from outside of task or softirq context. Signed-off-by: Ard Biesheuvel --- crypto/skcipher.c | 10 ++ 1

[PATCH v2 3/6] crypto: hisilicon/sec - add new skcipher mode for SEC

2020-12-10 Thread Longfang Liu
Add new skcipher algorithms for Kunpeng930 SEC: OFB(AES), CFB(AES), CTR(AES), OFB(SM4), CFB(SM4), CTR(SM4). Signed-off-by: Wenkai Lin Signed-off-by: Longfang Liu --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 88 +++--- drivers/crypto/hisilicon/sec2/sec_crypto.h | 2

[PATCH 1/5] crypto: caam/jr - avoid allocating memory at crypto request runtime for skcipher

2020-12-02 Thread Iuliana Prodan (OSS)
kfree(edesc); /* * If no backlog flag, the completion of the request is done @@ -1604,7 +1607,7 @@ static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req, dma_addr_t iv_dma = 0; u8 *iv; int ivsize = crypto_skcipher_ivsize(skciphe

[PATCH 3/5] crypto: hisilicon/sec - add new skcipher mode for SEC

2020-11-25 Thread Longfang Liu
Add new skcipher algorithms to Kunpeng930: OFB(AES), CFB(AES), CTR(AES), OFB(SM4), CFB(SM4), CTR(SM4). Signed-off-by: Wenkai Lin Signed-off-by: Longfang Liu --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 47 ++ drivers/crypto/hisilicon/sec2/sec_crypto.h | 2 ++ 2

[RFC PATCH 3/4] crypto: caam - avoid allocating memory at crypto request runtime for skcipher

2020-11-25 Thread Iuliana Prodan (OSS)
kfree(edesc); /* * If no backlog flag, the completion of the request is done @@ -1604,7 +1607,7 @@ static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req, dma_addr_t iv_dma = 0; u8 *iv; int ivsize = crypto_skcipher_ivsize(skciphe

[PATCH v2 3/3] crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks

2020-11-20 Thread Ard Biesheuvel
WireGuard and IPsec both typically operate on input blocks that are ~1420 bytes in size, given the default Ethernet MTU of 1500 bytes and the overhead of the VPN metadata. Many aead and sckipher implementations are optimized for power-of-2 block sizes, and whether they perform well when operating

[PATCH 3/3] crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks

2020-11-09 Thread Ard Biesheuvel
WireGuard and IPsec both typically operate on input blocks that are ~1420 bytes in size, given the default Ethernet MTU of 1500 bytes and the overhead of the VPN metadata. Many aead and sckipher implementations are optimized for power-of-2 block sizes, and whether they perform well when operating

[PATCH 4/4] crypto: testmgr - always print the actual skcipher driver name

2020-10-26 Thread Eric Biggers
r when checking whether the driver is the generic driver or not. Fix this for the skcipher algorithm tests by getting the driver name from the crypto_skcipher that actually got allocated. Signed-off-by: Eric Biggers --- crypto/testmgr.c | 36 1 file changed, 16 in

Re: [PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-09-21 Thread Horia Geantă
On 9/16/2020 12:50 AM, Richard Weinberger wrote: > - Ursprüngliche Mail - >> Von: "horia geanta" How to use it with cryptsetup? I'm asking because it is not clear to me why you are not implementing a new kernel key type (KEYS subsystem) to utilize tagged keys. Many

Re: [PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-09-15 Thread Horia Geantă
t; they are and how to handle them using tag_object API. >>> >>> Add support, for tagged keys, to skcipher algorithms by >>> adding new transformations, with _tk_ prefix to distinguish >>> between plaintext and tagged keys. >>> >>> For job descrip

Re: [PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-09-15 Thread Richard Weinberger
- Ursprüngliche Mail - > Von: "horia geanta" >>> How to use it with cryptsetup? >>> I'm asking because it is not clear to me why you are not implementing >>> a new kernel key type (KEYS subsystem) >>> to utilize tagged keys. >>> Many tools already support the keyctl userspace interface (cr

Re: [PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-09-13 Thread Richard Weinberger
On Thu, Jul 16, 2020 at 4:12 PM Richard Weinberger wrote: > > On Mon, Jul 13, 2020 at 12:09 AM Iuliana Prodan > wrote: > > > > Tagged keys are keys that contain metadata indicating what > > they are and how to handle them using tag_object API. > > > > Ad

Re: [PATCH v3 0/7] crypto: mark ecb(arc4) skcipher as obsolete

2020-09-10 Thread Herbert Xu
On Mon, Aug 31, 2020 at 06:16:42PM +0300, Ard Biesheuvel wrote: > RC4 hasn't aged very well, and is a poor fit for the skcipher API so it > would be good if we could get rid of the ecb(arc4) drivers in the kernel > at some point in the future. This prevents new users from creeping in

Re: [PATCH v3 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete

2020-09-10 Thread Herbert Xu
On Mon, Aug 31, 2020 at 06:16:49PM +0300, Ard Biesheuvel wrote: > > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include This needs kernel.h too for the pr_warn_ratelimited. I'll add it when I apply the series. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au

[PATCH v3 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete

2020-08-31 Thread Ard Biesheuvel
local implementation, we can take the next step, and mark the ecb(arc4) skcipher as obsolete, and only provide it if the socket API is enabled in the first place, as well as provide the option to disable all algorithms that have been marked as obsolete. [0] https://git.kernel.org/pub/scm/network/wir

[PATCH v3 0/7] crypto: mark ecb(arc4) skcipher as obsolete

2020-08-31 Thread Ard Biesheuvel
RC4 hasn't aged very well, and is a poor fit for the skcipher API so it would be good if we could get rid of the ecb(arc4) drivers in the kernel at some point in the future. This prevents new users from creeping in, and allows us to improve the skcipher API without having to care too much

Re: [PATCH v2 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete

2020-08-24 Thread Herbert Xu
On Mon, Aug 24, 2020 at 03:30:01PM +0200, Ard Biesheuvel wrote: > > +config CRYPTO_USER_ENABLE_OBSOLETE > + bool "Enable obsolete cryptographic algorithms for userspace" > + depends on CRYPTO_USER That should be CRYPTO_USER_API which is the option for af_alg. CRYPTO_USER is the configurati

Re: [PATCH v2 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete

2020-08-24 Thread Ard Biesheuvel
On Mon, 24 Aug 2020 at 15:35, Herbert Xu wrote: > > On Mon, Aug 24, 2020 at 03:30:01PM +0200, Ard Biesheuvel wrote: > > > > +config CRYPTO_USER_ENABLE_OBSOLETE > > + bool "Enable obsolete cryptographic algorithms for userspace" > > + depends on CRYPTO_USER > > That should be CRYPTO_USER_AP

[PATCH v2 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete

2020-08-24 Thread Ard Biesheuvel
local implementation, we can take the next step, and mark the ecb(arc4) skcipher as obsolete, and only provide it if the socket API is enabled in the first place, as well as provide the option to disable all algorithms that have been marked as obsolete. [0] https://git.kernel.org/pub/scm/network/wir

[PATCH v2 0/7] crypto: mark ecb(arc4) skcipher as obsolete

2020-08-24 Thread Ard Biesheuvel
RC4 hasn't aged very well, and is a poor fit for the skcipher API so it would be good if we could get rid of the ecb(arc4) drivers in the kernel at some point in the future. This prevents new users from creeping in, and allows us to improve the skcipher API without having to care too much

Re: [PATCH 6/6] crypto: cmac - Use cbc skcipher instead of raw cipher

2020-08-24 Thread Herbert Xu
> What we could do instead is having a certain flag/behavior in skcipher > where writes are omitted entirely, and cbcmac/cmac could opt into > that. But imho, the best way to improve this is to have a new AES-NI > asm helper (which I already implemented in my v2) that wraps the > AES-NI

Re: [PATCH 6/6] crypto: cmac - Use cbc skcipher instead of raw cipher

2020-08-24 Thread Ard Biesheuvel
On Tue, 18 Aug 2020 at 10:25, Herbert Xu wrote: > > Many architectures provide an accelerated implementation of cbc(aes) > skcipher that is far superior to using the standard cbc template > over an accelerated aes cipher. As cmac uses the raw cipher, it > was not able to b

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-22 Thread Christian Lamparter
On 2020-08-19 00:27, Herbert Xu wrote: On Wed, Aug 19, 2020 at 08:15:50AM +1000, Herbert Xu wrote: On Tue, Aug 18, 2020 at 07:17:35AM -0700, Ben Greear wrote: Is there any easy way to use your work to make shash fast for aesni? I basically just want it to perform as well as it used to with my

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 03:09:55PM -0700, Ben Greear wrote: > > I have always assumed that I need aesni instructions to have any chance at > this performing well, > but there are certainly chips out there that don't have aesni, so possibly it > is still worth improving > if it is relatively easy

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ben Greear
On 8/20/20 1:10 PM, Herbert Xu wrote: On Thu, Aug 20, 2020 at 06:54:58AM -0700, Ben Greear wrote: Here's a run on an: Intel(R) Core(TM) i7-7700T CPU @ 2.90GHz testing speed of async cmac(aes-aesni) (cmac(aes-aesni)) [ 259.397910] tcrypt: test 8 ( 1024 byte blocks, 1024 byte

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 06:54:58AM -0700, Ben Greear wrote: > > Here's a run on an: Intel(R) Core(TM) i7-7700T CPU @ 2.90GHz > >testing speed of async cmac(aes-aesni) (cmac(aes-aesni)) > > [ 259.397910] tcrypt: test 8 ( 1024 byte blocks, 1024 bytes per update, 1 > updates):

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ben Greear
On 8/20/20 12:56 AM, Ard Biesheuvel wrote: On Thu, 20 Aug 2020 at 09:54, Herbert Xu wrote: On Thu, Aug 20, 2020 at 09:48:02AM +0200, Ard Biesheuvel wrote: Or are you saying on Ben's machine cbc-aesni would have worse performance vs. aes-generic? Yes, given the pathological overhead of FP

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ard Biesheuvel
On Thu, 20 Aug 2020 at 09:54, Herbert Xu wrote: > > On Thu, Aug 20, 2020 at 09:48:02AM +0200, Ard Biesheuvel wrote: > > > > > Or are you saying on Ben's machine cbc-aesni would have worse > > > performance vs. aes-generic? > > > > > > > Yes, given the pathological overhead of FPU preserve/restore

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 09:48:02AM +0200, Ard Biesheuvel wrote: > > > Or are you saying on Ben's machine cbc-aesni would have worse > > performance vs. aes-generic? > > > > Yes, given the pathological overhead of FPU preserve/restore for every > block of 16 bytes processed by the cbcmac wrapper.

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ard Biesheuvel
given the pathological overhead of FPU preserve/restore for every block of 16 bytes processed by the cbcmac wrapper. > > The mac80211 CCMP code uses a synchronous ccm aead, which gets backed > > by a skcipher+ahash combo by the ccm template. So a synchronous ahash > > is fine fo

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
e performance. Why does that matter? These are numbers for cbc-aesni which means just a single preserve/restore for the whole request. Or are you saying on Ben's machine cbc-aesni would have worse performance vs. aes-generic? > The mac80211 CCMP code uses a synchronous ccm aead, which g

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ard Biesheuvel
;t had the > > spare cycles to spend on this. > > I don't have an issue your patch per se. But please make it so that > it has the async path like everything else. Also wireless uses shash > so it can't use an ahash anyway even if it is sync. > The mac80211 CCMP code uses a synchronous ccm aead, which gets backed by a skcipher+ahash combo by the ccm template. So a synchronous ahash is fine for this particular case.

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 09:19:16AM +0200, Ard Biesheuvel wrote: > > Actually, I'm not so sure that they will be so much worse. The > expensive FPU preserve/restore occurs for every 16 bytes of data > processed by the AES cipher, which I'd estimate to take ~10 cycles per > byte for an unaccelerated

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ard Biesheuvel
On Thu, 20 Aug 2020 at 09:06, Herbert Xu wrote: > > On Thu, Aug 20, 2020 at 09:04:26AM +0200, Ard Biesheuvel wrote: > > > > I don't disagree with that, especially given all the effort that went > > into optimizing FPU preserve/restore on both arm64 and x86. But the > > bottom line is that this is

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 09:04:26AM +0200, Ard Biesheuvel wrote: > > I don't disagree with that, especially given all the effort that went > into optimizing FPU preserve/restore on both arm64 and x86. But the > bottom line is that this is what is causing the degradation in Ben's > case, so we cannot

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Ard Biesheuvel
On Thu, 20 Aug 2020 at 09:01, Herbert Xu wrote: > > On Thu, Aug 20, 2020 at 08:58:15AM +0200, Ard Biesheuvel wrote: > > > > But if we look at the actual issue at hand, we might also look into > > amortizing the FPU preserve/restore over multiple invocations of a > > cipher. I proposed a patch a wh

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-20 Thread Herbert Xu
On Thu, Aug 20, 2020 at 08:58:15AM +0200, Ard Biesheuvel wrote: > > But if we look at the actual issue at hand, we might also look into > amortizing the FPU preserve/restore over multiple invocations of a > cipher. I proposed a patch a while ago that makes cipher an internal > crypto API abstractio

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-19 Thread Ard Biesheuvel
On Wed, 19 Aug 2020 at 00:39, Ben Greear wrote: > > On 8/18/20 3:33 PM, Herbert Xu wrote: > > On Tue, Aug 18, 2020 at 03:31:10PM -0700, Ben Greear wrote: > >> > >> I don't think it has been discussed recently, but mac80211 is already > >> a complicated beast, so if this added any significant compl

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Ben Greear
On 8/18/20 3:33 PM, Herbert Xu wrote: On Tue, Aug 18, 2020 at 03:31:10PM -0700, Ben Greear wrote: I don't think it has been discussed recently, but mac80211 is already a complicated beast, so if this added any significant complexity it might not be worth it. Any bulk data path should be using

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
On Tue, Aug 18, 2020 at 03:31:10PM -0700, Ben Greear wrote: > > I don't think it has been discussed recently, but mac80211 is already > a complicated beast, so if this added any significant complexity > it might not be worth it. Any bulk data path should be using the async interface, otherwise per

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Ben Greear
On 8/18/20 3:27 PM, Herbert Xu wrote: On Wed, Aug 19, 2020 at 08:15:50AM +1000, Herbert Xu wrote: On Tue, Aug 18, 2020 at 07:17:35AM -0700, Ben Greear wrote: Is there any easy way to use your work to make shash fast for aesni? I basically just want it to perform as well as it used to with my

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
On Wed, Aug 19, 2020 at 08:15:50AM +1000, Herbert Xu wrote: > On Tue, Aug 18, 2020 at 07:17:35AM -0700, Ben Greear wrote: > > > > Is there any easy way to use your work to make shash fast for aesni? I > > basically just want it to perform as well as it used to with my patch. > > Yes. We could ad

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
On Tue, Aug 18, 2020 at 07:17:35AM -0700, Ben Greear wrote: > > Is there any easy way to use your work to make shash fast for aesni? I > basically just want it to perform as well as it used to with my patch. Yes. We could add a sync version of aesni that simply falls back to aes-generic when sim

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Ben Greear
On 8/18/20 7:05 AM, Herbert Xu wrote: On Tue, Aug 18, 2020 at 06:56:12AM -0700, Ben Greear wrote: Herbert, thanks for working on this. If I apply the patches you posted, that is expected to provide wifi aes decryption speedup similar to what the original patch I sent does? Or, are additional

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
On Tue, Aug 18, 2020 at 06:56:12AM -0700, Ben Greear wrote: > > Herbert, thanks for working on this. If I apply the patches you posted, > that is expected to provide wifi aes decryption speedup similar to what > the original patch I sent does? Or, are additional patches needed? It depends on whe

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Ben Greear
On 8/18/20 6:51 AM, Herbert Xu wrote: On Tue, Aug 18, 2020 at 10:31:39AM +0200, Ard Biesheuvel wrote: What do you mean? You cannot implement cbcmac using a cbc skcipher unless you provide a scratch buffer of arbitrary size as the destination, in order to capture the skcipher output IV as the

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
On Tue, Aug 18, 2020 at 10:31:39AM +0200, Ard Biesheuvel wrote: > > What do you mean? You cannot implement cbcmac using a cbc skcipher > unless you provide a scratch buffer of arbitrary size as the > destination, in order to capture the skcipher output IV as the MAC. Please have a loo

Re: [PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Ard Biesheuvel
| 39 +++ > > arch/x86/crypto/aesni-intel_glue.c | 42 +--- > > arch/x86/crypto/aesni-intel_mac.c | 257 ++++ > > 4 files changed, 306 insertions(+), 34 deletions(-) > > We should just use the accelerated cbc skcipher. > What do you mean? You cannot im

[PATCH 6/6] crypto: cmac - Use cbc skcipher instead of raw cipher

2020-08-18 Thread Herbert Xu
Many architectures provide an accelerated implementation of cbc(aes) skcipher that is far superior to using the standard cbc template over an accelerated aes cipher. As cmac uses the raw cipher, it was not able to benefit from the accelerated cbc(aes) skcpipher. This patch changes cmac to use an

[PATCH 1/6] crypto: skcipher - Add helpers for sync skcipher spawn

2020-08-18 Thread Herbert Xu
This patch adds helpers for using sync skciphers as spawns from crypto instances. In doing so it also changes the error returned when an algorithm exceeds the maximum sync skcipher request size from EINVAL to E2BIG as the former is used for way too many things. Also the CRYPTO_ALG_ASYNC bit is

[PATCH 0/5] crypto: Implement cmac based on cbc skcipher

2020-08-18 Thread Herbert Xu
4 files changed, 306 insertions(+), 34 deletions(-) We should just use the accelerated cbc skcipher. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [RFC PATCH 4/7] crypto: remove ARC4 support from the skcipher API

2020-08-04 Thread Ard Biesheuvel
; > > On Thu, 2 Jul 2020 at 19:50, Eric Biggers wrote: > > > > > > > > > > [+linux-wireless, Marcel Holtmann, and Denis Kenzior] > > > > > > > > > > On Thu, Jul 02, 2020 at 12:19:44PM +0200, Ard Biesheuvel wrote: > > >

Re: [v3 PATCH 0/31] crypto: skcipher - Add support for no chaining and partial chaining

2020-07-28 Thread Herbert Xu
On Tue, Jul 28, 2020 at 10:19:21AM -0700, Eric Biggers wrote: > > Can you elaborate on the use case for supporting chaining on algorithms that > don't currently support it? OK I will describe the algif issue in more detail and also add a mention of sunrpc. In fact I might try to convert sunrpc to

Re: [v3 PATCH 8/31] crypto: skcipher - Initialise requests to zero

2020-07-28 Thread Herbert Xu
On Tue, Jul 28, 2020 at 10:10:59AM -0700, Eric Biggers wrote: > > Does this really work? Some users allocate memory themselves without using > *_request_alloc(). Yes good point. I will instead add a second request flag used to indicate that we should retain the internal state. Thanks, -- Email

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Herbert Xu
On Tue, Jul 28, 2020 at 08:46:42PM +0300, Ard Biesheuvel wrote: > > > Yes we could add a flag for it. However, for the two users that > > I'm looking at right now (algif_skcipher and sunrpc) this is not > > required. For algif_skcipher it'll simply fall back to the current > > behaviour if chaini

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Ard Biesheuvel
On Tue, 28 Jul 2020 at 20:30, Herbert Xu wrote: > > On Tue, Jul 28, 2020 at 08:26:38PM +0300, Ard Biesheuvel wrote: > > > > So how does one allocate a tfm that supports chaining if their use > > case requires it? Having different implementations of the same algo > > where one does support it while

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Herbert Xu
On Tue, Jul 28, 2020 at 08:26:38PM +0300, Ard Biesheuvel wrote: > > So how does one allocate a tfm that supports chaining if their use > case requires it? Having different implementations of the same algo > where one does support it while the other one doesn't means we will > need some flag to requ

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Ard Biesheuvel
On Tue, 28 Jul 2020 at 20:22, Herbert Xu wrote: > > On Tue, Jul 28, 2020 at 10:15:12AM -0700, Eric Biggers wrote: > > > > Shouldn't chaining be disabled by default? This is inviting bugs where > > drivers > > don't implement chaining, but leave final_chunksize unset (0) which > > apparently > >

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Herbert Xu
On Tue, Jul 28, 2020 at 10:15:12AM -0700, Eric Biggers wrote: > > Shouldn't chaining be disabled by default? This is inviting bugs where > drivers > don't implement chaining, but leave final_chunksize unset (0) which apparently > indicates that chaining is supported. I've gone through everything

Re: [v3 PATCH 0/31] crypto: skcipher - Add support for no chaining and partial chaining

2020-07-28 Thread Eric Biggers
On Tue, Jul 28, 2020 at 05:17:46PM +1000, Herbert Xu wrote: > This patch-set adds support to the Crypto API and algif_skcipher > for algorithms that cannot be chained, as well as ones that can > be chained if you withhold a certain number of blocks at the end. > > The vast majority of algorithms c

Re: [v3 PATCH 1/31] crypto: skcipher - Add final chunk size field for chaining

2020-07-28 Thread Eric Biggers
On Tue, Jul 28, 2020 at 05:18:39PM +1000, Herbert Xu wrote: > Crypto skcipher algorithms in general allow chaining to break > large operations into smaller ones based on multiples of the chunk > size. However, some algorithms don't support chaining while others > (such as

Re: [v3 PATCH 8/31] crypto: skcipher - Initialise requests to zero

2020-07-28 Thread Eric Biggers
On Tue, Jul 28, 2020 at 05:18:55PM +1000, Herbert Xu wrote: > This patch initialises skcipher requests to zero. This allows > algorithms to distinguish between the first operation versus > subsequent ones. > > Signed-off-by: Herbert Xu > --- > > include/

[v3 PATCH 7/31] crypto: skcipher - Add alg reqsize field

2020-07-28 Thread Herbert Xu
As it is the reqsize field only exists on the tfm object which means that in order to set it you must provide an init function for the tfm, even if the size is actually static. This patch adds a reqsize field to the skcipher alg object which allows it to be set without having an init function

  1   2   3   4   5   6   7   8   9   10   >