Skip to content

Commit 5f8f273

Browse files
committed
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>
1 parent f5608c1 commit 5f8f273

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/crypto/atmel-aes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,13 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode)
10941094
if (opmode == AES_FLAGS_XTS && req->cryptlen < XTS_BLOCK_SIZE)
10951095
return -EINVAL;
10961096

1097+
/*
1098+
* ECB, CBC, CFB, OFB or CTR mode require the plaintext and ciphertext
1099+
* to have a positve integer length.
1100+
*/
1101+
if (!req->cryptlen && opmode != AES_FLAGS_XTS)
1102+
return 0;
1103+
10971104
if ((opmode == AES_FLAGS_ECB || opmode == AES_FLAGS_CBC) &&
10981105
!IS_ALIGNED(req->cryptlen, crypto_skcipher_blocksize(skcipher)))
10991106
return -EINVAL;

0 commit comments

Comments
 (0)