Subject: Re: [PATCH v3 28/29] crypto: remove deprecated and unused ablkcipher support

From: Eric Biggers <[email-masked]>
Date: Tue, 5 Nov 2019 09:52:06 -0800

On Tue, Nov 05, 2019 at 02:28:25PM +0100, Ard Biesheuvel wrote:
> Now that all users of the deprecated ablkcipher interface have been
> moved to the skcipher interface, ablkcipher is no longer used and
> can be removed.
> 
> Signed-off-by: Ard Biesheuvel <[email-masked]>

Reviewed-by: Eric Biggers <[email-masked]>

Thanks for doing this!

A couple ideas for future cleanups below (which, if done, should go in separate
patches rather than in this big one):

> @@ -786,9 +683,6 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
>  	struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm);
>  	struct skcipher_alg *alg = crypto_skcipher_alg(skcipher);
>  
> -	if (tfm->__crt_alg->cra_type == &crypto_ablkcipher_type)
> -		return crypto_init_skcipher_ops_ablkcipher(tfm);
> -
>  	skcipher->setkey = skcipher_setkey;
>  	skcipher->encrypt = alg->encrypt;
>  	skcipher->decrypt = alg->decrypt;
>	skcipher->ivsize = alg->ivsize;
>	skcipher->keysize = alg->max_keysize;

Since a crypto_skcipher will now always be paired with a skcipher_alg (rather
than an blkcipher or ablkcipher algorithm), we could remove the 'encrypt',
'decrypt', 'ivsize', and 'keysize' fields of crypto_skcipher, and instead always
get them from the skcipher_alg.

> @@ -182,27 +171,18 @@ static inline u32 skcipher_request_flags(struct skcipher_request *req)
>  static inline unsigned int crypto_skcipher_alg_min_keysize(
>  	struct skcipher_alg *alg)
>  {
> -	if (alg->base.cra_ablkcipher.encrypt)
> -		return alg->base.cra_ablkcipher.min_keysize;
> -
>  	return alg->min_keysize;
>  }
>  
>  static inline unsigned int crypto_skcipher_alg_max_keysize(
>  	struct skcipher_alg *alg)
>  {
> -	if (alg->base.cra_ablkcipher.encrypt)
> -		return alg->base.cra_ablkcipher.max_keysize;
> -
>  	return alg->max_keysize;
>  }
>  
>  static inline unsigned int crypto_skcipher_alg_walksize(
>  	struct skcipher_alg *alg)
>  {
> -	if (alg->base.cra_ablkcipher.encrypt)
> -		return alg->base.cra_blocksize;
> -
>  	return alg->walksize;
>  }
>  
> diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
> index 8c5a31e810da..b4655d91661f 100644
> --- a/include/crypto/skcipher.h
> +++ b/include/crypto/skcipher.h
> @@ -241,9 +241,6 @@ static inline struct skcipher_alg *crypto_skcipher_alg(
>  
>  static inline unsigned int crypto_skcipher_alg_ivsize(struct skcipher_alg *alg)
>  {
> -	if (alg->base.cra_ablkcipher.encrypt)
> -		return alg->base.cra_ablkcipher.ivsize;
> -
>  	return alg->ivsize;
>  }
>  
> @@ -286,9 +283,6 @@ static inline unsigned int crypto_skcipher_blocksize(
>  static inline unsigned int crypto_skcipher_alg_chunksize(
>  	struct skcipher_alg *alg)
>  {
> -	if (alg->base.cra_ablkcipher.encrypt)
> -		return alg->base.cra_blocksize;
> -
>  	return alg->chunksize;
>  }

Now that these helpers are trivial, they could be removed and we could just
dereference the struct skcipher_alg directly.

- Eric

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel