crypto: atmel-aes - check alignment of cfb64 mode
authorLeilei Zhao <leilei.zhao@atmel.com>
Tue, 22 Apr 2014 07:23:24 +0000 (15:23 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 28 Apr 2014 10:21:19 +0000 (18:21 +0800)
The length shoule be 64 bit alignment and the block size shoule be 64 bit in aes cfb64 mode.

Signed-off-by: Leilei Zhao <leilei.zhao@atmel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/atmel-aes.c

index 12628a75fbccebdc7a28cc7dd682ea60f1921f67..a083474991abbb343aa330160ff988f34635b268 100644 (file)
@@ -716,6 +716,12 @@ static int atmel_aes_crypt(struct ablkcipher_request *req, unsigned long mode)
                        return -EINVAL;
                }
                ctx->block_size = CFB32_BLOCK_SIZE;
+       } else if (mode & AES_FLAGS_CFB64) {
+               if (!IS_ALIGNED(req->nbytes, CFB64_BLOCK_SIZE)) {
+                       pr_err("request size is not exact amount of CFB64 blocks\n");
+                       return -EINVAL;
+               }
+               ctx->block_size = CFB64_BLOCK_SIZE;
        } else {
                if (!IS_ALIGNED(req->nbytes, AES_BLOCK_SIZE)) {
                        pr_err("request size is not exact amount of AES blocks\n");