Skip to content

Commit 9429699

Browse files
committed
crypto: shash - Add spawn support
This patch adds the functions needed to create and use shash spawns, i.e., to use shash algorithms in a template. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 97eedce commit 9429699

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎crypto/shash.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,5 +509,14 @@ void shash_free_instance(struct crypto_instance *inst)
509509
}
510510
EXPORT_SYMBOL_GPL(shash_free_instance);
511511

512+
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
513+
struct shash_alg *alg,
514+
struct crypto_instance *inst)
515+
{
516+
return crypto_init_spawn2(&spawn->base, &alg->base, inst,
517+
&crypto_shash_type);
518+
}
519+
EXPORT_SYMBOL_GPL(crypto_init_shash_spawn);
520+
512521
MODULE_LICENSE("GPL");
513522
MODULE_DESCRIPTION("Synchronous cryptographic hash type");

‎include/crypto/internal/hash.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ struct shash_instance {
3838
struct shash_alg alg;
3939
};
4040

41+
struct crypto_shash_spawn {
42+
struct crypto_spawn base;
43+
};
44+
4145
extern const struct crypto_type crypto_ahash_type;
4246

4347
int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err);
@@ -52,6 +56,10 @@ int crypto_unregister_shash(struct shash_alg *alg);
5256

5357
void shash_free_instance(struct crypto_instance *inst);
5458

59+
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
60+
struct shash_alg *alg,
61+
struct crypto_instance *inst);
62+
5563
static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
5664
{
5765
return crypto_tfm_ctx(&tfm->base);
@@ -106,5 +114,11 @@ static inline struct shash_instance *shash_alloc_instance(
106114
sizeof(struct shash_alg) - sizeof(*alg));
107115
}
108116

117+
static inline struct crypto_shash *crypto_spawn_shash(
118+
struct crypto_shash_spawn *spawn)
119+
{
120+
return crypto_spawn_tfm2(&spawn->base);
121+
}
122+
109123
#endif /* _CRYPTO_INTERNAL_HASH_H */
110124

0 commit comments

Comments
 (0)