1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _CRYPTO_IF_ALG_H
14#define _CRYPTO_IF_ALG_H
15
16#include <linux/compiler.h>
17#include <linux/completion.h>
18#include <linux/if_alg.h>
19#include <linux/scatterlist.h>
20#include <linux/types.h>
21#include <net/sock.h>
22
23#define ALG_MAX_PAGES 16
24
25struct crypto_async_request;
26
27struct alg_sock {
28
29 struct sock sk;
30
31 struct sock *parent;
32
33 const struct af_alg_type *type;
34 void *private;
35};
36
37struct af_alg_completion {
38 struct completion completion;
39 int err;
40};
41
42struct af_alg_control {
43 struct af_alg_iv *iv;
44 int op;
45};
46
47struct af_alg_type {
48 void *(*bind)(const char *name, u32 type, u32 mask);
49 void (*release)(void *private);
50 int (*setkey)(void *private, const u8 *key, unsigned int keylen);
51 int (*accept)(void *private, struct sock *sk);
52
53 struct proto_ops *ops;
54 struct module *owner;
55 char name[14];
56};
57
58struct af_alg_sgl {
59 struct scatterlist sg[ALG_MAX_PAGES];
60 struct page *pages[ALG_MAX_PAGES];
61};
62
63int af_alg_register_type(const struct af_alg_type *type);
64int af_alg_unregister_type(const struct af_alg_type *type);
65
66int af_alg_release(struct socket *sock);
67int af_alg_accept(struct sock *sk, struct socket *newsock);
68
69int af_alg_make_sg(struct af_alg_sgl *sgl, void __user *addr, int len,
70 int write);
71void af_alg_free_sg(struct af_alg_sgl *sgl);
72
73int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
74
75int af_alg_wait_for_completion(int err, struct af_alg_completion *completion);
76void af_alg_complete(struct crypto_async_request *req, int err);
77
78static inline struct alg_sock *alg_sk(struct sock *sk)
79{
80 return (struct alg_sock *)sk;
81}
82
83static inline void af_alg_release_parent(struct sock *sk)
84{
85 sock_put(alg_sk(sk)->parent);
86}
87
88static inline void af_alg_init_completion(struct af_alg_completion *completion)
89{
90 init_completion(&completion->completion);
91}
92
93#endif
94