diff options
-rw-r--r-- | crypto/shash.c | 7 | ||||
-rw-r--r-- | include/crypto/internal/hash.h | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 2ccc8b0076ce..8f9d8831e293 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -502,5 +502,12 @@ int crypto_unregister_shash(struct shash_alg *alg) | |||
502 | } | 502 | } |
503 | EXPORT_SYMBOL_GPL(crypto_unregister_shash); | 503 | EXPORT_SYMBOL_GPL(crypto_unregister_shash); |
504 | 504 | ||
505 | void shash_free_instance(struct crypto_instance *inst) | ||
506 | { | ||
507 | crypto_drop_spawn(crypto_instance_ctx(inst)); | ||
508 | kfree(shash_instance(inst)); | ||
509 | } | ||
510 | EXPORT_SYMBOL_GPL(shash_free_instance); | ||
511 | |||
505 | MODULE_LICENSE("GPL"); | 512 | MODULE_LICENSE("GPL"); |
506 | MODULE_DESCRIPTION("Synchronous cryptographic hash type"); | 513 | MODULE_DESCRIPTION("Synchronous cryptographic hash type"); |
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 82b70564bcab..44d3bcdce6e2 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
@@ -34,6 +34,10 @@ struct crypto_hash_walk { | |||
34 | unsigned int flags; | 34 | unsigned int flags; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | struct shash_instance { | ||
38 | struct shash_alg alg; | ||
39 | }; | ||
40 | |||
37 | extern const struct crypto_type crypto_ahash_type; | 41 | extern const struct crypto_type crypto_ahash_type; |
38 | 42 | ||
39 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); | 43 | int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err); |
@@ -46,6 +50,8 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc, | |||
46 | int crypto_register_shash(struct shash_alg *alg); | 50 | int crypto_register_shash(struct shash_alg *alg); |
47 | int crypto_unregister_shash(struct shash_alg *alg); | 51 | int crypto_unregister_shash(struct shash_alg *alg); |
48 | 52 | ||
53 | void shash_free_instance(struct crypto_instance *inst); | ||
54 | |||
49 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) | 55 | static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm) |
50 | { | 56 | { |
51 | return crypto_tfm_ctx(&tfm->base); | 57 | return crypto_tfm_ctx(&tfm->base); |
@@ -80,5 +86,25 @@ static inline void *crypto_shash_ctx(struct crypto_shash *tfm) | |||
80 | return crypto_tfm_ctx(&tfm->base); | 86 | return crypto_tfm_ctx(&tfm->base); |
81 | } | 87 | } |
82 | 88 | ||
89 | static inline struct crypto_instance *shash_crypto_instance( | ||
90 | struct shash_instance *inst) | ||
91 | { | ||
92 | return container_of(&inst->alg.base, struct crypto_instance, alg); | ||
93 | } | ||
94 | |||
95 | static inline struct shash_instance *shash_instance( | ||
96 | struct crypto_instance *inst) | ||
97 | { | ||
98 | return container_of(__crypto_shash_alg(&inst->alg), | ||
99 | struct shash_instance, alg); | ||
100 | } | ||
101 | |||
102 | static inline struct shash_instance *shash_alloc_instance( | ||
103 | const char *name, struct crypto_alg *alg) | ||
104 | { | ||
105 | return crypto_alloc_instance2(name, alg, | ||
106 | sizeof(struct shash_alg) - sizeof(*alg)); | ||
107 | } | ||
108 | |||
83 | #endif /* _CRYPTO_INTERNAL_HASH_H */ | 109 | #endif /* _CRYPTO_INTERNAL_HASH_H */ |
84 | 110 | ||