From fd67b46ff7ec36d2cd45d03e3a05592c394d6c25 Mon Sep 17 00:00:00 2001 From: Cristian Stoica Date: Tue, 18 Mar 2014 16:09:57 +0200 Subject: 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 Reviewed-on: http://git.am.freescale.net:8181/10081 Tested-by: Review Code-CDREVIEW Reviewed-by: Horia Ioan Geanta Neag Reviewed-by: Jose Rivera (cherry picked from commit c89e8db964f0c280bd773b4bcc27a156a3e9d871) Reviewed-on: http://git.am.freescale.net:8181/10380 Reviewed-by: Mircea Pop Reviewed-by: Alexandru Porosanu 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); -- cgit v0.10.2