Skip to content

Commit 7d6f564

Browse files
committed
crypto: shash - Add shash_attr_alg2 helper
This patch adds the helper shash_attr_alg2 which locates a shash algorithm based on the information in the given attribute. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent d06854f commit 7d6f564

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎crypto/shash.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,5 +518,15 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
518518
}
519519
EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
520520

521+
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask)
522+
{
523+
struct crypto_alg *alg;
524+
525+
alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask);
526+
return IS_ERR(alg) ? ERR_CAST(alg) :
527+
container_of(alg, struct shash_alg, base);
528+
}
529+
EXPORT_SYMBOL_GPL(shash_attr_alg);
530+
521531
MODULE_LICENSE("GPL");
522532
MODULE_DESCRIPTION("Synchronous cryptographic hash type");

‎include/crypto/internal/hash.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
6060
struct shash_alg *alg,
6161
struct crypto_instance *inst);
6262

63+
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
64+
6365
static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
6466
{
6567
return crypto_tfm_ctx(&tfm->base);

0 commit comments

Comments
 (0)