Blame view
crypto/internal.h
3.3 KB
2874c5fd2
|
1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
1da177e4c
|
2 3 4 5 |
/* * Cryptographic API. * * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
5cb1454b8
|
6 |
* Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au> |
1da177e4c
|
7 8 9 |
*/ #ifndef _CRYPTO_INTERNAL_H #define _CRYPTO_INTERNAL_H |
cce9e06d1
|
10 11 |
#include <crypto/algapi.h> |
2825982d9
|
12 |
#include <linux/completion.h> |
1da177e4c
|
13 14 15 16 |
#include <linux/mm.h> #include <linux/highmem.h> #include <linux/interrupt.h> #include <linux/init.h> |
5cb1454b8
|
17 |
#include <linux/list.h> |
4cc7720cd
|
18 |
#include <linux/module.h> |
fbdae9f3e
|
19 |
#include <linux/kernel.h> |
2825982d9
|
20 |
#include <linux/notifier.h> |
5cb1454b8
|
21 |
#include <linux/rwsem.h> |
64baf3cfe
|
22 |
#include <linux/slab.h> |
ccb778e18
|
23 |
|
4cc7720cd
|
24 25 |
struct crypto_instance; struct crypto_template; |
2825982d9
|
26 27 28 29 |
struct crypto_larval { struct crypto_alg alg; struct crypto_alg *adult; struct completion completion; |
492e2b63e
|
30 |
u32 mask; |
2825982d9
|
31 |
}; |
5cb1454b8
|
32 33 |
extern struct list_head crypto_alg_list; extern struct rw_semaphore crypto_alg_sem; |
2825982d9
|
34 |
extern struct blocking_notifier_head crypto_chain; |
5cb1454b8
|
35 |
|
1da177e4c
|
36 37 |
#ifdef CONFIG_PROC_FS void __init crypto_init_proc(void); |
cce9e06d1
|
38 |
void __exit crypto_exit_proc(void); |
1da177e4c
|
39 40 41 |
#else static inline void crypto_init_proc(void) { } |
cce9e06d1
|
42 43 |
static inline void crypto_exit_proc(void) { } |
1da177e4c
|
44 |
#endif |
f1ddcaf33
|
45 |
static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg) |
fbdae9f3e
|
46 |
{ |
f1ddcaf33
|
47 |
return alg->cra_ctxsize; |
fbdae9f3e
|
48 |
} |
f1ddcaf33
|
49 |
static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg) |
fbdae9f3e
|
50 51 52 |
{ return alg->cra_ctxsize; } |
2825982d9
|
53 |
struct crypto_alg *crypto_mod_get(struct crypto_alg *alg); |
492e2b63e
|
54 |
struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask); |
2825982d9
|
55 |
|
73d3864a4
|
56 |
struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask); |
b9c55aa47
|
57 |
void crypto_larval_kill(struct crypto_alg *alg); |
73d3864a4
|
58 |
void crypto_alg_tested(const char *name, int err); |
2825982d9
|
59 |
|
89b596ba2
|
60 61 |
void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list, struct crypto_alg *nalg); |
22e5b20be
|
62 |
void crypto_remove_final(struct list_head *list); |
27d2a3300
|
63 64 |
struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, u32 mask); |
3f683d617
|
65 66 |
void *crypto_create_tfm(struct crypto_alg *alg, const struct crypto_type *frontend); |
d06854f02
|
67 68 69 |
struct crypto_alg *crypto_find_alg(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask); |
3f683d617
|
70 71 |
void *crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask); |
4cc7720cd
|
72 |
|
73d3864a4
|
73 |
int crypto_probing_notify(unsigned long val, void *v); |
2825982d9
|
74 |
|
38d214331
|
75 |
unsigned int crypto_alg_extsize(struct crypto_alg *alg); |
f2aefdab5
|
76 77 |
int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, u32 type, u32 mask); |
939e17799
|
78 79 |
static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) { |
ce8614a31
|
80 |
refcount_inc(&alg->cra_refcnt); |
939e17799
|
81 82 |
return alg; } |
6bfd48096
|
83 84 |
static inline void crypto_alg_put(struct crypto_alg *alg) { |
ce8614a31
|
85 |
if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) |
6bfd48096
|
86 87 |
alg->cra_destroy(alg); } |
4cc7720cd
|
88 89 90 91 92 93 94 95 96 |
static inline int crypto_tmpl_get(struct crypto_template *tmpl) { return try_module_get(tmpl->module); } static inline void crypto_tmpl_put(struct crypto_template *tmpl) { module_put(tmpl->module); } |
2825982d9
|
97 98 99 100 |
static inline int crypto_is_larval(struct crypto_alg *alg) { return alg->cra_flags & CRYPTO_ALG_LARVAL; } |
6bfd48096
|
101 102 103 104 105 106 107 108 109 |
static inline int crypto_is_dead(struct crypto_alg *alg) { return alg->cra_flags & CRYPTO_ALG_DEAD; } static inline int crypto_is_moribund(struct crypto_alg *alg) { return alg->cra_flags & (CRYPTO_ALG_DEAD | CRYPTO_ALG_DYING); } |
73d3864a4
|
110 |
static inline void crypto_notify(unsigned long val, void *v) |
2825982d9
|
111 |
{ |
73d3864a4
|
112 |
blocking_notifier_call_chain(&crypto_chain, val, v); |
2825982d9
|
113 |
} |
1da177e4c
|
114 |
#endif /* _CRYPTO_INTERNAL_H */ |