Commit b21919ee authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Greg Kroah-Hartman

s390/crypto: xts-aes-s390 fix extra run-time crypto self tests finding

[ Upstream commit 9e323d45 ]

With 'extra run-time crypto self tests' enabled, the selftest
for s390-xts fails with

  alg: skcipher: xts-aes-s390 encryption unexpectedly succeeded on
  test vector "random: len=0 klen=64"; expected_error=-22,
  cfg="random: inplace use_digest nosimd src_divs=[2.61%@+4006,
  84.44%@+21, 1.55%@+13, 4.50%@+344, 4.26%@+21, 2.64%@+27]"

This special case with nbytes=0 is not handled correctly and this
fix now makes sure that -EINVAL is returned when there is en/decrypt
called with 0 bytes to en/decrypt.
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fad90d4b
...@@ -585,6 +585,9 @@ static int xts_aes_encrypt(struct blkcipher_desc *desc, ...@@ -585,6 +585,9 @@ static int xts_aes_encrypt(struct blkcipher_desc *desc,
struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm); struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk; struct blkcipher_walk walk;
if (!nbytes)
return -EINVAL;
if (unlikely(!xts_ctx->fc)) if (unlikely(!xts_ctx->fc))
return xts_fallback_encrypt(desc, dst, src, nbytes); return xts_fallback_encrypt(desc, dst, src, nbytes);
...@@ -599,6 +602,9 @@ static int xts_aes_decrypt(struct blkcipher_desc *desc, ...@@ -599,6 +602,9 @@ static int xts_aes_decrypt(struct blkcipher_desc *desc,
struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm); struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk; struct blkcipher_walk walk;
if (!nbytes)
return -EINVAL;
if (unlikely(!xts_ctx->fc)) if (unlikely(!xts_ctx->fc))
return xts_fallback_decrypt(desc, dst, src, nbytes); return xts_fallback_decrypt(desc, dst, src, nbytes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment