]> err.no Git - linux-2.6/blobdiff - include/crypto/algapi.h
Pull misc-for-upstream into release branch
[linux-2.6] / include / crypto / algapi.h
index f3946baf0c0788b9ff86f8ba7ca951e968b737b3..4e05e93ff6811248002485475e8a624fa1209cf1 100644 (file)
@@ -18,8 +18,8 @@ struct module;
 struct seq_file;
 
 struct crypto_type {
-       unsigned int (*ctxsize)(struct crypto_alg *alg);
-       int (*init)(struct crypto_tfm *tfm);
+       unsigned int (*ctxsize)(struct crypto_alg *alg, u32 type, u32 mask);
+       int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask);
        void (*exit)(struct crypto_tfm *tfm);
        void (*show)(struct seq_file *m, struct crypto_alg *alg);
 };
@@ -82,6 +82,9 @@ struct blkcipher_walk {
 };
 
 extern const struct crypto_type crypto_blkcipher_type;
+extern const struct crypto_type crypto_hash_type;
+
+void crypto_mod_put(struct crypto_alg *alg);
 
 int crypto_register_template(struct crypto_template *tmpl);
 void crypto_unregister_template(struct crypto_template *tmpl);
@@ -90,7 +93,8 @@ struct crypto_template *crypto_lookup_template(const char *name);
 int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
                      struct crypto_instance *inst);
 void crypto_drop_spawn(struct crypto_spawn *spawn);
-struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn);
+struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
+                                   u32 mask);
 
 struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
                                       u32 type, u32 mask);
@@ -129,11 +133,33 @@ static inline void *crypto_blkcipher_ctx_aligned(struct crypto_blkcipher *tfm)
        return crypto_tfm_ctx_aligned(&tfm->base);
 }
 
+static inline struct crypto_cipher *crypto_spawn_cipher(
+       struct crypto_spawn *spawn)
+{
+       u32 type = CRYPTO_ALG_TYPE_CIPHER;
+       u32 mask = CRYPTO_ALG_TYPE_MASK;
+
+       return __crypto_cipher_cast(crypto_spawn_tfm(spawn, type, mask));
+}
+
 static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
 {
        return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
 }
 
+static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn)
+{
+       u32 type = CRYPTO_ALG_TYPE_HASH;
+       u32 mask = CRYPTO_ALG_TYPE_HASH_MASK;
+
+       return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask));
+}
+
+static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm)
+{
+       return crypto_tfm_ctx_aligned(&tfm->base);
+}
+
 static inline void blkcipher_walk_init(struct blkcipher_walk *walk,
                                       struct scatterlist *dst,
                                       struct scatterlist *src,