[PATCH V3] crypto/nx842: Add CRC and validation support

2015-10-08 Thread Haren Myneni

This patch adds CRC generation and validation support for nx-842.
Add CRC flag so that nx842 coprocessor includes CRC during compression
and validates during decompression.

Also changes in 842 SW compression to append CRC value at the end
of template and checks during decompression.

Signed-off-by: Haren Myneni 
---
Changes in V2: 
 Added CRC and validation support in 842 SW compression/ decompression
Changes in v3:
 Whitespace format changes

 drivers/crypto/nx/nx-842-powernv.c |4 ++--
 drivers/crypto/nx/nx-842-pseries.c |8 ++--
 lib/842/842.h  |2 ++
 lib/842/842_compress.c |   13 +
 lib/842/842_decompress.c   |   17 +
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/nx/nx-842-powernv.c 
b/drivers/crypto/nx/nx-842-powernv.c
index 3750e13..9ef51fa 100644
--- a/drivers/crypto/nx/nx-842-powernv.c
+++ b/drivers/crypto/nx/nx-842-powernv.c
@@ -491,7 +491,7 @@ static int nx842_powernv_compress(const unsigned char *in, 
unsigned int inlen,
  void *wmem)
 {
return nx842_powernv_function(in, inlen, out, outlenp,
- wmem, CCW_FC_842_COMP_NOCRC);
+ wmem, CCW_FC_842_COMP_CRC);
 }
 
 /**
@@ -519,7 +519,7 @@ static int nx842_powernv_decompress(const unsigned char 
*in, unsigned int inlen,
void *wmem)
 {
return nx842_powernv_function(in, inlen, out, outlenp,
- wmem, CCW_FC_842_DECOMP_NOCRC);
+ wmem, CCW_FC_842_DECOMP_CRC);
 }
 
 static int __init nx842_powernv_probe(struct device_node *dn)
diff --git a/drivers/crypto/nx/nx-842-pseries.c 
b/drivers/crypto/nx/nx-842-pseries.c
index f4cbde0..cddc6d8 100644
--- a/drivers/crypto/nx/nx-842-pseries.c
+++ b/drivers/crypto/nx/nx-842-pseries.c
@@ -234,6 +234,10 @@ static int nx842_validate_result(struct device *dev,
dev_dbg(dev, "%s: Out of space in output buffer\n",
__func__);
return -ENOSPC;
+   case 65: /* Calculated CRC doesn't match the passed value */
+   dev_dbg(dev, "%s: CRC mismatch for decompression\n",
+   __func__);
+   return -EINVAL;
case 66: /* Input data contains an illegal template field */
case 67: /* Template indicates data past the end of the input stream */
dev_dbg(dev, "%s: Bad data for decompression (code:%d)\n",
@@ -324,7 +328,7 @@ static int nx842_pseries_compress(const unsigned char *in, 
unsigned int inlen,
slout.entries = (struct nx842_slentry *)workmem->slout;
 
/* Init operation */
-   op.flags = NX842_OP_COMPRESS;
+   op.flags = NX842_OP_COMPRESS_CRC;
csbcpb = &workmem->csbcpb;
memset(csbcpb, 0, sizeof(*csbcpb));
op.csbcpb = nx842_get_pa(csbcpb);
@@ -457,7 +461,7 @@ static int nx842_pseries_decompress(const unsigned char 
*in, unsigned int inlen,
slout.entries = (struct nx842_slentry *)workmem->slout;
 
/* Init operation */
-   op.flags = NX842_OP_DECOMPRESS;
+   op.flags = NX842_OP_DECOMPRESS_CRC;
csbcpb = &workmem->csbcpb;
memset(csbcpb, 0, sizeof(*csbcpb));
op.csbcpb = nx842_get_pa(csbcpb);
diff --git a/lib/842/842.h b/lib/842/842.h
index 7c20003..e0a122b 100644
--- a/lib/842/842.h
+++ b/lib/842/842.h
@@ -76,6 +76,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -98,6 +99,7 @@
 #define I2_BITS(8)
 #define I4_BITS(9)
 #define I8_BITS(8)
+#define CRC_BITS   (32)
 
 #define REPEAT_BITS_MAX(0x3f)
 #define SHORT_DATA_BITS_MAX(0x7)
diff --git a/lib/842/842_compress.c b/lib/842/842_compress.c
index 7ce6894..4051339 100644
--- a/lib/842/842_compress.c
+++ b/lib/842/842_compress.c
@@ -490,6 +490,7 @@ int sw842_compress(const u8 *in, unsigned int ilen,
int ret;
u64 last, next, pad, total;
u8 repeat_count = 0;
+   u32 crc;
 
BUILD_BUG_ON(sizeof(*p) > SW842_MEM_COMPRESS);
 
@@ -580,6 +581,18 @@ skip_comp:
if (ret)
return ret;
 
+   /*
+* crc(0:31) is appended to target data starting with the next
+* bit after End of stream template.
+* nx842 calculates CRC for data in big-endian format. So doing
+* same here so that sw842 decompression can be used for both
+* compressed data.
+*/
+   crc = crc32_be(0, in, ilen);
+   ret = add_bits(p, crc, CRC_BITS);
+   if (ret)
+   return ret;
+
if (p->bit) {
p->out++;
p->olen--;
diff --git a/lib/842/842_decompress.c b/lib/842/842_decompress.c
index 5446ff0..8881dad 100644
--- a/lib/842/842_decompress.c
+++ b/lib/842/842_decompress.c
@@ -285,6 +285,7 @@ int s

[PATCH v2] crypto/jitterentropy-kcapi: remove unnecessary information from a comment

2015-10-08 Thread Alexander Kuleshov
The clocksource does not provide clocksource_register() function since
f893598 commit (clocksource: Mostly kill clocksource_register()), so
let's remove unnecessary information about this function from a comment.

Signed-off-by: Alexander Kuleshov 
Suggested-by: Herbert Xu 
---
 crypto/jitterentropy-kcapi.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
index ceea83d..597cedd 100644
--- a/crypto/jitterentropy-kcapi.c
+++ b/crypto/jitterentropy-kcapi.c
@@ -98,10 +98,6 @@ void jent_get_nstime(__u64 *out)
 * If random_get_entropy does not return a value (which is possible on,
 * for example, MIPS), invoke __getnstimeofday
 * hoping that there are timers we can work with.
-*
-* The list of available timers can be obtained from
-* /sys/devices/system/clocksource/clocksource0/available_clocksource
-* and are registered with clocksource_register()
 */
if ((0 == tmp) &&
   (0 == __getnstimeofday(&ts))) {
-- 
2.6.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 v6 2/2] crypto: akcipher - Changes to asymmetric key API

2015-10-08 Thread Tadeusz Struk
Setkey function has been split into set_priv_key and set_pub_key.
Akcipher requests takes sgl for src and dst instead of void *.
Users of the API i.e. two existing RSA implementation and
test mgr code have been updated accordingly.

Signed-off-by: Tadeusz Struk 
---
 crypto/Makefile   |9 +
 crypto/rsa.c  |   83 +---
 crypto/rsa_helper.c   |   42 +++-
 crypto/rsakey.asn1|5 
 crypto/rsaprivkey.asn1|   11 +
 crypto/rsapubkey.asn1 |4 
 crypto/testmgr.c  |   39 ++--
 crypto/testmgr.h  |   36 +++-
 drivers/crypto/qat/qat_common/Makefile|   12 +
 drivers/crypto/qat/qat_common/qat_asym_algs.c |  213 -
 drivers/crypto/qat/qat_common/qat_rsakey.asn1 |5 
 drivers/crypto/qat/qat_common/qat_rsaprivkey.asn1 |   11 +
 drivers/crypto/qat/qat_common/qat_rsapubkey.asn1  |4 
 include/crypto/akcipher.h |   90 +++--
 include/crypto/internal/rsa.h |7 -
 15 files changed, 407 insertions(+), 164 deletions(-)
 delete mode 100644 crypto/rsakey.asn1
 create mode 100644 crypto/rsaprivkey.asn1
 create mode 100644 crypto/rsapubkey.asn1
 delete mode 100644 drivers/crypto/qat/qat_common/qat_rsakey.asn1
 create mode 100644 drivers/crypto/qat/qat_common/qat_rsaprivkey.asn1
 create mode 100644 drivers/crypto/qat/qat_common/qat_rsapubkey.asn1

diff --git a/crypto/Makefile b/crypto/Makefile
index e2c5981..d897e0b 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -31,10 +31,13 @@ obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o
 obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 
-$(obj)/rsakey-asn1.o: $(obj)/rsakey-asn1.c $(obj)/rsakey-asn1.h
-clean-files += rsakey-asn1.c rsakey-asn1.h
+$(obj)/rsapubkey-asn1.o: $(obj)/rsapubkey-asn1.c $(obj)/rsapubkey-asn1.h
+$(obj)/rsaprivkey-asn1.o: $(obj)/rsaprivkey-asn1.c $(obj)/rsaprivkey-asn1.h
+clean-files += rsapubkey-asn1.c rsapubkey-asn1.h
+clean-files += rsaprivkey-asn1.c rsaprivkey-asn1.h
 
-rsa_generic-y := rsakey-asn1.o
+rsa_generic-y := rsapubkey-asn1.o
+rsa_generic-y += rsaprivkey-asn1.o
 rsa_generic-y += rsa.o
 rsa_generic-y += rsa_helper.o
 obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
diff --git a/crypto/rsa.c b/crypto/rsa.c
index 466003e..1093e04 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -97,24 +97,21 @@ static int rsa_enc(struct akcipher_request *req)
goto err_free_c;
}
 
-   m = mpi_read_raw_data(req->src, req->src_len);
-   if (!m) {
-   ret = -ENOMEM;
+   ret = -ENOMEM;
+   m = mpi_read_raw_from_sgl(req->src, req->src_len);
+   if (!m)
goto err_free_c;
-   }
 
ret = _rsa_enc(pkey, c, m);
if (ret)
goto err_free_m;
 
-   ret = mpi_read_buffer(c, req->dst, req->dst_len, &req->dst_len, &sign);
+   ret = mpi_write_to_sgl(c, req->dst, &req->dst_len, &sign);
if (ret)
goto err_free_m;
 
-   if (sign < 0) {
+   if (sign < 0)
ret = -EBADMSG;
-   goto err_free_m;
-   }
 
 err_free_m:
mpi_free(m);
@@ -145,25 +142,21 @@ static int rsa_dec(struct akcipher_request *req)
goto err_free_m;
}
 
-   c = mpi_read_raw_data(req->src, req->src_len);
-   if (!c) {
-   ret = -ENOMEM;
+   ret = -ENOMEM;
+   c = mpi_read_raw_from_sgl(req->src, req->src_len);
+   if (!c)
goto err_free_m;
-   }
 
ret = _rsa_dec(pkey, m, c);
if (ret)
goto err_free_c;
 
-   ret = mpi_read_buffer(m, req->dst, req->dst_len, &req->dst_len, &sign);
+   ret = mpi_write_to_sgl(m, req->dst, &req->dst_len, &sign);
if (ret)
goto err_free_c;
 
-   if (sign < 0) {
+   if (sign < 0)
ret = -EBADMSG;
-   goto err_free_c;
-   }
-
 err_free_c:
mpi_free(c);
 err_free_m:
@@ -193,24 +186,21 @@ static int rsa_sign(struct akcipher_request *req)
goto err_free_s;
}
 
-   m = mpi_read_raw_data(req->src, req->src_len);
-   if (!m) {
-   ret = -ENOMEM;
+   ret = -ENOMEM;
+   m = mpi_read_raw_from_sgl(req->src, req->src_len);
+   if (!m)
goto err_free_s;
-   }
 
ret = _rsa_sign(pkey, s, m);
if (ret)
goto err_free_m;
 
-   ret = mpi_read_buffer(s, req->dst, req->dst_len, &req->dst_len, &sign);
+   ret = mpi_write_to_sgl(s, req->dst, &req->dst_len, &sign);
if (ret)
goto err_free_m;
 
-   if (sign < 0) {
+   if (sign < 0)
ret = -EBADMSG;
-   goto err_free_m;
-   }
 
 err_free_m:
mpi_free(m);
@@ -241,7 +231,8 @@ st

[PATCH v6 1/2] lib/mpi: Add mpi sgl helpers

2015-10-08 Thread Tadeusz Struk
Add mpi_read_raw_from_sgl and mpi_write_to_sgl helpers.

Signed-off-by: Tadeusz Struk 
---
 include/linux/mpi.h |4 +
 lib/mpi/mpicoder.c  |  196 +++
 2 files changed, 200 insertions(+)

diff --git a/include/linux/mpi.h b/include/linux/mpi.h
index 641b7d6..8b8269f 100644
--- a/include/linux/mpi.h
+++ b/include/linux/mpi.h
@@ -31,6 +31,7 @@
 #define G10_MPI_H
 
 #include 
+#include 
 
 /* DSI defines */
 
@@ -78,6 +79,7 @@ void mpi_swap(MPI a, MPI b);
 MPI do_encode_md(const void *sha_buffer, unsigned nbits);
 MPI mpi_read_raw_data(const void *xbuffer, size_t nbytes);
 MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread);
+MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len);
 int mpi_fromstr(MPI val, const char *str);
 u32 mpi_get_keyid(MPI a, u32 *keyid);
 void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign);
@@ -85,6 +87,8 @@ int mpi_read_buffer(MPI a, uint8_t *buf, unsigned buf_len, 
unsigned *nbytes,
int *sign);
 void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign);
 int mpi_set_buffer(MPI a, const void *buffer, unsigned nbytes, int sign);
+int mpi_write_to_sgl(MPI a, struct scatterlist *sg, unsigned *nbytes,
+int *sign);
 
 #define log_mpidump g10_log_mpidump
 
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index 95c52a9..c20ef27 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -319,3 +319,199 @@ int mpi_set_buffer(MPI a, const void *xbuffer, unsigned 
nbytes, int sign)
return 0;
 }
 EXPORT_SYMBOL_GPL(mpi_set_buffer);
+
+/**
+ * mpi_write_to_sgl() - Funnction exports MPI to an sgl (msb first)
+ *
+ * This function works in the same way as the mpi_read_buffer, but it
+ * takes an sgl instead of u8 * buf.
+ *
+ * @a: a multi precision integer
+ * @sgl:   scatterlist to write to. Needs to be at least
+ * mpi_get_size(a) long.
+ * @nbytes:in/out param - it has the be set to the maximum number of
+ * bytes that can be written to sgl. This has to be at least
+ * the size of the integer a. On return it receives the actual
+ * length of the data written.
+ * @sign:  if not NULL, it will be set to the sign of a.
+ *
+ * Return: 0 on success or error code in case of error
+ */
+int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes,
+int *sign)
+{
+   u8 *p, *p2;
+   mpi_limb_t alimb, alimb2;
+   unsigned int n = mpi_get_size(a);
+   int i, x, y = 0, lzeros = 0, buf_len;
+
+   if (!nbytes || *nbytes < n)
+   return -EINVAL;
+
+   if (sign)
+   *sign = a->sign;
+
+   p = (void *)&a->d[a->nlimbs] - 1;
+
+   for (i = a->nlimbs * sizeof(alimb) - 1; i >= 0; i--, p--) {
+   if (!*p)
+   lzeros++;
+   else
+   break;
+   }
+
+   *nbytes = n - lzeros;
+   buf_len = sgl->length;
+   p2 = sg_virt(sgl);
+
+   for (i = a->nlimbs - 1; i >= 0; i--) {
+   alimb = a->d[i];
+   p = (u8 *)&alimb2;
+#if BYTES_PER_MPI_LIMB == 4
+   *p++ = alimb >> 24;
+   *p++ = alimb >> 16;
+   *p++ = alimb >> 8;
+   *p++ = alimb;
+#elif BYTES_PER_MPI_LIMB == 8
+   *p++ = alimb >> 56;
+   *p++ = alimb >> 48;
+   *p++ = alimb >> 40;
+   *p++ = alimb >> 32;
+   *p++ = alimb >> 24;
+   *p++ = alimb >> 16;
+   *p++ = alimb >> 8;
+   *p++ = alimb;
+#else
+#error please implement for this limb size.
+#endif
+   if (lzeros > 0) {
+   if (lzeros >= sizeof(alimb)) {
+   p -= sizeof(alimb);
+   continue;
+   } else {
+   mpi_limb_t *limb1 = (void *)p - sizeof(alimb);
+   mpi_limb_t *limb2 = (void *)p - sizeof(alimb)
+   + lzeros;
+   *limb1 = *limb2;
+   p -= lzeros;
+   y = lzeros;
+   }
+   lzeros -= sizeof(alimb);
+   }
+
+   p = p - (sizeof(alimb) - y);
+
+   for (x = 0; x < sizeof(alimb) - y; x++) {
+   if (!buf_len) {
+   sgl = sg_next(sgl);
+   if (!sgl)
+   return -EINVAL;
+   buf_len = sgl->length;
+   p2 = sg_virt(sgl);
+   }
+   *p2++ = *p++;
+   buf_len--;
+   }
+   y = 0;
+   }
+   return 0;
+}
+EXPORT_SYMBOL_GPL(mpi_write_to_sgl);
+
+/*
+ * mpi_read_raw_f

[PATCH v6 0/2] crypto: akcipher - Changes to asymmetric key API

2015-10-08 Thread Tadeusz Struk
This series updates the asymmetric key API.
The changes include
 - setkey function has been split into set_priv_key and set_pub_key.
 - akcipher requests takes sgl for src and dst instead of void *.
Users of the API i.e. two existing RSA implementation and
test mgr code have been updated accordingly.

First patch adds sgl helpers to mpi library.
Second patch implements the API changes in rsa-generic and rsa-qat

Changes in v6:
- changed mpi_write_to_sgl to take and verify the maximum length
  of bytes to write 
- removed include scatterlist.h in akcipher.h
- renamed crypto_akcipher_get_len() to crypto_akcipher_maxsize()

Changes in v5:
- droped the sg_len patch as it was not needed

Changes in v4:
- add back src_len and dst_len
- add sgl helpers to mpi library
- change rsa-generic implementation to use the new mpi helpers

Changes in v3:
- changed type returned from sg_len from int to unsigned int

Changes in v2:
- dropped patches that checked value returned by crypto_unregister_alg
- flatten patches 4 and 6-8 from v1 into one patch.  
---

Tadeusz Struk (2):
  lib/mpi: Add mpi sgl helpers
  crypto: akcipher - Changes to asymmetric key API


 crypto/Makefile   |9 +
 crypto/rsa.c  |   83 +---
 crypto/rsa_helper.c   |   42 +++-
 crypto/rsakey.asn1|5 
 crypto/rsaprivkey.asn1|   11 +
 crypto/rsapubkey.asn1 |4 
 crypto/testmgr.c  |   39 ++--
 crypto/testmgr.h  |   36 +++-
 drivers/crypto/qat/qat_common/Makefile|   12 +
 drivers/crypto/qat/qat_common/qat_asym_algs.c |  213 -
 drivers/crypto/qat/qat_common/qat_rsakey.asn1 |5 
 drivers/crypto/qat/qat_common/qat_rsaprivkey.asn1 |   11 +
 drivers/crypto/qat/qat_common/qat_rsapubkey.asn1  |4 
 include/crypto/akcipher.h |   90 +++--
 include/crypto/internal/rsa.h |7 -
 include/linux/mpi.h   |4 
 lib/mpi/mpicoder.c|  196 +++
 17 files changed, 607 insertions(+), 164 deletions(-)
 delete mode 100644 crypto/rsakey.asn1
 create mode 100644 crypto/rsaprivkey.asn1
 create mode 100644 crypto/rsapubkey.asn1
 delete mode 100644 drivers/crypto/qat/qat_common/qat_rsakey.asn1
 create mode 100644 drivers/crypto/qat/qat_common/qat_rsaprivkey.asn1
 create mode 100644 drivers/crypto/qat/qat_common/qat_rsapubkey.asn1

--
--
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: unaligned access in pkcs7_verify

2015-10-08 Thread Sowmini Varadhan
On (10/08/15 21:15), Herbert Xu wrote:
> > desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
> > -   sinfo->sig.digest_size = digest_size = crypto_shash_digestsize(tfm);
> > +   sinfo->sig.digest_size = digest_size = 
> > +   ALIGN(crypto_shash_digestsize(tfm), sizeof (*desc));
  :
> What hash algorithm were you using?

Algorithm is sha1. From printk, crypto_shash_descsize(tfm) comes out
to 0x60, digest_size to 0x14. Stack trace (for each modprobe [-r]) is 

pkcs7_verify+0x1d0/0x5e0
system_verify_data+0x54/0xb4
mod_verify_sig+0xa0/0xc4
load_module+0x48/0x16a0
SyS_init_module+0x114/0x128
linux_sparc_syscall+0x34/0x44

--Sowmini


--
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 v2 0/3] hwrng: st: Couple of improvements

2015-10-08 Thread Herbert Xu
On Wed, Oct 07, 2015 at 01:23:26PM +0100, Lee Jones wrote:
> This set contains a minor documentation fix, greater clarification
> with how the FIFO depth/size is represented and finally a fix to
> prevent early timeout during data acquisition.
> 
> v1 => v2:
>  - Remove phantom bugfix (FIFO really is 4 deep, not 8)
>  - Double timeout value to account for inconsistent call to udelay()
>- Suggested-by: Russell King 

All applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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] crypto: atmel: Check for clk_prepare_enable() return value

2015-10-08 Thread Herbert Xu
On Fri, Oct 02, 2015 at 02:12:58PM +0200, LABBE Corentin wrote:
> clk_prepare_enable() can fail so add a check for this and
> return the error code if it fails.
> 
> Signed-off-by: LABBE Corentin 

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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] crypto: qce: dma_map_sg can handle chained SG

2015-10-08 Thread Herbert Xu
On Fri, Oct 02, 2015 at 08:01:02AM +0200, LABBE Corentin wrote:
> The qce driver use two dma_map_sg path according to SG are chained
> or not.
> Since dma_map_sg can handle both case, clean the code with all
> references to sg chained.
> 
> Thus removing qce_mapsg, qce_unmapsg and qce_countsg functions.
> 
> Signed-off-by: LABBE Corentin 

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v1 0/4] crypto: ccp - CCP driver updates 2015-10-01

2015-10-08 Thread Herbert Xu
On Thu, Oct 01, 2015 at 04:32:25PM -0500, Tom Lendacky wrote:
> The following patches are included in this driver update series:
> 
> - Remove the usage of BUG_ON and replace with WARN_ON and an error
>   return code
> - Remove unused variable
> - Change references to accelerator to offload
> - Use the module name in the driver structure instead of a
>   descriptive name
>  
> This patch series is based on cryptodev-2.6.

All applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v5 1/2] lib/mpi: Add mpi sgl helpers

2015-10-08 Thread Herbert Xu
On Thu, Oct 08, 2015 at 06:31:52AM -0700, Tadeusz Struk wrote:
>
> The sgl has to be big enough to take the whole integer.
> What would be the point to export only part of a number?

You're not getting it.  Just because the SGL is X bytes long
it doesn't give you the right to write X bytes.  The number of
bytes that you may write to (let's call it Y) may be smaller.

The value of Y must be passed into the helper and verified.

This is why dst_len exists.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v5 1/2] lib/mpi: Add mpi sgl helpers

2015-10-08 Thread Tadeusz Struk
On 10/08/2015 06:02 AM, Herbert Xu wrote:
> On Thu, Oct 01, 2015 at 10:10:38PM -0700, Tadeusz Struk wrote:
>>
>> +/**
>> + * mpi_write_to_sgl() - Funnction exports MPI to an sgl (msb first)
>> + *
>> + * This function works in the same way as the mpi_read_buffer, but it
>> + * takes an sgl instead of u8 * buf.
>> + *
>> + * @a:  a multi precision integer
>> + * @sgl:scatterlist to write to. Needs to be at least
>> + *  mpi_get_size(a) long.
>> + * @nbytes: receives the actual length of the data written.
>> + * @sign:   if not NULL, it will be set to the sign of a.
>> + *
>> + * Return:  0 on success or error code in case of error
>> + */
>> +int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes,
>> + int *sign)
> 
> Where is the maximum length of sgl? You should not assume that the
> entire SG list is for you to use.  So the length that you are allowed
> to use should be passed in explicitly.  You can just put it into
> nbytes.

The sgl has to be big enough to take the whole integer.
What would be the point to export only part of a number?
--
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 V2] crypto/nx842: Add CRC and validation support

2015-10-08 Thread Herbert Xu
On Sat, Oct 03, 2015 at 09:35:31PM -0700, Haren Myneni wrote:
>
> diff --git a/lib/842/842_decompress.c b/lib/842/842_decompress.c
> index 5446ff0..b0db568 100644
> --- a/lib/842/842_decompress.c
> +++ b/lib/842/842_decompress.c
> @@ -285,6 +285,7 @@ int sw842_decompress(const u8 *in, unsigned int
> ilen,
>   struct sw842_param p;
>   int ret;
>   u64 op, rep, tmp, bytes, total;
> + u64 crc;
>  
>   p.in = (u8 *)in;
>   p.bit = 0;
> @@ -375,6 +376,22 @@ int sw842_decompress(const u8 *in, unsigned int
> ilen,
>   }
>   } while (op != OP_END);

Your patch is white-space corrupted.  Please resend.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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] crypto/jitterentropy-kcapi: fix a comment reflecting function name changed

2015-10-08 Thread Herbert Xu
On Wed, Oct 07, 2015 at 11:38:14PM +0600, Alexander Kuleshov wrote:
> The clocksource does not provide clocksource_register() function since
> f893598 commit (clocksource: Mostly kill clocksource_register()), but
> __clocksource_register() instead.
> 
> Signed-off-by: Alexander Kuleshov 
> ---
>  crypto/jitterentropy-kcapi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c
> index ceea83d..4b030df 100644
> --- a/crypto/jitterentropy-kcapi.c
> +++ b/crypto/jitterentropy-kcapi.c
> @@ -101,7 +101,7 @@ void jent_get_nstime(__u64 *out)
>*
>* The list of available timers can be obtained from
>* /sys/devices/system/clocksource/clocksource0/available_clocksource
> -  * and are registered with clocksource_register()
> +  * and are registered with __clocksource_register()

Please get rid of the reference to clocksource_register altogether.
It's simply unnecessary.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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: unaligned access in pkcs7_verify

2015-10-08 Thread Herbert Xu
On Fri, Oct 02, 2015 at 02:00:14PM +, Sowmini Varadhan wrote:
> 
> I'm getting a lot of unaligned access messages each time I 
> do "modprobe [-r] " on sparc:
> 
> Kernel unaligned access at TPC[6ad9b4] pkcs7_verify+0x1ec/0x5e0
> Kernel unaligned access at TPC[6a5484] crypto_shash_finup+0xc/0x5c
> Kernel unaligned access at TPC[6a5390] crypto_shash_update+0xc/0x54
> Kernel unaligned access at TPC[10150308] sha1_sparc64_update+0x14/0x5c 
> [sha1_sparc64]
> Kernel unaligned access at TPC[101501ac] __sha1_sparc64_update+0xc/0x98 
> [sha1_sparc64]
> 
> Looks like these are being caused by an unaligned desc at
> 
> desc = digest + digest_size;
> 
> Doing this:
> 
> --- a/crypto/asymmetric_keys/pkcs7_verify.c
> +++ b/crypto/asymmetric_keys/pkcs7_verify.c
> @@ -46,7 +46,8 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7,
> return (PTR_ERR(tfm) == -ENOENT) ? -ENOPKG : PTR_ERR(tfm);
>  
> desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
> -   sinfo->sig.digest_size = digest_size = crypto_shash_digestsize(tfm);
> +   sinfo->sig.digest_size = digest_size = 
> +   ALIGN(crypto_shash_digestsize(tfm), sizeof (*desc));
>  
> ret = -ENOMEM;
> digest = kzalloc(digest_size + desc_size, GFP_KERNEL);
> 
> makes the unaliagned message go away, but I dont know if
> sinfo->sig.digest_size needs to be set to the (unaligned) raw 
> value of crypto_shash_digestsize() itself, and how to verify that
> this doesnt break something else in crypto

What hash algorithm were you using?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v5 2/2] crypto: akcipher - Changes to asymmetric key API

2015-10-08 Thread Herbert Xu
On Thu, Oct 01, 2015 at 10:10:43PM -0700, Tadeusz Struk wrote:
>
>  /**
> + * crypto_akcipher_get_len() -- Get minimum len for output buffer
> + *
> + * Function returns minimum dest buffer size for a given key
> + *
> + * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
> + *
> + * Return: minimum len for output buffer or error code in key hasn't been set
> + */
> +static inline int crypto_akcipher_get_len(struct crypto_akcipher *tfm)

Please rename this to something like

crypto_akcipher_maxsize

I presume it's actually the maximum size that would be required
of the destination buffer rather than the minimum.  The latter
would seem to be quite useless.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v5 2/2] crypto: akcipher - Changes to asymmetric key API

2015-10-08 Thread Herbert Xu
On Thu, Oct 01, 2015 at 10:10:43PM -0700, Tadeusz Struk wrote:
>
> diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
> index 69d163e..c55526c 100644
> --- a/include/crypto/akcipher.h
> +++ b/include/crypto/akcipher.h
> @@ -13,26 +13,27 @@
>  #ifndef _CRYPTO_AKCIPHER_H
>  #define _CRYPTO_AKCIPHER_H
>  #include 
> +#include 

Is this actually needed?

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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 v5 1/2] lib/mpi: Add mpi sgl helpers

2015-10-08 Thread Herbert Xu
On Thu, Oct 01, 2015 at 10:10:38PM -0700, Tadeusz Struk wrote:
>
> +/**
> + * mpi_write_to_sgl() - Funnction exports MPI to an sgl (msb first)
> + *
> + * This function works in the same way as the mpi_read_buffer, but it
> + * takes an sgl instead of u8 * buf.
> + *
> + * @a:   a multi precision integer
> + * @sgl: scatterlist to write to. Needs to be at least
> + *   mpi_get_size(a) long.
> + * @nbytes:  receives the actual length of the data written.
> + * @sign:if not NULL, it will be set to the sign of a.
> + *
> + * Return:   0 on success or error code in case of error
> + */
> +int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes,
> +  int *sign)

Where is the maximum length of sgl? You should not assume that the
entire SG list is for you to use.  So the length that you are allowed
to use should be passed in explicitly.  You can just put it into
nbytes.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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