All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: [PATCH 12/16] crypto: gcm - Use default null skcipher
Date: Thu, 21 May 2015 15:11:11 +0800	[thread overview]
Message-ID: <E1YvKdL-0005fu-6x@gondolin.me.apana.org.au> (raw)
In-Reply-To: 20150521070915.GA20997@gondor.apana.org.au

This patch makes gcm use the default null skcipher instead of
allocating a new one for each tfm.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 crypto/gcm.c |   23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/crypto/gcm.c b/crypto/gcm.c
index b56200e..fc2b55e 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -12,6 +12,7 @@
 #include <crypto/internal/aead.h>
 #include <crypto/internal/skcipher.h>
 #include <crypto/internal/hash.h>
+#include <crypto/null.h>
 #include <crypto/scatterwalk.h>
 #include <crypto/hash.h>
 #include "internal.h"
@@ -39,7 +40,6 @@ struct crypto_rfc4106_ctx {
 
 struct crypto_rfc4543_instance_ctx {
 	struct crypto_aead_spawn aead;
-	struct crypto_skcipher_spawn null;
 };
 
 struct crypto_rfc4543_ctx {
@@ -1246,7 +1246,7 @@ static int crypto_rfc4543_init_tfm(struct crypto_tfm *tfm)
 	if (IS_ERR(aead))
 		return PTR_ERR(aead);
 
-	null = crypto_spawn_blkcipher(&ictx->null.base);
+	null = crypto_get_default_null_skcipher();
 	err = PTR_ERR(null);
 	if (IS_ERR(null))
 		goto err_free_aead;
@@ -1273,7 +1273,7 @@ static void crypto_rfc4543_exit_tfm(struct crypto_tfm *tfm)
 	struct crypto_rfc4543_ctx *ctx = crypto_tfm_ctx(tfm);
 
 	crypto_free_aead(ctx->child);
-	crypto_free_blkcipher(ctx->null);
+	crypto_put_default_null_skcipher();
 }
 
 static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb)
@@ -1311,23 +1311,15 @@ static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb)
 
 	alg = crypto_aead_spawn_alg(spawn);
 
-	crypto_set_skcipher_spawn(&ctx->null, inst);
-	err = crypto_grab_skcipher(&ctx->null, "ecb(cipher_null)", 0,
-				   CRYPTO_ALG_ASYNC);
-	if (err)
-		goto out_drop_alg;
-
-	crypto_skcipher_spawn_alg(&ctx->null);
-
 	err = -EINVAL;
 
 	/* We only support 16-byte blocks. */
 	if (alg->cra_aead.ivsize != 16)
-		goto out_drop_ecbnull;
+		goto out_drop_alg;
 
 	/* Not a stream cipher? */
 	if (alg->cra_blocksize != 1)
-		goto out_drop_ecbnull;
+		goto out_drop_alg;
 
 	err = -ENAMETOOLONG;
 	if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME,
@@ -1335,7 +1327,7 @@ static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb)
 	    snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
 		     "rfc4543(%s)", alg->cra_driver_name) >=
 	    CRYPTO_MAX_ALG_NAME)
-		goto out_drop_ecbnull;
+		goto out_drop_alg;
 
 	inst->alg.cra_flags = CRYPTO_ALG_TYPE_AEAD;
 	inst->alg.cra_flags |= alg->cra_flags & CRYPTO_ALG_ASYNC;
@@ -1362,8 +1354,6 @@ static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb)
 out:
 	return inst;
 
-out_drop_ecbnull:
-	crypto_drop_skcipher(&ctx->null);
 out_drop_alg:
 	crypto_drop_aead(spawn);
 out_free_inst:
@@ -1377,7 +1367,6 @@ static void crypto_rfc4543_free(struct crypto_instance *inst)
 	struct crypto_rfc4543_instance_ctx *ctx = crypto_instance_ctx(inst);
 
 	crypto_drop_aead(&ctx->aead);
-	crypto_drop_skcipher(&ctx->null);
 
 	kfree(inst);
 }

  parent reply	other threads:[~2015-05-21  7:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  7:09 [PATCH 0/16] crypto: aead - Add single SG interface and new IPsec IV generation Herbert Xu
2015-05-21  7:10 ` [PATCH 1/16] crypto: cryptd - Use crypto_grab_aead Herbert Xu
2015-05-21  7:10 ` [PATCH 2/16] crypto: pcrypt " Herbert Xu
2015-05-21  7:10 ` [PATCH 3/16] crypto: scatterwalk - Add scatterwalk_ffwd helper Herbert Xu
2015-05-21  7:11 ` [PATCH 4/16] crypto: aead - Add new interface with single SG list Herbert Xu
2015-05-21  7:11 ` [PATCH 5/16] crypto: aead - Rename aead_alg to old_aead_alg Herbert Xu
2015-05-21  7:11 ` [PATCH 6/16] crypto: caam - Use old_aead_alg Herbert Xu
2015-05-21  7:11 ` [PATCH 7/16] crypto: aead - Add crypto_aead_maxauthsize Herbert Xu
2015-05-21  7:11 ` [PATCH 8/16] crypto: ixp4xx - Use crypto_aead_maxauthsize Herbert Xu
2015-05-21  7:11 ` [PATCH 9/16] crypto: nx - Remove unnecessary maxauthsize check Herbert Xu
2015-05-21  7:11 ` [PATCH 10/16] crypto: aead - Add support for new AEAD implementations Herbert Xu
2015-05-21  7:11 ` [PATCH 11/16] crypto: null - Add default null skcipher Herbert Xu
2015-05-21  7:11 ` Herbert Xu [this message]
2015-05-21  7:11 ` [PATCH 13/16] crypto: scatterwalk - Check for same address in map_and_copy Herbert Xu
2015-05-21  7:11 ` [PATCH 14/16] crypto: seqiv - Add support for new AEAD interface Herbert Xu
2015-05-21  7:11 ` [PATCH 15/16] crypto: seqiv - Add seqniv Herbert Xu
2015-05-21  7:11 ` [PATCH 16/16] crypto: echainiv - Add encrypted chain IV generator 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=E1YvKdL-0005fu-6x@gondolin.me.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=linux-crypto@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 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.