diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-14 02:06:06 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-14 03:54:09 -0400 |
| commit | 01c2dece4316dadc0f9fad1ad0b56d493980e492 (patch) | |
| tree | 0d28b58ef64c4b286351ff18adc96899baac5ab8 /include/crypto | |
| parent | 88056ec346ccf41f63dbc7080b24b5fd19d1358d (diff) | |
crypto: ahash - Add instance/spawn support
This patch adds support for creating ahash instances and using
ahash as spawns.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/internal/hash.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 08bdffafefa..34eda233ee6 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
| @@ -34,10 +34,18 @@ struct crypto_hash_walk { | |||
| 34 | unsigned int flags; | 34 | unsigned int flags; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | struct ahash_instance { | ||
| 38 | struct ahash_alg alg; | ||
| 39 | }; | ||
| 40 | |||
| 37 | struct shash_instance { | 41 | struct shash_instance { |
| 38 | struct shash_alg alg; | 42 | struct shash_alg alg; |
| 39 | }; | 43 | }; |
| 40 | 44 | ||
| 45 | struct crypto_ahash_spawn { | ||
| 46 | struct crypto_spawn base; | ||
| 47 | }; | ||
| 48 | |||
| 41 | struct crypto_shash_spawn { | 49 | struct crypto_shash_spawn { |
| 42 | struct crypto_spawn base; | 50 | struct crypto_spawn base; |
| 43 | }; | 51 | }; |
| @@ -53,6 +61,15 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc, | |||
| 53 | 61 | ||
| 54 | int crypto_register_ahash(struct ahash_alg *alg); | 62 | int crypto_register_ahash(struct ahash_alg *alg); |
| 55 | int crypto_unregister_ahash(struct ahash_alg *alg); | 63 | int crypto_unregister_ahash(struct ahash_alg *alg); |
| 64 | int ahash_register_instance(struct crypto_template *tmpl, | ||
| 65 | struct ahash_instance *inst); | ||
| 66 | void ahash_free_instance(struct crypto_instance *inst); | ||
| 67 | |||
| 68 | int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn, | ||
| 69 | struct hash_alg_common *alg, | ||
| 70 | struct crypto_instance *inst); | ||
| 71 | |||
| 72 | struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask); | ||
| 56 | 73 | ||
| 57 | int crypto_register_shash(struct shash_alg *alg); | 74 | int crypto_register_shash(struct shash_alg *alg); |
| 58 | int crypto_unregister_shash(struct shash_alg *alg); | 75 | int crypto_unregister_shash(struct shash_alg *alg); |
| @@ -88,6 +105,40 @@ static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm, | |||
| 88 | tfm->reqsize = reqsize; | 105 | tfm->reqsize = reqsize; |
| 89 | } | 106 | } |
| 90 | 107 | ||
| 108 | static inline struct crypto_instance *ahash_crypto_instance( | ||
| 109 | struct ahash_instance *inst) | ||
| 110 | { | ||
| 111 | return container_of(&inst->alg.halg.base, struct crypto_instance, alg); | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline struct ahash_instance *ahash_instance( | ||
| 115 | struct crypto_instance *inst) | ||
| 116 | { | ||
| 117 | return container_of(&inst->alg, struct ahash_instance, alg.halg.base); | ||
| 118 | } | ||
| 119 | |||
| 120 | static inline void *ahash_instance_ctx(struct ahash_instance *inst) | ||
| 121 | { | ||
| 122 | return crypto_instance_ctx(ahash_crypto_instance(inst)); | ||
| 123 | } | ||
| 124 | |||
| 125 | static inline unsigned int ahash_instance_headroom(void) | ||
| 126 | { | ||
| 127 | return sizeof(struct ahash_alg) - sizeof(struct crypto_alg); | ||
| 128 | } | ||
| 129 | |||
| 130 | static inline struct ahash_instance *ahash_alloc_instance( | ||
| 131 | const char *name, struct crypto_alg *alg) | ||
| 132 | { | ||
| 133 | return crypto_alloc_instance2(name, alg, ahash_instance_headroom()); | ||
| 134 | } | ||
| 135 | |||
| 136 | static inline struct crypto_ahash *crypto_spawn_ahash( | ||
| 137 | struct crypto_ahash_spawn *spawn) | ||
| 138 | { | ||
| 139 | return crypto_spawn_tfm2(&spawn->base); | ||
| 140 | } | ||
| 141 | |||
| 91 | static inline int ahash_enqueue_request(struct crypto_queue *queue, | 142 | static inline int ahash_enqueue_request(struct crypto_queue *queue, |
| 92 | struct ahash_request *request) | 143 | struct ahash_request *request) |
| 93 | { | 144 | { |
