Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Mon, Aug 17, 2015 at 06:05:04PM -0700, Tadeusz Struk wrote:
> On 08/17/2015 01:50 AM, Herbert Xu wrote:
> >> If you don't like the first option then we still need this, as you pointed 
> >> out.
> > Yes this looks like the right fix for qat.  Please add a sign-off.
> > You might be able to just do it by replying to this thread, and
> > patchwork may be able to pick it up and attach it to the patch.
> 
> Signed-off-by: Tadeusz Struk 

Applied.  Please also fix the software implementation when you
get back.

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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Tadeusz Struk
On 08/17/2015 01:50 AM, Herbert Xu wrote:
>> If you don't like the first option then we still need this, as you pointed 
>> out.
> Yes this looks like the right fix for qat.  Please add a sign-off.
> You might be able to just do it by replying to this thread, and
> patchwork may be able to pick it up and attach it to the patch.

Signed-off-by: Tadeusz Struk 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Fri, Aug 14, 2015 at 07:24:23AM -0700, Tadeusz Struk wrote:
>
> If you don't like the first option then we still need this, as you pointed 
> out.

Yes this looks like the right fix for qat.  Please add a sign-off.
You might be able to just do it by replying to this thread, and
patchwork may be able to pick it up and attach it to the patch.

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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Fri, Aug 14, 2015 at 07:21:29AM -0700, Tadeusz Struk wrote:
> 
> Yes, that was wrong, sorry. The reason I wanted to change it is that
> the SW implementation can return a number with leading zeros.
> This is because mpi_read_buffer() returns the whole thing.

I think mpi_read_buffer is broken.  It should return exactly the
same thing as mpi_get_buffer, except that it should do so in the
buffer provided instead of allocating a new one.

So it most certainly should remove all leading zero bytes.

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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Mon, Aug 17, 2015 at 06:05:04PM -0700, Tadeusz Struk wrote:
 On 08/17/2015 01:50 AM, Herbert Xu wrote:
  If you don't like the first option then we still need this, as you pointed 
  out.
  Yes this looks like the right fix for qat.  Please add a sign-off.
  You might be able to just do it by replying to this thread, and
  patchwork may be able to pick it up and attach it to the patch.
 
 Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com

Applied.  Please also fix the software implementation when you
get back.

Thanks!
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Tadeusz Struk
On 08/17/2015 01:50 AM, Herbert Xu wrote:
 If you don't like the first option then we still need this, as you pointed 
 out.
 Yes this looks like the right fix for qat.  Please add a sign-off.
 You might be able to just do it by replying to this thread, and
 patchwork may be able to pick it up and attach it to the patch.

Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Fri, Aug 14, 2015 at 07:24:23AM -0700, Tadeusz Struk wrote:

 If you don't like the first option then we still need this, as you pointed 
 out.

Yes this looks like the right fix for qat.  Please add a sign-off.
You might be able to just do it by replying to this thread, and
patchwork may be able to pick it up and attach it to the patch.

Thanks,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-17 Thread Herbert Xu
On Fri, Aug 14, 2015 at 07:21:29AM -0700, Tadeusz Struk wrote:
 
 Yes, that was wrong, sorry. The reason I wanted to change it is that
 the SW implementation can return a number with leading zeros.
 This is because mpi_read_buffer() returns the whole thing.

I think mpi_read_buffer is broken.  It should return exactly the
same thing as mpi_get_buffer, except that it should do so in the
buffer provided instead of allocating a new one.

So it most certainly should remove all leading zero bytes.

Cheers,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
On 08/13/2015 11:26 PM, Herbert Xu wrote:
> On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:
>>
>> Right, but we don't need that anymore.
> 
> Why not? If you reduce the size without moving the buffer wouldn't
> it begin with a bunch of zeroes and wouldn't you lose the real bytes
> at the end?
> 

If you don't like the first option then we still need this, as you pointed out.

---8<---

Change memcpy to memmove because the copy is done within the same buffer.

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..e87f510 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -145,7 +145,7 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
}
 
if (areq->dst_len != req->ctx->key_sz)
-   memcpy(areq->dst, ptr, areq->dst_len);
+   memmove(areq->dst, ptr, areq->dst_len);
 
akcipher_request_complete(areq, err);
 }


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


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
Hi Herbert,
On 08/13/2015 11:26 PM, Herbert Xu wrote:
> On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:
>>
>> Right, but we don't need that anymore.
> 
> Why not? If you reduce the size without moving the buffer wouldn't
> it begin with a bunch of zeroes and wouldn't you lose the real bytes
> at the end?

Yes, that was wrong, sorry. The reason I wanted to change it is that
the SW implementation can return a number with leading zeros.
This is because mpi_read_buffer() returns the whole thing.

Because the format of the module signature starts with 0x00, 0x01
the two implementations return a different thing.
For instance SW returned a 512 bytes number starting with 0x00, 0x01
and HW returned 511 bytes number without the 0x00 at the beginning.
Technically both are correct, but then the rsa_signture_verify()
needs to check for both cases, which is not ideal.
To make it return the same thing as SW we can do something like this:

---8<---

Allow for leading zeros in output to make it exactly the same as the
SW implementation.
Change memcpy to memmove because the copy is done within the same buffer.

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..cc450fa 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -118,7 +118,13 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
struct device *dev = _DEV(req->ctx->inst->accel_dev);
int err = ICP_QAT_FW_PKE_RESP_PKE_STAT_GET(
resp->pke_resp_hdr.comn_resp_flags);
-   char *ptr = areq->dst;
+#if BYTES_PER_MPI_LIMB == 4
+   u32 *ptr = areq->dst;
+#elif BYTES_PER_MPI_LIMB == 8
+   u64 *ptr = areq->dst;
+#else
+#error please implement for this limb size.
+#endif
 
err = (err == ICP_QAT_FW_COMN_STATUS_FLAG_OK) ? 0 : -EINVAL;
 
@@ -140,12 +146,12 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
areq->dst_len = req->ctx->key_sz;
/* Need to set the corect length of the output */
while (!(*ptr) && areq->dst_len) {
-   areq->dst_len--;
+   areq->dst_len -= sizeof(*ptr);
ptr++;
}
 
if (areq->dst_len != req->ctx->key_sz)
-   memcpy(areq->dst, ptr, areq->dst_len);
+   memmove(areq->dst, ptr, areq->dst_len);
 
akcipher_request_complete(areq, err);
 }

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


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Herbert Xu
On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:
> 
> Right, but we don't need that anymore.

Why not? If you reduce the size without moving the buffer wouldn't
it begin with a bunch of zeroes and wouldn't you lose the real bytes
at the end?

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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
On 08/13/2015 10:14 PM, Herbert Xu wrote:
>> diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
>> b/drivers/crypto/qat/qat_common/qat_asym_algs.c
>> > index fe352a6..6ddb13c 100644
>> > --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
>> > +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
>> > @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp 
>> > *resp)
>> >ptr++;
>> >}
>> >  
>> > -  if (areq->dst_len != req->ctx->key_sz)
>> > -  memcpy(areq->dst, ptr, areq->dst_len);
>> > -
> This looks wrong.  It appears to be trying to remove leading
> zeroes so you can't just change the length because then you end
> up removing the trailing digits equal to the number of leading
> zeroes.

What it does is it sets the size of the output number, not the size of the 
output buffer.
The size of the buffer is set beforehand to the size of the modulo, which is 
the biggest
possible output.

> 
> The existing code is also wrong as you should be using memmove
> instead of memcpy.

Right, but we don't need that anymore.

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


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Herbert Xu
On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:
 
 Right, but we don't need that anymore.

Why not? If you reduce the size without moving the buffer wouldn't
it begin with a bunch of zeroes and wouldn't you lose the real bytes
at the end?

Cheers,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
On 08/13/2015 10:14 PM, Herbert Xu wrote:
 diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
 b/drivers/crypto/qat/qat_common/qat_asym_algs.c
  index fe352a6..6ddb13c 100644
  --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
  +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
  @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp 
  *resp)
 ptr++;
 }
   
  -  if (areq-dst_len != req-ctx-key_sz)
  -  memcpy(areq-dst, ptr, areq-dst_len);
  -
 This looks wrong.  It appears to be trying to remove leading
 zeroes so you can't just change the length because then you end
 up removing the trailing digits equal to the number of leading
 zeroes.

What it does is it sets the size of the output number, not the size of the 
output buffer.
The size of the buffer is set beforehand to the size of the modulo, which is 
the biggest
possible output.

 
 The existing code is also wrong as you should be using memmove
 instead of memcpy.

Right, but we don't need that anymore.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
Hi Herbert,
On 08/13/2015 11:26 PM, Herbert Xu wrote:
 On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:

 Right, but we don't need that anymore.
 
 Why not? If you reduce the size without moving the buffer wouldn't
 it begin with a bunch of zeroes and wouldn't you lose the real bytes
 at the end?

Yes, that was wrong, sorry. The reason I wanted to change it is that
the SW implementation can return a number with leading zeros.
This is because mpi_read_buffer() returns the whole thing.

Because the format of the module signature starts with 0x00, 0x01
the two implementations return a different thing.
For instance SW returned a 512 bytes number starting with 0x00, 0x01
and HW returned 511 bytes number without the 0x00 at the beginning.
Technically both are correct, but then the rsa_signture_verify()
needs to check for both cases, which is not ideal.
To make it return the same thing as SW we can do something like this:

---8---

Allow for leading zeros in output to make it exactly the same as the
SW implementation.
Change memcpy to memmove because the copy is done within the same buffer.

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..cc450fa 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -118,7 +118,13 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
struct device *dev = GET_DEV(req-ctx-inst-accel_dev);
int err = ICP_QAT_FW_PKE_RESP_PKE_STAT_GET(
resp-pke_resp_hdr.comn_resp_flags);
-   char *ptr = areq-dst;
+#if BYTES_PER_MPI_LIMB == 4
+   u32 *ptr = areq-dst;
+#elif BYTES_PER_MPI_LIMB == 8
+   u64 *ptr = areq-dst;
+#else
+#error please implement for this limb size.
+#endif
 
err = (err == ICP_QAT_FW_COMN_STATUS_FLAG_OK) ? 0 : -EINVAL;
 
@@ -140,12 +146,12 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
areq-dst_len = req-ctx-key_sz;
/* Need to set the corect length of the output */
while (!(*ptr)  areq-dst_len) {
-   areq-dst_len--;
+   areq-dst_len -= sizeof(*ptr);
ptr++;
}
 
if (areq-dst_len != req-ctx-key_sz)
-   memcpy(areq-dst, ptr, areq-dst_len);
+   memmove(areq-dst, ptr, areq-dst_len);
 
akcipher_request_complete(areq, err);
 }

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-14 Thread Tadeusz Struk
On 08/13/2015 11:26 PM, Herbert Xu wrote:
 On Thu, Aug 13, 2015 at 11:14:11PM -0700, Tadeusz Struk wrote:

 Right, but we don't need that anymore.
 
 Why not? If you reduce the size without moving the buffer wouldn't
 it begin with a bunch of zeroes and wouldn't you lose the real bytes
 at the end?
 

If you don't like the first option then we still need this, as you pointed out.

---8---

Change memcpy to memmove because the copy is done within the same buffer.

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..e87f510 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -145,7 +145,7 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
}
 
if (areq-dst_len != req-ctx-key_sz)
-   memcpy(areq-dst, ptr, areq-dst_len);
+   memmove(areq-dst, ptr, areq-dst_len);
 
akcipher_request_complete(areq, err);
 }


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-13 Thread Herbert Xu
On Wed, Aug 12, 2015 at 08:54:45PM -0700, Tadeusz Struk wrote:
> Don't need to move data inside of the output buffer
> because SW doen't need to do this anymore sice the new MPI
> mpi_read_buf() has been added. Just set the correct output len.
> 
> Signed-off-by: Tadeusz Struk 
> ---
>  drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
> b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> index fe352a6..6ddb13c 100644
> --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
> +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
>   ptr++;
>   }
>  
> - if (areq->dst_len != req->ctx->key_sz)
> - memcpy(areq->dst, ptr, areq->dst_len);
> -

This looks wrong.  It appears to be trying to remove leading
zeroes so you can't just change the length because then you end
up removing the trailing digits equal to the number of leading
zeroes.

The existing code is also wrong as you should be using memmove
instead of memcpy.

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-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-13 Thread Tadeusz Struk
On 08/12/2015 08:54 PM, Tadeusz Struk wrote:
> Don't need to move data inside of the output buffer
> because SW doen't need to do this anymore sice the new MPI
> mpi_read_buf() has been added. Just set the correct output len.
> 
> Signed-off-by: Tadeusz Struk 
> ---
>  drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
> b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> index fe352a6..6ddb13c 100644
> --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
> +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
>   ptr++;
>   }
>  
> - if (areq->dst_len != req->ctx->key_sz)
> - memcpy(areq->dst, ptr, areq->dst_len);
> -
>   akcipher_request_complete(areq, err);
>  }
>  
> 

Herbert,
Could you take this one and I'll work with David on the rest.
Thanks,
T
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-13 Thread Tadeusz Struk
On 08/12/2015 08:54 PM, Tadeusz Struk wrote:
 Don't need to move data inside of the output buffer
 because SW doen't need to do this anymore sice the new MPI
 mpi_read_buf() has been added. Just set the correct output len.
 
 Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com
 ---
  drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
  1 file changed, 3 deletions(-)
 
 diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
 b/drivers/crypto/qat/qat_common/qat_asym_algs.c
 index fe352a6..6ddb13c 100644
 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
 +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
 @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
   ptr++;
   }
  
 - if (areq-dst_len != req-ctx-key_sz)
 - memcpy(areq-dst, ptr, areq-dst_len);
 -
   akcipher_request_complete(areq, err);
  }
  
 

Herbert,
Could you take this one and I'll work with David on the rest.
Thanks,
T
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-13 Thread Herbert Xu
On Wed, Aug 12, 2015 at 08:54:45PM -0700, Tadeusz Struk wrote:
 Don't need to move data inside of the output buffer
 because SW doen't need to do this anymore sice the new MPI
 mpi_read_buf() has been added. Just set the correct output len.
 
 Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com
 ---
  drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
  1 file changed, 3 deletions(-)
 
 diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
 b/drivers/crypto/qat/qat_common/qat_asym_algs.c
 index fe352a6..6ddb13c 100644
 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
 +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
 @@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
   ptr++;
   }
  
 - if (areq-dst_len != req-ctx-key_sz)
 - memcpy(areq-dst, ptr, areq-dst_len);
 -

This looks wrong.  It appears to be trying to remove leading
zeroes so you can't just change the length because then you end
up removing the trailing digits equal to the number of leading
zeroes.

The existing code is also wrong as you should be using memmove
instead of memcpy.

Cheers,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-12 Thread Tadeusz Struk
Don't need to move data inside of the output buffer
because SW doen't need to do this anymore sice the new MPI
mpi_read_buf() has been added. Just set the correct output len.

Signed-off-by: Tadeusz Struk 
---
 drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..6ddb13c 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
ptr++;
}
 
-   if (areq->dst_len != req->ctx->key_sz)
-   memcpy(areq->dst, ptr, areq->dst_len);
-
akcipher_request_complete(areq, err);
 }
 

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


[PATCH 2/2] crypto: qat - Don't move data inside output buffer

2015-08-12 Thread Tadeusz Struk
Don't need to move data inside of the output buffer
because SW doen't need to do this anymore sice the new MPI
mpi_read_buf() has been added. Just set the correct output len.

Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com
---
 drivers/crypto/qat/qat_common/qat_asym_algs.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c 
b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index fe352a6..6ddb13c 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -144,9 +144,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)
ptr++;
}
 
-   if (areq-dst_len != req-ctx-key_sz)
-   memcpy(areq-dst, ptr, areq-dst_len);
-
akcipher_request_complete(areq, err);
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/