diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-08 05:21:37 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-08 06:58:29 -0400 |
commit | 942969992d86330c9700e2cd9afe8a6bea42df78 (patch) | |
tree | 4183f307974076a606c97bf5b5c333aa4021562b | |
parent | 97eedce1a64a57648ac5e39f03825528c47ba72e (diff) |
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>
-rw-r--r-- | crypto/shash.c | 9 | ||||
-rw-r--r-- | include/crypto/internal/hash.h | 14 |
2 files changed, 23 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 8f9d8831e293..97f6c8ba103a 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -509,5 +509,14 @@ void shash_free_instance(struct crypto_instance *inst) | |||
509 | } | 509 | } |
510 | EXPORT_SYMBOL_GPL(shash_free_instance); | 510 | EXPORT_SYMBOL_GPL(shash_free_instance); |
511 | 511 | ||
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 | |||
512 | MODULE_LICENSE("GPL"); | 521 | MODULE_LICENSE("GPL"); |
513 | MODULE_DESCRIPTION("Synchronous cryptographic hash type"); | 522 | MODULE_DESCRIPTION("Synchronous cryptographic hash type"); |
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 44d3bcdce6e2..6cc824b79331 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
@@ -38,6 +38,10 @@ struct shash_instance { | |||
38 | struct shash_alg alg; | 38 | struct shash_alg alg; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct crypto_shash_spawn { | ||
42 | struct crypto_spawn base; | ||
43 | }; | ||
44 | |||
41 | extern const struct crypto_type crypto_ahash_type; | 45 | extern const struct crypto_type crypto_ahash_type; |
42 | 46 | ||
43 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); | 47 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); |
@@ -52,6 +56,10 @@ int crypto_unregister_shash(struct shash_alg *alg); | |||
52 | 56 | ||
53 | void shash_free_instance(struct crypto_instance *inst); | 57 | void shash_free_instance(struct crypto_instance *inst); |
54 | 58 | ||
59 | int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn, | ||
60 | struct shash_alg *alg, | ||
61 | struct crypto_instance *inst); | ||
62 | |||
55 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) | 63 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) |
56 | { | 64 | { |
57 | return crypto_tfm_ctx(&tfm->base); | 65 | return crypto_tfm_ctx(&tfm->base); |
@@ -106,5 +114,11 @@ static inline struct shash_instance *shash_alloc_instance( | |||
106 | sizeof(struct shash_alg) - sizeof(*alg)); | 114 | sizeof(struct shash_alg) - sizeof(*alg)); |
107 | } | 115 | } |
108 | 116 | ||
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 | |||
109 | #endif /* _CRYPTO_INTERNAL_HASH_H */ | 123 | #endif /* _CRYPTO_INTERNAL_HASH_H */ |
110 | 124 | ||