All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: herbert@gondor.apana.org.au, Ard Biesheuvel <ardb@kernel.org>,
	linux-omap@vger.kernel.org, Tero Kristo <t-kristo@ti.com>
Subject: [PATCH 1/6] crypto: omap-aes - reject invalid input sizes for block modes
Date: Sat, 26 Oct 2019 16:52:54 +0200	[thread overview]
Message-ID: <20191026145259.16040-2-ardb@kernel.org> (raw)
In-Reply-To: <20191026145259.16040-1-ardb@kernel.org>

Block modes such as ECB and CBC only support input sizes that are
a round multiple of the block size, so align with the generic code
which returns -EINVAL when encountering inputs that violate this
rule.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/crypto/omap-aes.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index de05b35283bf..067f4cd7c005 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -525,6 +525,9 @@ static int omap_aes_crypt(struct skcipher_request *req, unsigned long mode)
 	struct omap_aes_dev *dd;
 	int ret;
 
+	if ((req->cryptlen % AES_BLOCK_SIZE) && !(mode & FLAGS_CTR))
+		return -EINVAL;
+
 	pr_debug("nbytes: %d, enc: %d, cbc: %d\n", req->cryptlen,
 		  !!(mode & FLAGS_ENCRYPT),
 		  !!(mode & FLAGS_CBC));
-- 
2.17.1


  reply	other threads:[~2019-10-26 14:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 14:52 [PATCH 0/6] crypto: additional fixes for omap-aes Ard Biesheuvel
2019-10-26 14:52 ` Ard Biesheuvel [this message]
2019-10-26 14:52 ` [PATCH 2/6] crypto: omap-aes-ctr - set blocksize to 1 Ard Biesheuvel
2019-10-26 14:52 ` [PATCH 3/6] crypto: omap-aes-gcm - deal with memory allocation failure Ard Biesheuvel
2019-10-26 14:52 ` [PATCH 4/6] crypto: omap-aes-gcm - add missing .setauthsize hooks Ard Biesheuvel
2019-10-26 14:52 ` [PATCH 5/6] crypto: omap-aes-gcm - check length of assocdata in RFC4106 mode Ard Biesheuvel
2019-10-26 14:52 ` [PATCH 6/6] crypto: omap-aes-gcm - use the AES library to encrypt the tag Ard Biesheuvel
2019-11-05 12:19 ` [PATCH 0/6] crypto: additional fixes for omap-aes Tero Kristo
2019-11-05 13:20   ` Herbert Xu
2019-11-05 13:38     ` Tero Kristo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191026145259.16040-2-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=t-kristo@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.