diff options
author | Stephan Mueller <smueller@chronox.de> | 2017-03-22 15:26:36 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-03-24 15:03:01 +0100 |
commit | 44068d5999d372b0034382530899df77d83c70e5 (patch) | |
tree | e73ad505d0c6fd23d65aaf5a8eccd7416beddeae /crypto/drbg.c | |
parent | crypto: testmgr - mark ctr(des3_ede) as fips_allowed (diff) | |
download | linux-44068d5999d372b0034382530899df77d83c70e5.tar.xz linux-44068d5999d372b0034382530899df77d83c70e5.zip |
crypto: DRBG - initialize SGL only once
An SGL to be initialized only once even when its buffers are written
to several times.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r-- | crypto/drbg.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c index 8a4d98b4adba..fa749f470135 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -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); |