[01/12] crypto: add helper function for akcipher_request
diff mbox series

Message ID 1574029845-22796-2-git-send-email-iuliana.prodan@nxp.com
State New
Headers show
Series
  • crypto: caam - backlogging support
Related show

Commit Message

Iuliana Prodan Nov. 17, 2019, 10:30 p.m. UTC
Add akcipher_request_cast function to get an akcipher_request struct from
a crypto_async_request struct.

Remove this function from ccp driver.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
---
 drivers/crypto/ccp/ccp-crypto-rsa.c | 6 ------
 include/crypto/akcipher.h           | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Corentin Labbe Nov. 18, 2019, 1:29 p.m. UTC | #1
On Mon, Nov 18, 2019 at 12:30:34AM +0200, Iuliana Prodan wrote:
> Add akcipher_request_cast function to get an akcipher_request struct from
> a crypto_async_request struct.
> 
> Remove this function from ccp driver.
> 
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
> ---
>  drivers/crypto/ccp/ccp-crypto-rsa.c | 6 ------
>  include/crypto/akcipher.h           | 6 ++++++
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 

I need (and did) the same for future sun8i-ss/sun8i-ce RSA support.
Thanks

Reviewed-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Horia Geantă Nov. 19, 2019, 2:27 p.m. UTC | #2
On 11/18/2019 12:31 AM, Iuliana Prodan wrote:
> Add akcipher_request_cast function to get an akcipher_request struct from
> a crypto_async_request struct.
> 
> Remove this function from ccp driver.
> 
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

Thanks,
Horia
Gary R Hook Nov. 19, 2019, 3:10 p.m. UTC | #3
On 11/17/19 4:30 PM, Iuliana Prodan wrote:
> Add akcipher_request_cast function to get an akcipher_request struct from
> a crypto_async_request struct.
> 
> Remove this function from ccp driver.
> 
> Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>

Acked-by: Gary R Hook <gary.hook@amd.com>

> ---
>   drivers/crypto/ccp/ccp-crypto-rsa.c | 6 ------
>   include/crypto/akcipher.h           | 6 ++++++
>   2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-crypto-rsa.c b/drivers/crypto/ccp/ccp-crypto-rsa.c
> index 649c91d..3ab659d 100644
> --- a/drivers/crypto/ccp/ccp-crypto-rsa.c
> +++ b/drivers/crypto/ccp/ccp-crypto-rsa.c
> @@ -19,12 +19,6 @@
>   
>   #include "ccp-crypto.h"
>   
> -static inline struct akcipher_request *akcipher_request_cast(
> -	struct crypto_async_request *req)
> -{
> -	return container_of(req, struct akcipher_request, base);
> -}
> -
>   static inline int ccp_copy_and_save_keypart(u8 **kpbuf, unsigned int *kplen,
>   					    const u8 *buf, size_t sz)
>   {
> diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
> index 6924b09..4365edd 100644
> --- a/include/crypto/akcipher.h
> +++ b/include/crypto/akcipher.h
> @@ -170,6 +170,12 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
>   	return __crypto_akcipher_tfm(req->base.tfm);
>   }
>   
> +static inline struct akcipher_request *akcipher_request_cast(
> +	struct crypto_async_request *req)
> +{
> +	return container_of(req, struct akcipher_request, base);
> +}
> +
>   /**
>    * crypto_free_akcipher() - free AKCIPHER tfm handle
>    *
>
Herbert Xu Nov. 22, 2019, 9:08 a.m. UTC | #4
On Mon, Nov 18, 2019 at 12:30:34AM +0200, Iuliana Prodan wrote:
>
> diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
> index 6924b09..4365edd 100644
> --- a/include/crypto/akcipher.h
> +++ b/include/crypto/akcipher.h
> @@ -170,6 +170,12 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
>  	return __crypto_akcipher_tfm(req->base.tfm);
>  }
>  
> +static inline struct akcipher_request *akcipher_request_cast(
> +	struct crypto_async_request *req)
> +{
> +	return container_of(req, struct akcipher_request, base);
> +}

This should go into include/crypto/internal/akcipher.h as it's
only used by implementors.

But having reviewed the subsequent patches I think we shouldn't
have this function at all.

Cheers,
Iuliana Prodan Nov. 22, 2019, 10:29 a.m. UTC | #5
On 11/22/2019 11:08 AM, Herbert Xu wrote:
> On Mon, Nov 18, 2019 at 12:30:34AM +0200, Iuliana Prodan wrote:
>>
>> diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
>> index 6924b09..4365edd 100644
>> --- a/include/crypto/akcipher.h
>> +++ b/include/crypto/akcipher.h
>> @@ -170,6 +170,12 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
>>   	return __crypto_akcipher_tfm(req->base.tfm);
>>   }
>>   
>> +static inline struct akcipher_request *akcipher_request_cast(
>> +	struct crypto_async_request *req)
>> +{
>> +	return container_of(req, struct akcipher_request, base);
>> +}
> 
> This should go into include/crypto/internal/akcipher.h as it's
> only used by implementors.
> 
> But having reviewed the subsequent patches I think we shouldn't
> have this function at all.
> 

Why can't we use this? There are similar functions for 
skcipher/aead/ahash and they are all in include/crypto.

Thanks,
Iulia
Herbert Xu Nov. 22, 2019, 10:34 a.m. UTC | #6
On Fri, Nov 22, 2019 at 10:29:01AM +0000, Iuliana Prodan wrote:
>
> Why can't we use this? There are similar functions for 
> skcipher/aead/ahash and they are all in include/crypto.

Because we don't want drivers to use the underlying crypto_request
at all.  All drivers should be using the aead_request and others.

Only infrastructure code such as crypto_engine may use the base
type internally.

Cheers,

Patch
diff mbox series

diff --git a/drivers/crypto/ccp/ccp-crypto-rsa.c b/drivers/crypto/ccp/ccp-crypto-rsa.c
index 649c91d..3ab659d 100644
--- a/drivers/crypto/ccp/ccp-crypto-rsa.c
+++ b/drivers/crypto/ccp/ccp-crypto-rsa.c
@@ -19,12 +19,6 @@ 
 
 #include "ccp-crypto.h"
 
-static inline struct akcipher_request *akcipher_request_cast(
-	struct crypto_async_request *req)
-{
-	return container_of(req, struct akcipher_request, base);
-}
-
 static inline int ccp_copy_and_save_keypart(u8 **kpbuf, unsigned int *kplen,
 					    const u8 *buf, size_t sz)
 {
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index 6924b09..4365edd 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -170,6 +170,12 @@  static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
 	return __crypto_akcipher_tfm(req->base.tfm);
 }
 
+static inline struct akcipher_request *akcipher_request_cast(
+	struct crypto_async_request *req)
+{
+	return container_of(req, struct akcipher_request, base);
+}
+
 /**
  * crypto_free_akcipher() - free AKCIPHER tfm handle
  *