linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<linux-crypto@vger.kernel.org>
Cc: <linux-omap@vger.kernel.org>, <ard.biesheuvel@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCHv2 14/22] crypto: omap-aes-gcm - add missing .setauthsize hooks
Date: Tue, 5 Nov 2019 16:01:03 +0200	[thread overview]
Message-ID: <20191105140111.20285-15-t-kristo@ti.com> (raw)
In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com>

From: Ard Biesheuvel <ardb@kernel.org>

GCM only permits certain tag lengths, so populate the .setauthsize
hooks which ensure that only permitted sizes are accepted by the
implementation.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Tero Kristo <t-kristo@ti.com>
Tested-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/crypto/omap-aes-gcm.c | 11 +++++++++++
 drivers/crypto/omap-aes.c     |  2 ++
 drivers/crypto/omap-aes.h     |  3 +++
 3 files changed, 16 insertions(+)

diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c
index 05d2fe78b105..70398fbd669d 100644
--- a/drivers/crypto/omap-aes-gcm.c
+++ b/drivers/crypto/omap-aes-gcm.c
@@ -413,3 +413,14 @@ int omap_aes_4106gcm_setkey(struct crypto_aead *tfm, const u8 *key,
 
 	return 0;
 }
+
+int omap_aes_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
+{
+	return crypto_gcm_check_authsize(authsize);
+}
+
+int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent,
+				 unsigned int authsize)
+{
+	return crypto_rfc4106_check_authsize(authsize);
+}
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 33cba7a2d6df..161af3bf667c 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -787,6 +787,7 @@ static struct aead_alg algs_aead_gcm[] = {
 	.ivsize		= GCM_AES_IV_SIZE,
 	.maxauthsize	= AES_BLOCK_SIZE,
 	.setkey		= omap_aes_gcm_setkey,
+	.setauthsize	= omap_aes_gcm_setauthsize,
 	.encrypt	= omap_aes_gcm_encrypt,
 	.decrypt	= omap_aes_gcm_decrypt,
 },
@@ -807,6 +808,7 @@ static struct aead_alg algs_aead_gcm[] = {
 	.maxauthsize	= AES_BLOCK_SIZE,
 	.ivsize		= GCM_RFC4106_IV_SIZE,
 	.setkey		= omap_aes_4106gcm_setkey,
+	.setauthsize	= omap_aes_4106gcm_setauthsize,
 	.encrypt	= omap_aes_4106gcm_encrypt,
 	.decrypt	= omap_aes_4106gcm_decrypt,
 },
diff --git a/drivers/crypto/omap-aes.h b/drivers/crypto/omap-aes.h
index 2d3575231e31..1bcca7957e92 100644
--- a/drivers/crypto/omap-aes.h
+++ b/drivers/crypto/omap-aes.h
@@ -202,8 +202,11 @@ int omap_aes_4106gcm_setkey(struct crypto_aead *tfm, const u8 *key,
 			    unsigned int keylen);
 int omap_aes_gcm_encrypt(struct aead_request *req);
 int omap_aes_gcm_decrypt(struct aead_request *req);
+int omap_aes_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize);
 int omap_aes_4106gcm_encrypt(struct aead_request *req);
 int omap_aes_4106gcm_decrypt(struct aead_request *req);
+int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent,
+				 unsigned int authsize);
 int omap_aes_write_ctrl(struct omap_aes_dev *dd);
 int omap_aes_crypt_dma_start(struct omap_aes_dev *dd);
 int omap_aes_crypt_dma_stop(struct omap_aes_dev *dd);
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2019-11-05 14:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 14:00 [PATCHv2 00/22] crypto: omap-sham: fixes towards 5.5 Tero Kristo
2019-11-05 14:00 ` [PATCHv2 01/22] crypto: omap-sham: split up data to multiple sg elements with huge data Tero Kristo
2019-11-05 14:00 ` [PATCHv2 02/22] crypto: omap-sham: remove the sysfs group during driver removal Tero Kristo
2019-11-05 14:00 ` [PATCHv2 03/22] crypto: omap-aes: " Tero Kristo
2019-11-05 14:00 ` [PATCHv2 04/22] crypto: omap-des: add IV output handling Tero Kristo
2019-11-05 14:00 ` [PATCHv2 05/22] crypto: omap-aes: " Tero Kristo
2019-11-05 14:00 ` [PATCHv2 06/22] crypto: omap-sham: fix buffer handling for split test cases Tero Kristo
2019-11-05 14:00 ` [PATCHv2 07/22] crypto: omap-aes-gcm: fix corner case with only auth data Tero Kristo
2019-11-05 14:00 ` [PATCHv2 08/22] crypto: omap-sham: fix split update cases with cryptomgr tests Tero Kristo
2019-11-05 14:00 ` [PATCHv2 09/22] crypto: add timeout to crypto_wait_req Tero Kristo
2019-11-15  5:29   ` Herbert Xu
2019-11-15  7:44     ` Tero Kristo
2019-11-15  9:10       ` Herbert Xu
2019-11-05 14:00 ` [PATCHv2 10/22] crypto: omap-aes: fixup aligned data cleanup Tero Kristo
2019-11-05 14:01 ` [PATCHv2 11/22] crypto: omap-aes - reject invalid input sizes for block modes Tero Kristo
2019-11-05 14:01 ` [PATCHv2 12/22] crypto: omap-aes-ctr - set blocksize to 1 Tero Kristo
2019-11-05 14:01 ` [PATCHv2 13/22] crypto: omap-aes-gcm - deal with memory allocation failure Tero Kristo
2019-11-05 14:01 ` Tero Kristo [this message]
2019-11-05 14:01 ` [PATCHv2 15/22] crypto: omap-aes-gcm - check length of assocdata in RFC4106 mode Tero Kristo
2019-11-05 14:01 ` [PATCHv2 16/22] crypto: omap-aes-gcm - use the AES library to encrypt the tag Tero Kristo
2019-11-05 14:01 ` [PATCHv2 17/22] crypto: omap-aes-gcm: fix failure with assocdata only Tero Kristo
2019-11-05 14:01 ` [PATCHv2 18/22] crypto: omap-sham: fix unaligned sg list handling Tero Kristo
2019-11-05 14:01 ` [PATCHv2 19/22] crypto: omap-aes-gcm: convert to use crypto engine Tero Kristo
2019-11-05 14:01 ` [PATCHv2 20/22] crypto: omap-des: avoid unnecessary spam with bad cryptlen Tero Kristo
2019-11-05 14:01 ` [PATCHv2 21/22] crypto: omap-des: handle NULL cipher request Tero Kristo
2019-11-05 14:01 ` [PATCHv2 22/22] crypto: omap-crypto: copy the temporary data to output buffer properly Tero Kristo
2019-12-11  8:06 ` [PATCHv2 00/22] crypto: omap-sham: fixes towards 5.5 Tero Kristo
2019-12-11  8:12   ` Herbert Xu
2019-12-11  8:40     ` Tero Kristo
2019-12-11  9:42 ` Herbert Xu

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=20191105140111.20285-15-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=ard.biesheuvel@kernel.org \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).