summaryrefslogtreecommitdiff
path: root/drivers/crypto/atmel-tdes.c
diff options
context:
space:
mode:
authorTudor Ambarus <tudor.ambarus@microchip.com>2021-07-20 11:55:32 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2021-07-30 10:58:33 +0800
commit031f5e00150895232e658f67e66382b6c867ba13 (patch)
treec9ac4bffd95c4ef20c9704be04df85fe537a3d25 /drivers/crypto/atmel-tdes.c
parent0d0433599d84bf7db8caa8fb76915dc0ff818150 (diff)
crypto: atmel-tdes - Add FIPS81's zero length cryptlen constraint
FIPS81 requires for the ECB, CBC, CFB, and OFB modes that the plaintext and ciphertext to have a positive integer length. Add this constraint and just return 0 for a zero length cryptlen. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/atmel-tdes.c')
-rw-r--r--drivers/crypto/atmel-tdes.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c
index abbf1b7a75ab..8380e0ab149a 100644
--- a/drivers/crypto/atmel-tdes.c
+++ b/drivers/crypto/atmel-tdes.c
@@ -682,6 +682,9 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
struct atmel_tdes_reqctx *rctx = skcipher_request_ctx(req);
struct device *dev = ctx->dd->dev;
+ if (!req->cryptlen)
+ return 0;
+
switch (mode & TDES_FLAGS_OPMODE_MASK) {
case TDES_FLAGS_CFB8:
if (!IS_ALIGNED(req->cryptlen, CFB8_BLOCK_SIZE)) {