mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 00:51:44 +00:00
crypto: atmel-aes - Add NIST 800-38A's zero length cryptlen constraint
NIST 800-38A requires for the ECB, CBC, CFB, OFB and CTR modes that the plaintext and ciphertext to have a positive integer length. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
26d769ae90
commit
0d0433599d
@ -1094,6 +1094,13 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode)
|
||||
if (opmode == AES_FLAGS_XTS && req->cryptlen < XTS_BLOCK_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* ECB, CBC, CFB, OFB or CTR mode require the plaintext and ciphertext
|
||||
* to have a positve integer length.
|
||||
*/
|
||||
if (!req->cryptlen && opmode != AES_FLAGS_XTS)
|
||||
return 0;
|
||||
|
||||
if ((opmode == AES_FLAGS_ECB || opmode == AES_FLAGS_CBC) &&
|
||||
!IS_ALIGNED(req->cryptlen, crypto_skcipher_blocksize(skcipher)))
|
||||
return -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user