Re: [RFC PATCH 4/4] crypto: aes - add generic time invariant AES for CTR/CCM/GCM

2017-01-26 Thread Krzysztof Kwiatkowski
Ard, This is really interesting implementation. Is there a way to test if execution of this code is really constant time. Have you done any tests like that? Adam Langley has proposed using modified version of valgrind (ctgrind) for that, but I wonder if you maybe thought about any alternative meth

Re: [RFC PATCH 4/4] crypto: aes - add generic time invariant AES for CTR/CCM/GCM

2017-01-26 Thread Ard Biesheuvel
On 26 January 2017 at 18:35, Krzysztof Kwiatkowski wrote: > Ard, > > This is really interesting implementation. Is there a way to test if > execution of this code is really constant time. Have you done any tests > like that? No, I haven't, and to be perfectly honest, I think it would only make se

[PATCH 1/4] crypto: testmgr - add test cases for cbcmac(aes)

2017-01-26 Thread Ard Biesheuvel
In preparation of splitting off the CBC-MAC transform in the CCM driver into a separate algorithm, define some test cases for the AES incarnation of cbcmac. Signed-off-by: Ard Biesheuvel --- crypto/testmgr.c | 7 +++ crypto/testmgr.h | 58 2 files changed, 65 insertions(+)

[PATCH 3/4] crypto: arm64/aes - add NEON and Crypto Extension CBC-MAC driver

2017-01-26 Thread Ard Biesheuvel
On ARMv8 implementations that do not support the Crypto Extensions, such as the Raspberry Pi 3, the CCM driver falls back to the generic table based AES implementation to perform the MAC part of the algorithm, which is slow and not time invariant. So add a CBCMAC implementation to the shared glue c

[RFC PATCH 4/4] crypto: aes - add generic time invariant AES for CTR/CCM/GCM

2017-01-26 Thread Ard Biesheuvel
Lookup table based AES is sensitive to timing attacks, which is due to the fact that such table lookups are data dependent, and the fact that 8 KB worth of tables covers a significant number of cachelines on any architecture. For network facing algorithms such as CTR, CCM or GCM, this presents a s

[PATCH 2/4] crypto: ccm - switch to separate cbcmac driver

2017-01-26 Thread Ard Biesheuvel
Update the generic CCM driver to defer CBC-MAC processing to a dedicated CBC-MAC ahash transform rather than open coding this transform (and much of the associated scatterwalk plumbing) in the CCM driver itself. This cleans up the code considerably, but more importantly, it allows the use of alter

[PATCH 0/4] crypto: time invariant AES for CCM (and GCM/CTR)

2017-01-26 Thread Ard Biesheuvel
This series is primarily directed at improving the performance and security of CCM on the Rasperry Pi 3. This involves splitting the MAC handling of CCM into a separate driver so that we can efficiently replace it by something else using the ordinary algo resolution machinery. Patch #1 adds some t

[PATCH v3 09/12] crypto: atmel-sha: add support to hmac(shaX)

2017-01-26 Thread Cyrille Pitchen
This patch adds support to the hmac(shaX) algorithms. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha-regs.h | 4 + drivers/crypto/atmel-sha.c | 598 +++- 2 files changed, 601 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/atmel-s

[PATCH v3 08/12] crypto: atmel-sha: add simple DMA transfers

2017-01-26 Thread Cyrille Pitchen
This patch adds a simple function to perform data transfer with the DMA controller. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 116 + 1 file changed, 116 insertions(+) diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel

[PATCH v3 10/12] crypto: atmel-aes: fix atmel_aes_handle_queue()

2017-01-26 Thread Cyrille Pitchen
This patch fixes the value returned by atmel_aes_handle_queue(), which could have been wrong previously when the crypto request was started synchronously but became asynchronous during the ctx->start() call. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-aes.c | 7 +-- 1 file change

[PATCH v3 02/12] crypto: atmel-sha: update request queue management to make it more generic

2017-01-26 Thread Cyrille Pitchen
This patch is a transitional patch. It splits the atmel_sha_handle_queue() function. Now atmel_sha_handle_queue() only manages the request queue and calls a new .start() hook from the atmel_sha_ctx structure. This hook allows to implement different kind of requests still handled by a single queue.

[PATCH v3 11/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes

2017-01-26 Thread Cyrille Pitchen
This patchs allows to combine the AES and SHA hardware accelerators on some Atmel SoCs. Doing so, AES blocks are only written to/read from the AES hardware. Those blocks are also transferred from the AES to the SHA accelerator internally, without additionnal accesses to the system busses. Hence, t

[PATCH v3 12/12] crypto: atmel-sha: add verbose debug facilities to print hw register names

2017-01-26 Thread Cyrille Pitchen
When VERBOSE_DEBUG is defined and SHA_FLAGS_DUMP_REG flag is set in dd->flags, this patch prints the register names and values when performing IO accesses. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 110 - 1 file changed, 108 inser

[PATCH v3 01/12] crypto: atmel-sha: create function to get an Atmel SHA device

2017-01-26 Thread Cyrille Pitchen
This is a transitional patch: it creates the atmel_sha_find_dev() function, which will be used in further patches to share the source code responsible for finding a Atmel SHA device. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 15 +++ 1 file changed, 11 insertions

[PATCH v3 04/12] crypto: atmel-sha: redefine SHA_FLAGS_SHA* flags to match SHA_MR_ALGO_SHA*

2017-01-26 Thread Cyrille Pitchen
This patch modifies the SHA_FLAGS_SHA* flags: those algo flags are now organized as values of a single bitfield instead of individual bits. This allows to reduce the number of bits needed to encode all possible values. Also the new values match the SHA_MR_ALGO_SHA* values hence the algorithm bitfie

[PATCH v3 06/12] crypto: atmel-sha: add SHA_MR_MODE_IDATAR0

2017-01-26 Thread Cyrille Pitchen
This patch defines an alias macro to SHA_MR_MODE_PDC, which is not suited for DMA usage. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha-regs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/atmel-sha-regs.h b/drivers/crypto/atmel-sha-regs.h index deb0b0b15096..8d

[PATCH v3 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready()

2017-01-26 Thread Cyrille Pitchen
This patch simply defines a helper function to test the 'Data Ready' flag of the Status Register. It also gives a chance for the crypto request to be processed synchronously if this 'Data Ready' flag is already set when polling the Status Register. Indeed, running synchronously avoid the latency of

[PATCH v3 07/12] crypto: atmel-sha: add atmel_sha_cpu_start()

2017-01-26 Thread Cyrille Pitchen
This patch adds a simple function to perform data transfer with PIO, hence handled by the CPU. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 90 ++ 1 file changed, 90 insertions(+) diff --git a/drivers/crypto/atmel-sha.c b/drivers/cr

[PATCH v3 03/12] crypto: atmel-sha: make atmel_sha_done_task more generic

2017-01-26 Thread Cyrille Pitchen
This patch is a transitional patch. It updates atmel_sha_done_task() to make it more generic. Indeed, it adds a new .resume() member in the atmel_sha_dev structure. This hook is called from atmel_sha_done_task() to resume processing an asynchronous request. Signed-off-by: Cyrille Pitchen --- dri

[PATCH v3 00/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes

2017-01-26 Thread Cyrille Pitchen
Hi all, this series of patches has been based and tested on next-20170125 with CRYPTO_MANAGER_DISABLED_TESTS not set. The series adds support to the hmac(shaX) algorithms first, then combines both the Atmel SHA and AES hardware accelerators to implement authenc(hmac(shaX),Y(aes)) algorithms as us

[PATCHv2] crypto: doc - Fix hash export state information

2017-01-26 Thread Rabin Vincent
From: Rabin Vincent The documentation states that crypto_ahash_reqsize() provides the size of the state structure used by crypto_ahash_export(). But it's actually crypto_ahash_statesize() which provides this size. Signed-off-by: Rabin Vincent --- v2: Add crypto_ahash_statesize() to api-digest;

Re: [PATCH] crypto: doc - Fix hash export state information

2017-01-26 Thread Rabin Vincent
On Wed, Jan 25, 2017 at 05:18:05PM +0100, Stephan Müller wrote: > Am Mittwoch, 25. Januar 2017, 16:55:06 CET schrieb Rabin Vincent: > > The documentation states that crypto_ahash_reqsize() provides the size > > of the state structure used by crypto_ahash_export(). But it's actually > > crypto_ahas

Re: [PATCH v5 0/5] Update LZ4 compressor module

2017-01-26 Thread Sven Schmidt
On Thu, Jan 26, 2017 at 01:19:53AM -0800, Eric Biggers wrote: > On Thu, Jan 26, 2017 at 08:57:30AM +0100, Sven Schmidt wrote: > > > > This patchset is for updating the LZ4 compression module to a version based > > on LZ4 v1.7.3 allowing to use the fast compression algorithm aka LZ4 fast > > which

Re: [PATCH] dm: switch dm-verity to async hash crypto API

2017-01-26 Thread Ondrej Mosnáček
Hi Gilad, 2017-01-24 15:38 GMT+01:00 Gilad Ben-Yossef : > - v->tfm = crypto_alloc_shash(v->alg_name, 0, 0); > + v->tfm = crypto_alloc_ahash(v->alg_name, 0, CRYPTO_ALG_ASYNC); I believe you should pass zero as the mask here. When flags == 0 and mask == CRYPTO_ALG_ASYNC, you are basical

Re: [PATCH v5 0/5] Update LZ4 compressor module

2017-01-26 Thread Eric Biggers
On Thu, Jan 26, 2017 at 08:57:30AM +0100, Sven Schmidt wrote: > > This patchset is for updating the LZ4 compression module to a version based > on LZ4 v1.7.3 allowing to use the fast compression algorithm aka LZ4 fast > which provides an "acceleration" parameter as a tradeoff between > high compre