4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
13 #ifndef _CRYPTO_INTERNAL_H
14 #define _CRYPTO_INTERNAL_H
16 #include <crypto/algapi.h>
17 #include <linux/completion.h>
19 #include <linux/list.h>
20 #include <linux/kernel.h>
21 #include <linux/notifier.h>
22 #include <linux/rwsem.h>
23 #include <linux/slab.h>
25 struct crypto_instance;
26 struct crypto_template;
28 struct crypto_larval {
29 struct crypto_alg alg;
30 struct crypto_alg *adult;
31 struct completion completion;
35 extern struct list_head crypto_alg_list;
36 extern struct rw_semaphore crypto_alg_sem;
38 static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
40 return alg->cra_ctxsize;
43 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
44 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
46 void crypto_remove_final(struct list_head *list);
47 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
49 void *crypto_create_tfm(struct crypto_alg *alg,
50 const struct crypto_type *frontend);
51 struct crypto_alg *crypto_find_alg(const char *alg_name,
52 const struct crypto_type *frontend,
54 void *crypto_alloc_tfm(const char *alg_name,
55 const struct crypto_type *frontend, u32 type, u32 mask);
57 int crypto_register_notifier(struct notifier_block *nb);
58 int crypto_unregister_notifier(struct notifier_block *nb);
60 unsigned int crypto_alg_extsize(struct crypto_alg *alg);
62 int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
65 static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
67 atomic_inc(&alg->cra_refcnt);
71 static inline void crypto_alg_put(struct crypto_alg *alg)
73 if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)
74 alg->cra_destroy(alg);
77 #endif /* _CRYPTO_INTERNAL_H */