Re: [PATCH v3 1/1] crypto: engine: permit to enqueue ashash_request

2016-06-10 Thread LABBE Corentin
On Tue, Jun 07, 2016 at 06:31:39PM +0800, Herbert Xu wrote:
> On Thu, Jun 02, 2016 at 03:13:32PM +0200, LABBE Corentin wrote:
> >
> >  static int omap_aes_prepare_req(struct crypto_engine *engine,
> > -   struct ablkcipher_request *req)
> > +   struct crypto_async_request *areq)
> >  {
> > +   struct ablkcipher_request *req = ablkcipher_request_cast(areq);
> 
> You're still doing casting in the driver.
> 
> I want this to be moved into the crypto engine API.  There should
> be separate function pointers for each request type.
> 
> Thanks,
> -- 

So I need to split do_one_request to cipher_one_request/hash_one_request.
Same with prepare_request to prepare_hash_request/prepare_cipher_request.
With the choice of each function done in crypto_engine.c.

Since this modification need to add  to algapi.h, I think it is 
necessary to move all crypto engine stuff to crypto/engine.h
Do you agree ?

Regards

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/6] crypto: AF_ALG -- add asymmetric cipher interface

2016-06-10 Thread Tadeusz Struk
On 06/09/2016 11:36 AM, Stephan Mueller wrote:
> Am Donnerstag, 9. Juni 2016, 11:27:13 schrieb Mat Martineau:
> 
> Hi Mat, Tadeusz,
> 
>> On Thu, 9 Jun 2016, Stephan Mueller wrote:
>>> Am Donnerstag, 9. Juni 2016, 11:18:04 schrieb Mat Martineau:
>>>
>>> Hi Mat,
>>>
> Or is your concern that the user space interface restricts things too
> much
> and thus prevents a valid use case?

 The latter - my primary concern is the constraint this places on
 userspace
 by forcing larger buffer sizes than might be necessary for the operation.
 struct akcipher_request has separate members for src_len and dst_len, and
 dst_len is documented as needing "to be at least as big as the expected
 result depending on the operation". Not the maximum result, the expected
 result. It's also documented that the cipher will generate an error if
 dst_len is insufficient and update the value with the required size.

 I'm updating some userspace TLS code that worked with an earlier,
 unmerged
 patch set for AF_ALG akcipher (from last year). The read calls with
 shorter buffers were the main porting problem.
>>>
>>> I see -- are you proposing to drop that check entirely?
>>
>> Yes.
> 
> Ok, after checking the code again, I think that dropping that sanity check 
> should be ok given that this length is part of the akcipher API.
> 
> Tadeusz, as you are currently managing that patch set, would you re-spin it 
> with the following check removed?
> 
> + if (usedpages < akcipher_calcsize(ctx)) {
> + err = -EMSGSIZE;
> + goto unlock;
> + }
> 

Ok, I'll update the patch.
Thanks,
-- 
TS
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 23/28] ARM: dts: DRA7: Add DT node for DES IP

2016-06-10 Thread Tony Lindgren
* Tero Kristo  [160601 02:09]:
> From: Joel Fernandes 
> 
> DRA7xx SoCs have a DES3DES IP. Add DT data for the same.

Are these dts changes safe to apply separately or do they
cause issues like extra warnings during boot?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] hw_random: Add Amlogic Meson SoCs Random Generator driver

2016-06-10 Thread Neil Armstrong
Add support for the Amlogic Meson SoCs Hardware Random generator as a hw_random 
char driver.
The generator is a single 32bit wide register.
Also adds the Meson GXBB SoC DTSI node and corresponding DT bindings.

Changes since v1 at 
http://lkml.kernel.org/r/1464943621-18278-1-git-send-email-narmstr...@baylibre.com
 :
- change to depend on ARCH_MESON || COMPILE_TEST
- check buffer max size in read

Neil Armstrong (3):
  char: hw_random: Add Amlogic Meson Hardware Random Generator
  dt-bindings: hwrng: Add Amlogic Meson Hardware Random Generator
bindings
  ARM64: dts: meson-gxbb: Add Hardware Random Generator node

 .../devicetree/bindings/rng/amlogic,meson-rng.txt  |  14 +++
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi|   5 +
 drivers/char/hw_random/Kconfig |  14 +++
 drivers/char/hw_random/Makefile|   1 +
 drivers/char/hw_random/meson-rng.c | 131 +
 5 files changed, 165 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt
 create mode 100644 drivers/char/hw_random/meson-rng.c

-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] dt-bindings: hwrng: Add Amlogic Meson Hardware Random Generator bindings

2016-06-10 Thread Neil Armstrong
Acked-by: Rob Herring 
Signed-off-by: Neil Armstrong 
---
 .../devicetree/bindings/rng/amlogic,meson-rng.txt  | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt

diff --git a/Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt 
b/Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt
new file mode 100644
index 000..202f2d0
--- /dev/null
+++ b/Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt
@@ -0,0 +1,14 @@
+Amlogic Meson Random number generator
+=
+
+Required properties:
+
+- compatible : should be "amlogic,meson-rng"
+- reg : Specifies base physical address and size of the registers.
+
+Example:
+
+rng {
+compatible = "amlogic,meson-rng";
+reg = <0x0 0xc8834000 0x0 0x4>;
+};
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] ARM64: dts: meson-gxbb: Add Hardware Random Generator node

2016-06-10 Thread Neil Armstrong
Signed-off-by: Neil Armstrong 
---
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi 
b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 832815d..8353621 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -167,6 +167,11 @@
};
};
 
+   rng {
+   compatible = "amlogic,meson-rng";
+   reg = <0x0 0xc8834000 0x0 0x4>;
+   };
+
apb: apb@d000 {
compatible = "simple-bus";
reg = <0x0 0xd000 0x0 0x20>;
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] char: hw_random: Add Amlogic Meson Hardware Random Generator

2016-06-10 Thread Neil Armstrong
Add support for the Amlogic Meson SoCs hardware random generator.

Signed-off-by: Neil Armstrong 
---
 drivers/char/hw_random/Kconfig |  14 
 drivers/char/hw_random/Makefile|   1 +
 drivers/char/hw_random/meson-rng.c | 131 +
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/char/hw_random/meson-rng.c

diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index ac51149..8558a61 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -396,6 +396,20 @@ config HW_RANDOM_PIC32
 
  If unsure, say Y.
 
+config HW_RANDOM_MESON
+   tristate "Amlogic Meson Random Number Generator support"
+   depends on HW_RANDOM
+   depends on ARCH_MESON || COMPILE_TEST
+   default y
+   ---help---
+ This driver provides kernel-side support for the Random Number
+ Generator hardware found on Amlogic Meson SoCs.
+
+ To compile this driver as a module, choose M here. the
+ module will be called meson-rng.
+
+ If unsure, say Y.
+
 endif # HW_RANDOM
 
 config UML_RANDOM
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index 63022b4..04bb0b0 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -34,3 +34,4 @@ obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o
 obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o
 obj-$(CONFIG_HW_RANDOM_STM32) += stm32-rng.o
 obj-$(CONFIG_HW_RANDOM_PIC32) += pic32-rng.o
+obj-$(CONFIG_HW_RANDOM_MESON) += meson-rng.o
diff --git a/drivers/char/hw_random/meson-rng.c 
b/drivers/char/hw_random/meson-rng.c
new file mode 100644
index 000..0cfd81b
--- /dev/null
+++ b/drivers/char/hw_random/meson-rng.c
@@ -0,0 +1,131 @@
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright (c) 2016 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ * Copyright (C) 2014 Amlogic, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * BSD LICENSE
+ *
+ * Copyright (c) 2016 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ * Copyright (C) 2014 Amlogic, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *   * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RNG_DATA 0x00
+
+struct meson_rng_data {
+   void __iomem *base;
+   struct platform_device *pdev;
+   struct hwrng rng;
+};
+
+static int meson_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
+{
+   struct meson_rng_data *data =
+   container_of(rng, struct meson_rng_data, rng);
+
+   if (max < sizeof(u32))
+   return 0;
+
+   *(u32 *)buf = readl_relaxed(data->base + RNG_DATA);
+
+   return si