Skip to contentSkip to conversation

crypto: DRBG - initialize SGL only once

PATCH In review Stephan Müller 2 participants 2 messages Mar 22, 2017 – Mar 24, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: DRBG - initialize SGL only once

An SGL to be initialized only once even when its buffers are written to several times.

---
 crypto/drbg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
crypto/drbg.c +2 -3
index 8a4d98b..fa749f4 100644
@@ -1749,17 +1749,16 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
 			      u8 *inbuf, u32 inlen,
 			      u8 *outbuf, u32 outlen)
 {
-	struct scatterlist sg_in;
+	struct scatterlist sg_in, sg_out;
 	int ret;
 
 	sg_init_one(&sg_in, inbuf, inlen);
+	sg_init_one(&sg_out, drbg->outscratchpad, DRBG_OUTSCRATCHLEN);
 
 	while (outlen) {
 		u32 cryptlen = min3(inlen, outlen, (u32)DRBG_OUTSCRATCHLEN);
-		struct scatterlist sg_out;
 
 		/* Output buffer may not be valid for SGL, use scratchpad */
-		sg_init_one(&sg_out, drbg->outscratchpad, cryptlen);
 		skcipher_request_set_crypt(drbg->ctr_req, &sg_in, &sg_out,
 					   cryptlen, drbg->V);
 		ret = crypto_skcipher_encrypt(drbg->ctr_req);
Signature · 1 line
2.9.3
maintainer
#1 lore raw
Quoted 4 lines · Stephan Müller

An SGL to be initialized only once even when its buffers are written to several times.

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt