crypto: tcrypt - add lrw(twofish) tests
[linux-flexiantxendom0-3.2.10.git] / crypto / algapi.c
index f149b1c..54dd4e3 100644 (file)
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include "internal.h"
 
-static void crypto_remove_final(struct list_head *list);
-
 static LIST_HEAD(crypto_template_list);
 
 void crypto_larval_error(const char *name, u32 type, u32 mask)
@@ -128,9 +127,8 @@ static void crypto_remove_spawn(struct crypto_spawn *spawn,
        BUG_ON(!list_empty(&inst->alg.cra_users));
 }
 
-static void crypto_remove_spawns(struct crypto_alg *alg,
-                                struct list_head *list,
-                                struct crypto_alg *nalg)
+void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
+                         struct crypto_alg *nalg)
 {
        u32 new_type = (nalg ?: alg)->cra_flags;
        struct crypto_spawn *spawn, *n;
@@ -176,6 +174,7 @@ static void crypto_remove_spawns(struct crypto_alg *alg,
                        crypto_remove_spawn(spawn, list);
        }
 }
+EXPORT_SYMBOL_GPL(crypto_remove_spawns);
 
 static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
 {
@@ -230,7 +229,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
        list_add(&alg->cra_list, &crypto_alg_list);
        list_add(&larval->alg.cra_list, &crypto_alg_list);
 
-out:   
+out:
        return larval;
 
 free_larval:
@@ -320,7 +319,7 @@ unlock:
 }
 EXPORT_SYMBOL_GPL(crypto_alg_tested);
 
-static void crypto_remove_final(struct list_head *list)
+void crypto_remove_final(struct list_head *list)
 {
        struct crypto_alg *alg;
        struct crypto_alg *n;
@@ -330,6 +329,7 @@ static void crypto_remove_final(struct list_head *list)
                crypto_alg_put(alg);
        }
 }
+EXPORT_SYMBOL_GPL(crypto_remove_final);
 
 static void crypto_wait_for_test(struct crypto_larval *larval)
 {
@@ -388,7 +388,7 @@ int crypto_unregister_alg(struct crypto_alg *alg)
 {
        int ret;
        LIST_HEAD(list);
-       
+
        down_write(&crypto_alg_sem);
        ret = crypto_remove_alg(alg, &list);
        up_write(&crypto_alg_sem);
@@ -492,6 +492,7 @@ int crypto_register_instance(struct crypto_template *tmpl,
                goto err;
 
        inst->alg.cra_module = tmpl->module;
+       inst->alg.cra_flags |= CRYPTO_ALG_INSTANCE;
 
        down_write(&crypto_alg_sem);
 
@@ -543,7 +544,7 @@ int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg,
 {
        int err = -EINVAL;
 
-       if (frontend && (alg->cra_flags ^ frontend->type) & frontend->maskset)
+       if ((alg->cra_flags ^ frontend->type) & frontend->maskset)
                goto out;
 
        spawn->frontend = frontend;