All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [v2 PATCH] crypto: skcipher - Add skcipher_ialg_simple helper
Date: Thu, 19 Dec 2019 12:34:00 -0800	[thread overview]
Message-ID: <20191219203359.GB54076@gmail.com> (raw)
In-Reply-To: <20191218080733.2ckqf4e5qmgnnrjd@gondor.apana.org.au>

On Wed, Dec 18, 2019 at 04:07:33PM +0800, Herbert Xu wrote:
> This patch introduces the skcipher_ialg_simple helper which fetches
> the crypto_alg structure from a simple skcpiher instance's spawn.

Typo: skcpiher => skcipher

> diff --git a/crypto/ecb.c b/crypto/ecb.c
> index 9d6981ca7d5d..249aca75b7dc 100644
> --- a/crypto/ecb.c
> +++ b/crypto/ecb.c
> @@ -64,10 +64,12 @@ static int crypto_ecb_create(struct crypto_template *tmpl, struct rtattr **tb)
>  	struct crypto_alg *alg;
>  	int err;
>  
> -	inst = skcipher_alloc_instance_simple(tmpl, tb, &alg);
> +	inst = skcipher_alloc_instance_simple(tmpl, tb);
>  	if (IS_ERR(inst))
>  		return PTR_ERR(inst);
>  
> +	alg = skcipher_ialg_simple(inst);
> +
>  	inst->alg.ivsize = 0; /* ECB mode doesn't take an IV */
>  
>  	inst->alg.encrypt = crypto_ecb_encrypt;
> @@ -76,7 +78,7 @@ static int crypto_ecb_create(struct crypto_template *tmpl, struct rtattr **tb)
>  	err = skcipher_register_instance(tmpl, inst);
>  	if (err)
>  		inst->free(inst);
> -	crypto_mod_put(alg);
> +
>  	return err;
>  }

For ecb, 'alg' isn't used anymore, so it should just be removed.

> diff --git a/crypto/pcbc.c b/crypto/pcbc.c
> index 862cdb8d8b6c..5c5245647208 100644
> --- a/crypto/pcbc.c
> +++ b/crypto/pcbc.c
> @@ -156,17 +156,19 @@ static int crypto_pcbc_create(struct crypto_template *tmpl, struct rtattr **tb)
>  	struct crypto_alg *alg;
>  	int err;
>  
> -	inst = skcipher_alloc_instance_simple(tmpl, tb, &alg);
> +	inst = skcipher_alloc_instance_simple(tmpl, tb);
>  	if (IS_ERR(inst))
>  		return PTR_ERR(inst);
>  
> +	alg = skcipher_ialg_simple(inst);
> +
>  	inst->alg.encrypt = crypto_pcbc_encrypt;
>  	inst->alg.decrypt = crypto_pcbc_decrypt;
>  
>  	err = skcipher_register_instance(tmpl, inst);
>  	if (err)
>  		inst->free(inst);
> -	crypto_mod_put(alg);
> +
>  	return err;
>  }

Same for pcbc.

- Eric

  reply	other threads:[~2019-12-19 20:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06  5:57 [PATCH] crypto: skcipher - Add skcipher_ialg_simple helper Herbert Xu
2019-12-06 21:47 ` Eric Biggers
2019-12-18  8:07 ` [v2 PATCH] " Herbert Xu
2019-12-19 20:34   ` Eric Biggers [this message]
2019-12-20  5:29     ` [v3 " 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=20191219203359.GB54076@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=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.