summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/vmx/aes_cbc.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-04-09 23:46:35 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2019-04-18 22:14:58 +0800
commit694e0db6600c12f8172efb51cd4b4bbade958562 (patch)
tree02072801a75103ecb788005f608b4333b7185241 /drivers/crypto/vmx/aes_cbc.c
parent4a8108b70508df0b6c4ffa4a3974dab93dcbe851 (diff)
downloadlinux-694e0db6600c12f8172efb51cd4b4bbade958562.tar.gz
linux-694e0db6600c12f8172efb51cd4b4bbade958562.tar.bz2
linux-694e0db6600c12f8172efb51cd4b4bbade958562.zip
crypto: vmx - return correct error code on failed setkey
In the VMX implementations of AES and AES modes, return -EINVAL when an invalid key length is provided, rather than some unusual error code determined via a series of additions. This makes the behavior match the other AES implementations in the kernel's crypto API. Cc: Daniel Axtens <dja@axtens.net> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/vmx/aes_cbc.c')
-rw-r--r--drivers/crypto/vmx/aes_cbc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c
index c5c5ff82b52e..fbe882ef1bc5 100644
--- a/drivers/crypto/vmx/aes_cbc.c
+++ b/drivers/crypto/vmx/aes_cbc.c
@@ -81,13 +81,14 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
pagefault_disable();
enable_kernel_vsx();
ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
- ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
+ ret |= aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
disable_kernel_vsx();
pagefault_enable();
preempt_enable();
- ret += crypto_sync_skcipher_setkey(ctx->fallback, key, keylen);
- return ret;
+ ret |= crypto_sync_skcipher_setkey(ctx->fallback, key, keylen);
+
+ return ret ? -EINVAL : 0;
}
static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,