]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/crypto/internal/hash.h
Merge branch 'bjorn-start-stop-2.6.32' into release
[karo-tx-linux.git] / include / crypto / internal / hash.h
index 069b93e1a8ec47ab1bf290ff60182cde42b9c93f..5bfad8c8059580d9668c72e9acf9f056f24b928c 100644 (file)
@@ -34,10 +34,18 @@ struct crypto_hash_walk {
        unsigned int flags;
 };
 
+struct ahash_instance {
+       struct ahash_alg alg;
+};
+
 struct shash_instance {
        struct shash_alg alg;
 };
 
+struct crypto_ahash_spawn {
+       struct crypto_spawn base;
+};
+
 struct crypto_shash_spawn {
        struct crypto_spawn base;
 };
@@ -51,6 +59,28 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
                                  struct crypto_hash_walk *walk,
                                  struct scatterlist *sg, unsigned int len);
 
+static inline int crypto_hash_walk_last(struct crypto_hash_walk *walk)
+{
+       return !(walk->entrylen | walk->total);
+}
+
+int crypto_register_ahash(struct ahash_alg *alg);
+int crypto_unregister_ahash(struct ahash_alg *alg);
+int ahash_register_instance(struct crypto_template *tmpl,
+                           struct ahash_instance *inst);
+void ahash_free_instance(struct crypto_instance *inst);
+
+int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
+                           struct hash_alg_common *alg,
+                           struct crypto_instance *inst);
+
+static inline void crypto_drop_ahash(struct crypto_ahash_spawn *spawn)
+{
+       crypto_drop_spawn(&spawn->base);
+}
+
+struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
+
 int crypto_register_shash(struct shash_alg *alg);
 int crypto_unregister_shash(struct shash_alg *alg);
 int shash_register_instance(struct crypto_template *tmpl,
@@ -61,17 +91,68 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
                            struct shash_alg *alg,
                            struct crypto_instance *inst);
 
+static inline void crypto_drop_shash(struct crypto_shash_spawn *spawn)
+{
+       crypto_drop_spawn(&spawn->base);
+}
+
 struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
 
+int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
+int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc);
+int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
+
+int crypto_init_shash_ops_async(struct crypto_tfm *tfm);
+
 static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
 {
-       return crypto_tfm_ctx(&tfm->base);
+       return crypto_tfm_ctx(crypto_ahash_tfm(tfm));
 }
 
-static inline struct ahash_alg *crypto_ahash_alg(
-       struct crypto_ahash *tfm)
+static inline struct ahash_alg *__crypto_ahash_alg(struct crypto_alg *alg)
 {
-       return &crypto_ahash_tfm(tfm)->__crt_alg->cra_ahash;
+       return container_of(__crypto_hash_alg_common(alg), struct ahash_alg,
+                           halg);
+}
+
+static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm,
+                                           unsigned int reqsize)
+{
+       tfm->reqsize = reqsize;
+}
+
+static inline struct crypto_instance *ahash_crypto_instance(
+       struct ahash_instance *inst)
+{
+       return container_of(&inst->alg.halg.base, struct crypto_instance, alg);
+}
+
+static inline struct ahash_instance *ahash_instance(
+       struct crypto_instance *inst)
+{
+       return container_of(&inst->alg, struct ahash_instance, alg.halg.base);
+}
+
+static inline void *ahash_instance_ctx(struct ahash_instance *inst)
+{
+       return crypto_instance_ctx(ahash_crypto_instance(inst));
+}
+
+static inline unsigned int ahash_instance_headroom(void)
+{
+       return sizeof(struct ahash_alg) - sizeof(struct crypto_alg);
+}
+
+static inline struct ahash_instance *ahash_alloc_instance(
+       const char *name, struct crypto_alg *alg)
+{
+       return crypto_alloc_instance2(name, alg, ahash_instance_headroom());
+}
+
+static inline struct crypto_ahash *crypto_spawn_ahash(
+       struct crypto_ahash_spawn *spawn)
+{
+       return crypto_spawn_tfm2(&spawn->base);
 }
 
 static inline int ahash_enqueue_request(struct crypto_queue *queue,
@@ -135,7 +216,7 @@ static inline void *crypto_shash_ctx_aligned(struct crypto_shash *tfm)
 
 static inline struct crypto_shash *__crypto_shash_cast(struct crypto_tfm *tfm)
 {
-       return (struct crypto_shash *)tfm;
+       return container_of(tfm, struct crypto_shash, base);
 }
 
 #endif /* _CRYPTO_INTERNAL_HASH_H */