RE: [BUG?] crypto: caam: little/big endianness on ARM vs PPC

2015-06-16 Thread Victoria Milhoan
Jon, The patches published to the mailing list yesterday for comment (titled crypto: caam - Add i.MX6 support to the Freescale CAAM driver) are based on the patches in the Freescale 3.14 git repository which enable i.MX6 support. The initial patch set is intended to provide a functional

[PATCH RFC v7 1/3] crypto: add PKE API

2015-06-16 Thread Tadeusz Struk
Add Public Key Encryption API. Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com --- crypto/Kconfig | 11 + crypto/Makefile|1 crypto/akcipher.c | 117 crypto/crypto_user.c | 22 ++

[PATCH RFC v7 3/3] crypto: add tests vectors for RSA

2015-06-16 Thread Tadeusz Struk
New test vectors for RSA algorithm. Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com --- crypto/Kconfig |1 crypto/testmgr.c | 158 ++ crypto/testmgr.h | 187 ++ 3 files changed, 346

[PATCH RFC v7 0/3] crypto: Introduce Public Key Encryption API

2015-06-16 Thread Tadeusz Struk
This patch set introduces a Public Key Encryption API. What is proposed is a new crypto type called crypto_akcipher_type, plus new struct akcipher_alg and struct crypto_akcipher, together with number of helper functions to register akcipher type algorithms and allocate tfm instances. This is to

[PATCH RFC v7 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Tadeusz Struk
Add a new rsa generic SW implementation. This implements only cryptographic primitives. Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com --- crypto/Kconfig|7 + crypto/Makefile |8 + crypto/rsa.c | 315

Re: [PATCH RFC v7 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread David Howells
Tadeusz Struk tadeusz.st...@intel.com wrote: +static int _rsa_sign(const struct rsa_key *key, MPI s, MPI m) +{ + /* (1) Validate 0 = m n */ + if (mpi_cmp_ui(m, 0) 0 || mpi_cmp(m, key-n) = 0) + return -EINVAL; Why -EINVAL not -EBADMSG? David -- To unsubscribe from this

Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-16 Thread Herbert Xu
On Wed, Jun 17, 2015 at 01:05:27PM +0800, Herbert Xu wrote: On Tue, Jun 16, 2015 at 11:58:59AM +0200, Boris Brezillon wrote: + ret = dma_map_sg(cesa_dev-dev, req-src, creq-src_nents, +DMA_TO_DEVICE); + if (ret != creq-src_nents) + return -ENOMEM; Hmm

Re: [PATCH v5 04/14] crypto: add a new driver for Marvell's CESA

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 11:58:58AM +0200, Boris Brezillon wrote: +config CRYPTO_DEV_MARVELL_CESA + tristate New Marvell's Cryptographic Engine driver + depends on (PLAT_ORION || ARCH_MVEBU || COMPILE_TEST) HAS_DMA HAS_IOMEM + select CRYPTO_ALGAPI + select CRYPTO_AES +

Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 11:58:59AM +0200, Boris Brezillon wrote: + ret = dma_map_sg(cesa_dev-dev, req-src, creq-src_nents, + DMA_TO_DEVICE); + if (ret != creq-src_nents) + return -ENOMEM; Hmm it doesn't quite work like that. It returns zero on error,

Re: [PATCH RFC v7 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Tadeusz Struk
Hi David, On 06/16/2015 03:10 PM, David Howells wrote: +static int _rsa_sign(const struct rsa_key *key, MPI s, MPI m) +{ + /* (1) Validate 0 = m n */ + if (mpi_cmp_ui(m, 0) 0 || mpi_cmp(m, key-n) = 0) + return -EINVAL; Why -EINVAL not -EBADMSG? I thought that -EBADMSG was

Re: [PATCH RFC v7 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 07:32:16PM -0700, Tadeusz Struk wrote: I thought that -EBADMSG was mainly used for authenticated ciphers in case when verification of auth data fails. Since this are input params I thought that -EINVAL would be more appropriate. I can change it to -EBADMSG, no

Re: [PATCH RFC v7 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Tadeusz Struk
On 06/16/2015 07:36 PM, Herbert Xu wrote: The existing crypto/asymmetric_key errno scheme doesn't really mesh in with the rest of crypto. So you'll just have to pick one scheme and stick with it. I don't really mind either way as long as the error codes are unique and meaningful. So I

Re: [PATCH RFC 05/11] crypto: caam - Add cache coherency support to Freescale CAAM scatterlist implementation

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 04:52:53PM -0700, Victoria Milhoan wrote: @@ -91,9 +91,14 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg, { if (unlikely(chained)) { int i; + struct scatterlist *tsg = sg; + + /* We use a local copy of the

Re: [PATCH RFC v5 4/4] crypto: add tests vectors for RSA

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 11:26:58PM -0700, Tadeusz Struk wrote: On 06/15/2015 05:37 PM, Herbert Xu wrote: config CRYPTO_MANAGER tristate Cryptographic algorithm manager select CRYPTO_MANAGER2 +select CRYPTO_AKCIPHER Please add this to CRYPTO_MANAGER2

Re: [PATCH RFC v5 4/4] crypto: add tests vectors for RSA

2015-06-16 Thread Tadeusz Struk
On 06/15/2015 05:37 PM, Herbert Xu wrote: config CRYPTO_MANAGER tristate Cryptographic algorithm manager select CRYPTO_MANAGER2 + select CRYPTO_AKCIPHER Please add this to CRYPTO_MANAGER2 instead. This causes a recursive dependency error crypto/Kconfig:115:error: recursive

Re: [PATCH RFC v5 1/4] MPILIB: add mpi_read_buf() and mpi_get_size() helpers

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 01:18:36PM -0700, Tadeusz Struk wrote: Added a mpi_read_buf() helper function to export MPI to a buf provided by the user, and a mpi_get_size() helper, that tells the user how big the buf is. Changed mpi_free to use kzfree instead of kfree because it is used to free

Re: [PATCH RFC 08/11] crypto: caam - improve initalization for context state saves

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 04:52:56PM -0700, Victoria Milhoan wrote: From: Steve Cornelius steve.cornel...@freescale.com Multiple function in asynchronous hashing use a saved-state block, a.k.a. struct caam_hash_state, which holds a stash of information between requests (init/update/final).

Re: [PATCH RFC 11/11] crypto: caam - fix RNG buffer cache alignment

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 04:52:59PM -0700, Victoria Milhoan wrote: From: Steve Cornelius steve.cornel...@freescale.com The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx) allocated in one DMA-tagged region. While the kernel's heap allocator should place the overall

Re: [PATCH RFC 10/11] crypto: caam - Provide correct value to iounmap() in controller driver

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 04:52:58PM -0700, Victoria Milhoan wrote: Fix a Trying to vfree() nonexistent vm area error when unloading the CAAM controller module by providing the correct pointer value to iounmap(). Signed-off-by: Victoria Milhoan vicki.milh...@freescale.com Applied. -- Email:

Re: [PATCH RFC 09/11] crypto: caam - Fix incorrect size when DMA unmapping buffer

2015-06-16 Thread Herbert Xu
On Mon, Jun 15, 2015 at 04:52:57PM -0700, Victoria Milhoan wrote: The CAAM driver uses two data buffers to store data for a hashing operation, with one buffer defined as active. This change forces switching of the active buffer when executing a hashing operation to avoid a later DMA unmap

Re: [PATCH RFC v6 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 01:02:05AM -0700, Tadeusz Struk wrote: + if (!pkey-n || !pkey-e || !req-dst_len) + return -EINVAL; You leaked m. + if (*req-dst_len mpi_get_size(pkey-n)) { + *req-dst_len = mpi_get_size(pkey-n); + return -EINVAL; + }

[PATCH RFC v6 0/3] crypto: Introduce Public Key Encryption API

2015-06-16 Thread Tadeusz Struk
This patch set introduces a Public Key Encryption API. What is proposed is a new crypto type called crypto_akcipher_type, plus new struct akcipher_alg and struct crypto_akcipher, together with number of helper functions to register akcipher type algorithms and allocate tfm instances. This is to

[PATCH RFC v6 1/3] crypto: add PKE API

2015-06-16 Thread Tadeusz Struk
Add Public Key Encryption API. Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com --- crypto/Kconfig | 11 + crypto/Makefile|1 crypto/akcipher.c | 100 +++ crypto/crypto_user.c | 22 ++

[PATCH] crypto: poly1305 - Pass key as first two message blocks to each desc_ctx

2015-06-16 Thread Martin Willi
The Poly1305 authenticator requires a unique key for each generated tag. This implies that we can't set the key per tfm, as multiple users set individual keys. Instead we pass a desc specific key as the first two blocks of the message to authenticate in update(). Signed-off-by: Martin Willi

[PATCH] crypto: caam - fix non-64-bit write/read access

2015-06-16 Thread Steffen Trumtrar
The patch crypto: caam - Add definition of rd/wr_reg64 for little endian platform added support for little endian platforms to the CAAM driver. Namely a write and read function for 64 bit registers. The only user of this functions is the Job Ring driver (drivers/crypto/caam/jr.c). It

[PATCH RFC v6 2/3] crypto: rsa: add a new rsa generic implementation

2015-06-16 Thread Tadeusz Struk
Add a new rsa generic SW implementation. This implements only cryptographic primitives. Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com --- crypto/Kconfig|7 + crypto/Makefile |8 + crypto/rsa.c | 313

Re: [PATCH RFC v6 1/3] crypto: add PKE API

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 01:01:59AM -0700, Tadeusz Struk wrote: @@ -28,6 +28,7 @@ crypto_hash-y += shash.o obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o +obj-$(CONFIG_CRYPTO_AKCIPHER) += akcipher.o s/AKCIPHER/AKCIPHER2/ +/** + * struct

[PATCH 0/2] crypto: testmgr: test IV value after a cipher operation

2015-06-16 Thread Boris Brezillon
Hello, Crypto drivers are supposed to update the IV passed to a cipher request but it appears that some of them are not updating it. The first patch of this series adds a new test for cipher algo (test the IV value after a cipher operation) and the second one adds the expected IV value to all the

[PATCH 1/2] crypto: testmgr: test IV value after a cipher operation

2015-06-16 Thread Boris Brezillon
The crypto drivers are supposed to update the IV passed to the crypto request before calling the completion callback. Test for the IV value before considering the test as successful. Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- crypto/testmgr.c | 12 +++-

[PATCH 2/2] crypto: testmgr: add iv_out information for all CBC testvec

2015-06-16 Thread Boris Brezillon
Add iv_out information to all CBC testvec so that the testmgr can verify the IV value after each cipher request. Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- crypto/testmgr.h | 81 1 file changed, 81 insertions(+)

[PATCH v5 03/14] crypto: mv_cesa: explicitly define kirkwood and dove compatible strings

2015-06-16 Thread Boris Brezillon
We are about to add a new driver to support new features like using the TDMA engine to offload the CPU. Orion, Dove and Kirkwood platforms are already using the mv_cesa driver, but Orion SoCs do not embed the TDMA engine, which means we will have to differentiate them if we want to get TDMA

[PATCH v5 11/14] crypto: marvell/CESA: add allhwsupport module parameter

2015-06-16 Thread Boris Brezillon
The old and new marvell CESA drivers both support Orion and Kirkwood SoCs. Add a module parameter to choose whether these SoCs should be attached to the new or the old driver. The default policy is to keep attaching those IPs to the old driver if it is enabled, until we decide the new CESA driver

[PATCH v5 09/14] crypto: marvell/CESA: add SHA256 support

2015-06-16 Thread Boris Brezillon
From: Arnaud Ebalard a...@natisbad.org Add support for SHA256 operations. Signed-off-by: Arnaud Ebalard a...@natisbad.org Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- drivers/crypto/marvell/cesa.c | 2 + drivers/crypto/marvell/cesa.h | 2 +

[PATCH v5 13/14] crypto: marvell/CESA: add support for Kirkwood and Dove SoCs

2015-06-16 Thread Boris Brezillon
From: Arnaud Ebalard a...@natisbad.org Add the Kirkwood and Dove SoC descriptions, and control the allhwsupport module parameter to avoid probing the CESA IP when the old CESA driver is enabled (unless it is explicitly requested to do so). Signed-off-by: Arnaud Ebalard a...@natisbad.org

[PATCH v5 04/14] crypto: add a new driver for Marvell's CESA

2015-06-16 Thread Boris Brezillon
The existing mv_cesa driver supports some features of the CESA IP but is quite limited, and reworking it to support new features (like involving the TDMA engine to offload the CPU) is almost impossible. This driver has been rewritten from scratch to take those new features into account. This

[PATCH v5 06/14] crypto: marvell/CESA: add DES support

2015-06-16 Thread Boris Brezillon
Add support for DES operations. Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com Signed-off-by: Arnaud Ebalard a...@natisbad.org --- drivers/crypto/marvell/cesa.c | 2 + drivers/crypto/marvell/cesa.h | 2 + drivers/crypto/marvell/cipher.c | 150

[PATCH v5 02/14] crypto: mv_cesa: use gen_pool to reserve the SRAM memory region

2015-06-16 Thread Boris Brezillon
The mv_cesa driver currently expects the SRAM memory region to be passed as a platform device resource. This approach implies two drawbacks: - the DT representation is wrong - the only one that can access the SRAM is the crypto engine The last point is particularly annoying in some cases: for

[PATCH v5 01/14] crypto: mv_cesa: document the clocks property

2015-06-16 Thread Boris Brezillon
On Dove platforms, the crypto engine requires a clock. Document this clocks property in the mv_cesa bindings doc. Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- Documentation/devicetree/bindings/crypto/mv_cesa.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH v5 00/14] crypto: add a new driver for Marvell's CESA

2015-06-16 Thread Boris Brezillon
Hello, This patch series adds a new driver supporting Marvell's CESA IP. This driver addresses some limitations of the existing one. From a performance and CPU load point of view the most important limitation in the existing driver is the lack of DMA support, thus preventing us from chaining

[PATCH v5 14/14] crypto: marvell/CESA: add DT bindings documentation

2015-06-16 Thread Boris Brezillon
Add DT bindings documentation for the new marvell-cesa driver. Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- .../devicetree/bindings/crypto/marvell-cesa.txt| 45 ++ 1 file changed, 45 insertions(+) create mode 100644

[PATCH v5 12/14] crypto: marvell/CESA: add support for Orion SoCs

2015-06-16 Thread Boris Brezillon
Add the Orion SoC description, and select this implementation by default to support non-DT probing: Orion is the only platform where non-DT boards are declaring the CESA block. Control the allhwsupport module parameter to avoid probing the CESA IP when the old CESA driver is enabled (unless it is

[PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-16 Thread Boris Brezillon
The CESA IP supports CPU offload through a dedicated DMA engine (TDMA) which can control the crypto block. When you use this mode, all the required data (operation metadata and payload data) are transferred using DMA, and the results are retrieved through DMA when possible (hash results are not

[PATCH v5 08/14] crypto: marvell/CESA: add MD5 support

2015-06-16 Thread Boris Brezillon
From: Arnaud Ebalard a...@natisbad.org Add support for MD5 operations. Signed-off-by: Arnaud Ebalard a...@natisbad.org Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- drivers/crypto/marvell/cesa.c | 2 + drivers/crypto/marvell/cesa.h | 2 +

[PATCH v5 07/14] crypto: marvell/CESA: add Triple-DES support

2015-06-16 Thread Boris Brezillon
From: Arnaud Ebalard a...@natisbad.org Add support for Triple-DES operations. Signed-off-by: Arnaud Ebalard a...@natisbad.org Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com --- drivers/crypto/marvell/cesa.c | 2 + drivers/crypto/marvell/cesa.h | 2 +