Skip to contentSkip to conversation

crypto: CTR DRBG - advance output buffer pointer

PATCH In review Stephan Mueller 2 participants 2 messages Nov 18, 2016 – Nov 21, 2016 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: CTR DRBG - advance output buffer pointer

The CTR DRBG segments the number of random bytes to be generated into 128 byte blocks. The current code misses the advancement of the output buffer pointer when the requestor asks for more than 128 bytes of data. In this case, the next 128 byte block of random numbers is copied to the beginning of the output buffer again. This implies that only the first 128 bytes of the output buffer would ever be filled.

The patch adds the advancement of the buffer pointer to fill the entire buffer.

---
 crypto/drbg.c | 1 +
 1 file changed, 1 insertion(+)
crypto/drbg.c +1 -0
index fb33f7d..9a95b61 100644
@@ -1766,6 +1766,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
 		init_completion(&drbg->ctr_completion);
 
 		outlen -= cryptlen;
+		outbuf += cryptlen;
 	}
 
 	return 0;
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 11 lines · Stephan Mueller

The CTR DRBG segments the number of random bytes to be generated into 128 byte blocks. The current code misses the advancement of the output buffer pointer when the requestor asks for more than 128 bytes of data. In this case, the next 128 byte block of random numbers is copied to the beginning of the output buffer again. This implies that only the first 128 bytes of the output buffer would ever be filled.

The patch adds the advancement of the buffer pointer to fill the entire buffer.

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