@@ -227,6 +227,11 @@ static int crypto_lskcipher_crypt_sg(struct skcipher_request *req,
if (!(req->base.flags & CRYPTO_SKCIPHER_REQ_NOTFINAL))
flags |= CRYPTO_LSKCIPHER_FLAG_FINAL;
+ if (unlikely(!req->cryptlen)) {
+ err = crypt(tfm, NULL, NULL, 0, ivs, flags);
+ goto out;
+ }
+
do {
err = skcipher_walk_virt(&walk, req, false);
morethanone = walk.nbytes != walk.total;
@@ -245,6 +250,7 @@ static int crypto_lskcipher_crypt_sg(struct skcipher_request *req,
return err;
} while (!secondpass++ && !isincremental && morethanone);
+out:
if (flags & CRYPTO_LSKCIPHER_FLAG_FINAL)
memcpy(req->iv, ivs, ivsize);
Propagate zero-length requests down to the lskcipher algorithm as otherwise the return value could be different, e.g., zero vs. -EINVAL for xts. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- crypto/lskcipher.c | 6 ++++++ 1 file changed, 6 insertions(+)