diff mbox series

[01/12] crypto: add crypto_has_shash()

Message ID 20211112125928.97318-2-hare@suse.de (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show
Series nvme: In-band authentication support | expand

Commit Message

Hannes Reinecke Nov. 12, 2021, 12:59 p.m. UTC
Add helper function to determine if a given synchronous hash is supported.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 crypto/shash.c        | 6 ++++++
 include/crypto/hash.h | 2 ++
 2 files changed, 8 insertions(+)

Comments

Himanshu Madhani Nov. 15, 2021, 3:19 p.m. UTC | #1
On 11/12/21 06:59, Hannes Reinecke wrote:
> Add helper function to determine if a given synchronous hash is supported.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
>   crypto/shash.c        | 6 ++++++
>   include/crypto/hash.h | 2 ++
>   2 files changed, 8 insertions(+)
> 
> diff --git a/crypto/shash.c b/crypto/shash.c
> index 0a0a50cb694f..4c88e63b3350 100644
> --- a/crypto/shash.c
> +++ b/crypto/shash.c
> @@ -521,6 +521,12 @@ struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
>   }
>   EXPORT_SYMBOL_GPL(crypto_alloc_shash);
>   
> +int crypto_has_shash(const char *alg_name, u32 type, u32 mask)
> +{
> +	return crypto_type_has_alg(alg_name, &crypto_shash_type, type, mask);
> +}
> +EXPORT_SYMBOL_GPL(crypto_has_shash);
> +
>   static int shash_prepare_alg(struct shash_alg *alg)
>   {
>   	struct crypto_alg *base = &alg->base;
> diff --git a/include/crypto/hash.h b/include/crypto/hash.h
> index f140e4643949..f5841992dc9b 100644
> --- a/include/crypto/hash.h
> +++ b/include/crypto/hash.h
> @@ -718,6 +718,8 @@ static inline void ahash_request_set_crypt(struct ahash_request *req,
>   struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
>   					u32 mask);
>   
> +int crypto_has_shash(const char *alg_name, u32 type, u32 mask);
> +
>   static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
>   {
>   	return &tfm->base;
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff mbox series

Patch

diff --git a/crypto/shash.c b/crypto/shash.c
index 0a0a50cb694f..4c88e63b3350 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -521,6 +521,12 @@  struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
 }
 EXPORT_SYMBOL_GPL(crypto_alloc_shash);
 
+int crypto_has_shash(const char *alg_name, u32 type, u32 mask)
+{
+	return crypto_type_has_alg(alg_name, &crypto_shash_type, type, mask);
+}
+EXPORT_SYMBOL_GPL(crypto_has_shash);
+
 static int shash_prepare_alg(struct shash_alg *alg)
 {
 	struct crypto_alg *base = &alg->base;
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index f140e4643949..f5841992dc9b 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -718,6 +718,8 @@  static inline void ahash_request_set_crypt(struct ahash_request *req,
 struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
 					u32 mask);
 
+int crypto_has_shash(const char *alg_name, u32 type, u32 mask);
+
 static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
 {
 	return &tfm->base;