Patchwork [2/2] crypto: tcrypt - fix buffer lengths in test_aead_speed()

login
register
mail settings
Submitter Robert Baronescu
Date Oct. 10, 2017, 10:22 a.m.
Message ID <1507630920-9014-2-git-send-email-robert.baronescu@nxp.com>
Download mbox | patch
Permalink /patch/9995729/
State Accepted
Delegated to: Herbert Xu
Headers show

Comments

Robert Baronescu - Oct. 10, 2017, 10:22 a.m.
Fix the way the length of the buffers used for
encryption / decryption are computed.
For e.g. in case of encryption, input buffer does not contain
an authentication tag.

Signed-off-by: Robert Baronescu <robert.baronescu@nxp.com>
---
 crypto/tcrypt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Herbert Xu - Nov. 3, 2017, 2:22 p.m.
On Tue, Oct 10, 2017 at 01:22:00PM +0300, Robert Baronescu wrote:
> Fix the way the length of the buffers used for
> encryption / decryption are computed.
> For e.g. in case of encryption, input buffer does not contain
> an authentication tag.
> 
> Signed-off-by: Robert Baronescu <robert.baronescu@nxp.com>

Patch applied.  Thanks.

Patch

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index bd9b66c..e339960 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -342,7 +342,7 @@  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			}
 
 			sg_init_aead(sg, xbuf,
-				    *b_size + (enc ? authsize : 0));
+				    *b_size + (enc ? 0 : authsize));
 
 			sg_init_aead(sgout, xoutbuf,
 				    *b_size + (enc ? authsize : 0));
@@ -350,7 +350,9 @@  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			sg_set_buf(&sg[0], assoc, aad_size);
 			sg_set_buf(&sgout[0], assoc, aad_size);
 
-			aead_request_set_crypt(req, sg, sgout, *b_size, iv);
+			aead_request_set_crypt(req, sg, sgout,
+					       *b_size + (enc ? 0 : authsize),
+					       iv);
 			aead_request_set_ad(req, aad_size);
 
 			if (secs)