Skip to content

Commit

Permalink
crypto: tcrypt - set assoc in sg_init_aead()
Browse files Browse the repository at this point in the history
Results better code readability.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tudor-Dan Ambarus authored and Herbert Xu committed Nov 29, 2017
1 parent 6905c46 commit 5601e01
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crypto/tcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ static void testmgr_free_buf(char *buf[XBUFSIZE])
}

static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
unsigned int buflen)
unsigned int buflen, const void *assoc,
unsigned int aad_size)
{
int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
int k, rem;
Expand All @@ -198,6 +199,9 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
}

sg_init_table(sg, np + 1);

sg_set_buf(&sg[0], assoc, aad_size);

if (rem)
np--;
for (k = 0; k < np; k++)
Expand Down Expand Up @@ -318,14 +322,12 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
goto out;
}

sg_init_aead(sg, xbuf,
*b_size + (enc ? 0 : authsize));
sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
assoc, aad_size);

sg_init_aead(sgout, xoutbuf,
*b_size + (enc ? authsize : 0));

sg_set_buf(&sg[0], assoc, aad_size);
sg_set_buf(&sgout[0], assoc, aad_size);
*b_size + (enc ? authsize : 0), assoc,
aad_size);

aead_request_set_crypt(req, sg, sgout,
*b_size + (enc ? 0 : authsize),
Expand Down

0 comments on commit 5601e01

Please sign in to comment.