diff options
author | Tudor Ambarus <tudor.ambarus@microchip.com> | 2021-07-20 11:55:30 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2021-07-30 05:58:33 +0300 |
commit | 26d769ae90907e6f4724b800ba16f11681079f23 (patch) | |
tree | c7c9e06413ab6f6228b807ad366c8b5ff4b46454 /drivers/crypto | |
parent | 534b32a8be27dc0eb54dccc302b3c9a6f0fe88a2 (diff) | |
download | linux-26d769ae90907e6f4724b800ba16f11681079f23.tar.xz |
crypto: atmel-aes - Add XTS input length constraint
Input length smaller than block size does not make sense for XTS.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/atmel-aes.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 9c6d80d1d7a0..4e9515e8dd25 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -1091,6 +1091,9 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode) struct atmel_aes_dev *dd; u32 opmode = mode & AES_FLAGS_OPMODE_MASK; + if (opmode == AES_FLAGS_XTS && req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + if ((opmode == AES_FLAGS_ECB || opmode == AES_FLAGS_CBC) && !IS_ALIGNED(req->cryptlen, crypto_skcipher_blocksize(skcipher))) return -EINVAL; |