]> git.sesse.net Git - bcachefs-tools-debian/blob - linux/crypto/internal.h
bcache in userspace; userspace fsck
[bcachefs-tools-debian] / linux / crypto / internal.h
1 /*
2  * Cryptographic API.
3  *
4  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5  * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
6  *
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)
10  * any later version.
11  *
12  */
13 #ifndef _CRYPTO_INTERNAL_H
14 #define _CRYPTO_INTERNAL_H
15
16 #include <crypto/algapi.h>
17 #include <linux/completion.h>
18 #include <linux/mm.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>
24
25 struct crypto_instance;
26 struct crypto_template;
27
28 struct crypto_larval {
29         struct crypto_alg alg;
30         struct crypto_alg *adult;
31         struct completion completion;
32         u32 mask;
33 };
34
35 extern struct list_head crypto_alg_list;
36 extern struct rw_semaphore crypto_alg_sem;
37
38 static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg)
39 {
40         return alg->cra_ctxsize;
41 }
42
43 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
44 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
45
46 void crypto_remove_final(struct list_head *list);
47 struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
48                                       u32 mask);
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,
53                                    u32 type, u32 mask);
54 void *crypto_alloc_tfm(const char *alg_name,
55                        const struct crypto_type *frontend, u32 type, u32 mask);
56
57 int crypto_register_notifier(struct notifier_block *nb);
58 int crypto_unregister_notifier(struct notifier_block *nb);
59
60 unsigned int crypto_alg_extsize(struct crypto_alg *alg);
61
62 int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
63                         u32 type, u32 mask);
64
65 static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
66 {
67         atomic_inc(&alg->cra_refcnt);
68         return alg;
69 }
70
71 static inline void crypto_alg_put(struct crypto_alg *alg)
72 {
73         if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)
74                 alg->cra_destroy(alg);
75 }
76
77 #endif  /* _CRYPTO_INTERNAL_H */
78