Thread (20 messages) 20 messages, 4 authors, 2015-08-24

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

From: Tadeusz Struk <hidden>
Date: 2015-08-14 06:15:29
Also in: lkml

On 08/13/2015 10:14 PM, Herbert Xu wrote:
quoted
diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help