diff options
author | Eric Biggers <ebiggers@google.com> | 2019-01-03 20:16:10 -0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-01-11 14:16:57 +0800 |
commit | 394a9e044702e6a8958a5e89d2a291605a587a2a (patch) | |
tree | df5baadd680fa2fe9f49839765d049086e210a8a /crypto/cfb.c | |
parent | 1bb64d867cfe84cc3c255d8fdeff0b4d86341519 (diff) | |
download | linux-stable-394a9e044702e6a8958a5e89d2a291605a587a2a.tar.gz linux-stable-394a9e044702e6a8958a5e89d2a291605a587a2a.tar.bz2 linux-stable-394a9e044702e6a8958a5e89d2a291605a587a2a.zip |
crypto: cfb - add missing 'chunksize' property
Like some other block cipher mode implementations, the CFB
implementation assumes that while walking through the scatterlist, a
partial block does not occur until the end. But the walk is incorrectly
being done with a blocksize of 1, as 'cra_blocksize' is set to 1 (since
CFB is a stream cipher) but no 'chunksize' is set. This bug causes
incorrect encryption/decryption for some scatterlist layouts.
Fix it by setting the 'chunksize'. Also extend the CFB test vectors to
cover this bug as well as cases where the message length is not a
multiple of the block size.
Fixes: a7d85e06ed80 ("crypto: cfb - add support for Cipher FeedBack mode")
Cc: <stable@vger.kernel.org> # v4.17+
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/cfb.c')
-rw-r--r-- | crypto/cfb.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/cfb.c b/crypto/cfb.c index e81e45673498..183e8a9c3312 100644 --- a/crypto/cfb.c +++ b/crypto/cfb.c @@ -298,6 +298,12 @@ static int crypto_cfb_create(struct crypto_template *tmpl, struct rtattr **tb) inst->alg.base.cra_blocksize = 1; inst->alg.base.cra_alignmask = alg->cra_alignmask; + /* + * To simplify the implementation, configure the skcipher walk to only + * give a partial block at the very end, never earlier. + */ + inst->alg.chunksize = alg->cra_blocksize; + inst->alg.ivsize = alg->cra_blocksize; inst->alg.min_keysize = alg->cra_cipher.cia_min_keysize; inst->alg.max_keysize = alg->cra_cipher.cia_max_keysize; |