Re: [PATCH] crypto: hisilicon/hpre - Use helper to set reqsize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022/11/22 17:28, Herbert Xu wrote:
> The value of reqsize must only be changed through the helper.
> 
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> 
> diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> index ef02dadd6217..5f6d363c9435 100644
> --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> @@ -740,6 +740,8 @@ static int hpre_dh_init_tfm(struct crypto_kpp *tfm)
>  {
>  	struct hpre_ctx *ctx = kpp_tfm_ctx(tfm);
>  
> +	kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ);
> +
>  	return hpre_ctx_init(ctx, HPRE_V2_ALG_TYPE);
>  }
>  
> @@ -1165,6 +1167,9 @@ static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm)
>  		return PTR_ERR(ctx->rsa.soft_tfm);
>  	}
>  
> +	akcipher_set_reqsize(tfm, sizeof(struct hpre_asym_request) +
> +				  HPRE_ALIGN_SZ);
> +
>  	ret = hpre_ctx_init(ctx, HPRE_V2_ALG_TYPE);
>  	if (ret)
>  		crypto_free_akcipher(ctx->rsa.soft_tfm);
> @@ -1617,6 +1622,8 @@ static int hpre_ecdh_nist_p192_init_tfm(struct crypto_kpp *tfm)
>  
>  	ctx->curve_id = ECC_CURVE_NIST_P192;
>  
> +	kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ);
> +
>  	return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE);
>  }
>  
> @@ -1626,6 +1633,8 @@ static int hpre_ecdh_nist_p256_init_tfm(struct crypto_kpp *tfm)
>  
>  	ctx->curve_id = ECC_CURVE_NIST_P256;
>  
> +	kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ);
> +
>  	return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE);
>  }
>  
> @@ -1635,6 +1644,8 @@ static int hpre_ecdh_nist_p384_init_tfm(struct crypto_kpp *tfm)
>  
>  	ctx->curve_id = ECC_CURVE_NIST_P384;
>  
> +	kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ);
> +
>  	return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE);
>  }
>  
> @@ -1961,6 +1972,8 @@ static int hpre_curve25519_init_tfm(struct crypto_kpp *tfm)
>  {
>  	struct hpre_ctx *ctx = kpp_tfm_ctx(tfm);
>  
> +	kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ);
> +
>  	return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE);
>  }
>  
> @@ -1981,7 +1994,6 @@ static struct akcipher_alg rsa = {
>  	.max_size = hpre_rsa_max_size,
>  	.init = hpre_rsa_init_tfm,
>  	.exit = hpre_rsa_exit_tfm,
> -	.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  	.base = {
>  		.cra_ctxsize = sizeof(struct hpre_ctx),
>  		.cra_priority = HPRE_CRYPTO_ALG_PRI,
> @@ -1998,7 +2010,6 @@ static struct kpp_alg dh = {
>  	.max_size = hpre_dh_max_size,
>  	.init = hpre_dh_init_tfm,
>  	.exit = hpre_dh_exit_tfm,
> -	.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  	.base = {
>  		.cra_ctxsize = sizeof(struct hpre_ctx),
>  		.cra_priority = HPRE_CRYPTO_ALG_PRI,
> @@ -2016,7 +2027,6 @@ static struct kpp_alg ecdh_curves[] = {
>  		.max_size = hpre_ecdh_max_size,
>  		.init = hpre_ecdh_nist_p192_init_tfm,
>  		.exit = hpre_ecdh_exit_tfm,
> -		.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  		.base = {
>  			.cra_ctxsize = sizeof(struct hpre_ctx),
>  			.cra_priority = HPRE_CRYPTO_ALG_PRI,
> @@ -2031,7 +2041,6 @@ static struct kpp_alg ecdh_curves[] = {
>  		.max_size = hpre_ecdh_max_size,
>  		.init = hpre_ecdh_nist_p256_init_tfm,
>  		.exit = hpre_ecdh_exit_tfm,
> -		.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  		.base = {
>  			.cra_ctxsize = sizeof(struct hpre_ctx),
>  			.cra_priority = HPRE_CRYPTO_ALG_PRI,
> @@ -2046,7 +2055,6 @@ static struct kpp_alg ecdh_curves[] = {
>  		.max_size = hpre_ecdh_max_size,
>  		.init = hpre_ecdh_nist_p384_init_tfm,
>  		.exit = hpre_ecdh_exit_tfm,
> -		.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  		.base = {
>  			.cra_ctxsize = sizeof(struct hpre_ctx),
>  			.cra_priority = HPRE_CRYPTO_ALG_PRI,
> @@ -2064,7 +2072,6 @@ static struct kpp_alg curve25519_alg = {
>  	.max_size = hpre_curve25519_max_size,
>  	.init = hpre_curve25519_init_tfm,
>  	.exit = hpre_curve25519_exit_tfm,
> -	.reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ,
>  	.base = {
>  		.cra_ctxsize = sizeof(struct hpre_ctx),
>  		.cra_priority = HPRE_CRYPTO_ALG_PRI,
> 

Reviewed-by: Longfang Liu <liulongfang@xxxxxxxxxx>
Thanks,
Longfang.



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux