summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-03-18 14:09:57 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-03-28 13:40:30 (GMT)
commitfd67b46ff7ec36d2cd45d03e3a05592c394d6c25 (patch)
tree8d86da651e65f6588b8b76ab925bdfb345c1bfd4 /crypto
parentfcc5e5274bc78ee6509a029673063b91fd262e32 (diff)
downloadlinux-fsl-qoriq-fd67b46ff7ec36d2cd45d03e3a05592c394d6c25.tar.xz
crypto: tls - reduce helper function arity
This helper function calculates the padded digest and sets the length of the result as a side-effect. Doing more than this increases complexity with no visible advantage. This patch removes a calculation that can be done by the caller. Change-Id: Ifb5ec2b47cde824837065985230a19bdd1f0af88 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/10081 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com> (cherry picked from commit c89e8db964f0c280bd773b4bcc27a156a3e9d871) Reviewed-on: http://git.am.freescale.net:8181/10380 Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Alexandru Porosanu <alexandru.porosanu@freescale.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tls.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/crypto/tls.c b/crypto/tls.c
index a45574d..99a88b9 100644
--- a/crypto/tls.c
+++ b/crypto/tls.c
@@ -177,11 +177,10 @@ static int crypto_tls_genicv(u8 *hash, struct scatterlist *src,
* crypto_tls_gen_padicv - Calculate and pad hmac digest for a TLS record
* @hash: (output) buffer to save the digest and padding into
* @phashlen: (output) the size of digest + padding
- * @cryptlen: (output) the size of the total frame to be encrypted
* @req: (input) aead request
**/
static int crypto_tls_gen_padicv(u8 *hash, unsigned int *phashlen,
- unsigned int *cryptlen, struct aead_request *req)
+ struct aead_request *req)
{
struct crypto_aead *tls = crypto_aead_reqtfm(req);
unsigned int hash_size = crypto_aead_authsize(tls);
@@ -198,8 +197,6 @@ static int crypto_tls_gen_padicv(u8 *hash, unsigned int *phashlen,
padlen = block_size - (srclen % block_size);
memset(hash + hash_size, padlen - 1, padlen);
- /* save the frame length to be encrypted */
- *cryptlen = srclen + padlen;
*phashlen = hash_size + padlen;
out:
return err;
@@ -236,7 +233,7 @@ static int crypto_tls_encrypt(struct aead_request *req)
/*
* STEP 1: create ICV and add necessary padding
*/
- err = crypto_tls_gen_padicv(hash, &phashlen, &cryptlen, req);
+ err = crypto_tls_gen_padicv(hash, &phashlen, req);
if (err)
return err;
@@ -257,6 +254,7 @@ static int crypto_tls_encrypt(struct aead_request *req)
cipher = icv;
}
/* prepare the cipher request */
+ cryptlen = req->cryptlen + phashlen;
ablkcipher_request_set_tfm(abreq, ctx->enc);
ablkcipher_request_set_crypt(abreq, cipher, req->dst, cryptlen,
req->iv);