All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	devel@driverdev.osuosl.org
Subject: Re: [PATCH 5/6] staging: lustre: Use ahash
Date: Wed, 3 Feb 2016 14:48:57 -0800	[thread overview]
Message-ID: <20160203224857.GA20244@kroah.com> (raw)
In-Reply-To: <E1aQEez-0002pe-RL@gondolin.me.apana.org.au>

On Mon, Feb 01, 2016 at 09:36:53PM +0800, Herbert Xu wrote:
> This patch replaces uses of the long obsolete hash interface with
> ahash.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> ---
> 
>  drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c |   92 +++++++-------
>  1 file changed, 52 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
> index 079d50e..94c01aa 100644
> --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
> +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
> @@ -27,7 +27,7 @@
>   * Copyright (c) 2012, Intel Corporation.
>   */
>  
> -#include <linux/crypto.h>
> +#include <crypto/hash.h>
>  #include <linux/scatterlist.h>
>  #include "../../../include/linux/libcfs/libcfs.h"
>  #include "linux-crypto.h"
> @@ -38,9 +38,11 @@ static int cfs_crypto_hash_speeds[CFS_HASH_ALG_MAX];
>  
>  static int cfs_crypto_hash_alloc(unsigned char alg_id,
>  				 const struct cfs_crypto_hash_type **type,
> -				 struct hash_desc *desc, unsigned char *key,
> +				 struct ahash_request **req,
> +				 unsigned char *key,
>  				 unsigned int key_len)
>  {
> +	struct crypto_ahash *tfm;
>  	int     err = 0;
>  
>  	*type = cfs_crypto_hash_type(alg_id);
> @@ -50,18 +52,23 @@ static int cfs_crypto_hash_alloc(unsigned char alg_id,
>  		      alg_id, CFS_HASH_ALG_MAX);
>  		return -EINVAL;
>  	}
> -	desc->tfm = crypto_alloc_hash((*type)->cht_name, 0, 0);
> +	tfm = crypto_alloc_ahash((*type)->cht_name, 0, CRYPTO_ALG_ASYNC);
>  
> -	if (desc->tfm == NULL)
> -		return -EINVAL;
> -
> -	if (IS_ERR(desc->tfm)) {
> +	if (IS_ERR(tfm)) {
>  		CDEBUG(D_INFO, "Failed to alloc crypto hash %s\n",
>  		       (*type)->cht_name);
> -		return PTR_ERR(desc->tfm);
> +		return PTR_ERR(tfm);
>  	}
>  
> -	desc->flags = 0;
> +	*req = ahash_request_alloc(tfm, GFP_KERNEL);
> +	if (!*req) {
> +		CDEBUG(D_INFO, "Failed to alloc ahash_request for %s\n",
> +		       (*type)->cht_name);
> +		crypto_free_ahash(tfm);
> +		return -ENOMEM;
> +	}
> +
> +	ahash_request_set_callback(*req, 0, NULL, NULL);
>  
>  	/** Shash have different logic for initialization then digest
>  	 * shash: crypto_hash_setkey, crypto_hash_init
> @@ -70,23 +77,27 @@ static int cfs_crypto_hash_alloc(unsigned char alg_id,
>  	 * cfs_crypto_hash_alloc.
>  	 */
>  	if (key != NULL)
> -		err = crypto_hash_setkey(desc->tfm, key, key_len);
> +		err = crypto_ahash_setkey(tfm, key, key_len);
>  	else if ((*type)->cht_key != 0)
> -		err = crypto_hash_setkey(desc->tfm,
> +		err = crypto_ahash_setkey(tfm,
>  					 (unsigned char *)&((*type)->cht_key),
>  					 (*type)->cht_size);
>  
>  	if (err != 0) {
> -		crypto_free_hash(desc->tfm);
> +		crypto_free_ahash(tfm);
>  		return err;
>  	}
>  
>  	CDEBUG(D_INFO, "Using crypto hash: %s (%s) speed %d MB/s\n",
> -	       (crypto_hash_tfm(desc->tfm))->__crt_alg->cra_name,
> -	       (crypto_hash_tfm(desc->tfm))->__crt_alg->cra_driver_name,
> +	       crypto_ahash_alg_name(tfm), crypto_ahash_driver_name(tfm),

This change breaks the build for me so I can't take this through my
tree.  I'm hoping you have a patch earlier in the series that adds these
functions, if so, feel free to take this through your tree:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

  reply	other threads:[~2016-02-03 22:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 13:34 [PATCH 0/6] crypto: hash - Remove crypto_hash interface Herbert Xu
2016-02-01 13:36 ` [PATCH 1/6] crypto: tcrypt - Use ahash Herbert Xu
2016-02-01 13:36 ` [PATCH 2/6] crypto: doc " Herbert Xu
2016-02-01 13:36 ` [PATCH 3/6] crypto: skcipher - Fix driver name helper Herbert Xu
2016-02-01 13:36 ` [PATCH 4/6] crypto: hash - Add helpers to return alg and driver names Herbert Xu
2016-02-01 13:36 ` [PATCH 5/6] staging: lustre: Use ahash Herbert Xu
2016-02-03 22:48   ` Greg KH [this message]
2016-02-04  3:17     ` Herbert Xu
2016-02-01 13:36 ` [PATCH 6/6] crypto: hash - Remove crypto_hash interface 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=20160203224857.GA20244@kroah.com \
    --to=greg@kroah.com \
    --cc=devel@driverdev.osuosl.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.