Skip to content

Commit

Permalink
crypto: add crypto_has_shash()
Browse files Browse the repository at this point in the history
Add helper function to determine if a given synchronous hash is supported.

Signed-off-by: Hannes Reinecke <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
Reviewed-by: Himanshu Madhani <[email protected]>
Acked-by: Herbert Xu <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
hreinecke authored and axboe committed Aug 2, 2022
1 parent e41f8c0 commit 85cc424
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto/shash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions include/crypto/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 85cc424

Please sign in to comment.