diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/if_alg.h | 92 | ||||
-rw-r--r-- | include/crypto/padlock.h | 29 | ||||
-rw-r--r-- | include/crypto/scatterwalk.h | 15 | ||||
-rw-r--r-- | include/linux/Kbuild | 1 | ||||
-rw-r--r-- | include/linux/if_alg.h | 40 | ||||
-rw-r--r-- | include/linux/socket.h | 5 |
6 files changed, 181 insertions, 1 deletions
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h new file mode 100644 index 000000000000..c5813c87de06 --- /dev/null +++ b/include/crypto/if_alg.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * if_alg: User-space algorithm interface | ||
3 | * | ||
4 | * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
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/types.h> | ||
20 | #include <net/sock.h> | ||
21 | |||
22 | #define ALG_MAX_PAGES 16 | ||
23 | |||
24 | struct crypto_async_request; | ||
25 | |||
26 | struct alg_sock { | ||
27 | /* struct sock must be the first member of struct alg_sock */ | ||
28 | struct sock sk; | ||
29 | |||
30 | struct sock *parent; | ||
31 | |||
32 | const struct af_alg_type *type; | ||
33 | void *private; | ||
34 | }; | ||
35 | |||
36 | struct af_alg_completion { | ||
37 | struct completion completion; | ||
38 | int err; | ||
39 | }; | ||
40 | |||
41 | struct af_alg_control { | ||
42 | struct af_alg_iv *iv; | ||
43 | int op; | ||
44 | }; | ||
45 | |||
46 | struct af_alg_type { | ||
47 | void *(*bind)(const char *name, u32 type, u32 mask); | ||
48 | void (*release)(void *private); | ||
49 | int (*setkey)(void *private, const u8 *key, unsigned int keylen); | ||
50 | int (*accept)(void *private, struct sock *sk); | ||
51 | |||
52 | struct proto_ops *ops; | ||
53 | struct module *owner; | ||
54 | char name[14]; | ||
55 | }; | ||
56 | |||
57 | struct af_alg_sgl { | ||
58 | struct scatterlist sg[ALG_MAX_PAGES]; | ||
59 | struct page *pages[ALG_MAX_PAGES]; | ||
60 | }; | ||
61 | |||
62 | int af_alg_register_type(const struct af_alg_type *type); | ||
63 | int af_alg_unregister_type(const struct af_alg_type *type); | ||
64 | |||
65 | int af_alg_release(struct socket *sock); | ||
66 | int af_alg_accept(struct sock *sk, struct socket *newsock); | ||
67 | |||
68 | int af_alg_make_sg(struct af_alg_sgl *sgl, void __user *addr, int len, | ||
69 | int write); | ||
70 | void af_alg_free_sg(struct af_alg_sgl *sgl); | ||
71 | |||
72 | int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con); | ||
73 | |||
74 | int af_alg_wait_for_completion(int err, struct af_alg_completion *completion); | ||
75 | void af_alg_complete(struct crypto_async_request *req, int err); | ||
76 | |||
77 | static inline struct alg_sock *alg_sk(struct sock *sk) | ||
78 | { | ||
79 | return (struct alg_sock *)sk; | ||
80 | } | ||
81 | |||
82 | static inline void af_alg_release_parent(struct sock *sk) | ||
83 | { | ||
84 | sock_put(alg_sk(sk)->parent); | ||
85 | } | ||
86 | |||
87 | static inline void af_alg_init_completion(struct af_alg_completion *completion) | ||
88 | { | ||
89 | init_completion(&completion->completion); | ||
90 | } | ||
91 | |||
92 | #endif /* _CRYPTO_IF_ALG_H */ | ||
diff --git a/include/crypto/padlock.h b/include/crypto/padlock.h new file mode 100644 index 000000000000..d2cfa2ef49e8 --- /dev/null +++ b/include/crypto/padlock.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Driver for VIA PadLock | ||
3 | * | ||
4 | * Copyright (c) 2004 Michal Ludvig <michal@logix.cz> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _CRYPTO_PADLOCK_H | ||
14 | #define _CRYPTO_PADLOCK_H | ||
15 | |||
16 | #define PADLOCK_ALIGNMENT 16 | ||
17 | |||
18 | #define PFX KBUILD_MODNAME ": " | ||
19 | |||
20 | #define PADLOCK_CRA_PRIORITY 300 | ||
21 | #define PADLOCK_COMPOSITE_PRIORITY 400 | ||
22 | |||
23 | #ifdef CONFIG_64BIT | ||
24 | #define STACK_ALIGN 16 | ||
25 | #else | ||
26 | #define STACK_ALIGN 4 | ||
27 | #endif | ||
28 | |||
29 | #endif /* _CRYPTO_PADLOCK_H */ | ||
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 833d208c25d6..4fd95a323beb 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h | |||
@@ -68,6 +68,21 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) | |||
68 | return (++sg)->length ? sg : (void *)sg_page(sg); | 68 | return (++sg)->length ? sg : (void *)sg_page(sg); |
69 | } | 69 | } |
70 | 70 | ||
71 | static inline void scatterwalk_crypto_chain(struct scatterlist *head, | ||
72 | struct scatterlist *sg, | ||
73 | int chain, int num) | ||
74 | { | ||
75 | if (chain) { | ||
76 | head->length += sg->length; | ||
77 | sg = scatterwalk_sg_next(sg); | ||
78 | } | ||
79 | |||
80 | if (sg) | ||
81 | scatterwalk_sg_chain(head, num, sg); | ||
82 | else | ||
83 | sg_mark_end(head); | ||
84 | } | ||
85 | |||
71 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, | 86 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, |
72 | struct scatter_walk *walk_out) | 87 | struct scatter_walk *walk_out) |
73 | { | 88 | { |
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index d1580c17cab3..2296d8b1931f 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -158,6 +158,7 @@ header-y += icmpv6.h | |||
158 | header-y += if.h | 158 | header-y += if.h |
159 | header-y += if_addr.h | 159 | header-y += if_addr.h |
160 | header-y += if_addrlabel.h | 160 | header-y += if_addrlabel.h |
161 | header-y += if_alg.h | ||
161 | header-y += if_arcnet.h | 162 | header-y += if_arcnet.h |
162 | header-y += if_arp.h | 163 | header-y += if_arp.h |
163 | header-y += if_bonding.h | 164 | header-y += if_bonding.h |
diff --git a/include/linux/if_alg.h b/include/linux/if_alg.h new file mode 100644 index 000000000000..0f9acce5b1ff --- /dev/null +++ b/include/linux/if_alg.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * if_alg: User-space algorithm interface | ||
3 | * | ||
4 | * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _LINUX_IF_ALG_H | ||
14 | #define _LINUX_IF_ALG_H | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | struct sockaddr_alg { | ||
19 | __u16 salg_family; | ||
20 | __u8 salg_type[14]; | ||
21 | __u32 salg_feat; | ||
22 | __u32 salg_mask; | ||
23 | __u8 salg_name[64]; | ||
24 | }; | ||
25 | |||
26 | struct af_alg_iv { | ||
27 | __u32 ivlen; | ||
28 | __u8 iv[0]; | ||
29 | }; | ||
30 | |||
31 | /* Socket options */ | ||
32 | #define ALG_SET_KEY 1 | ||
33 | #define ALG_SET_IV 2 | ||
34 | #define ALG_SET_OP 3 | ||
35 | |||
36 | /* Operations */ | ||
37 | #define ALG_OP_DECRYPT 0 | ||
38 | #define ALG_OP_ENCRYPT 1 | ||
39 | |||
40 | #endif /* _LINUX_IF_ALG_H */ | ||
diff --git a/include/linux/socket.h b/include/linux/socket.h index 5f65f14c4f44..edbb1d07ddf4 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
@@ -191,7 +191,8 @@ struct ucred { | |||
191 | #define AF_PHONET 35 /* Phonet sockets */ | 191 | #define AF_PHONET 35 /* Phonet sockets */ |
192 | #define AF_IEEE802154 36 /* IEEE802154 sockets */ | 192 | #define AF_IEEE802154 36 /* IEEE802154 sockets */ |
193 | #define AF_CAIF 37 /* CAIF sockets */ | 193 | #define AF_CAIF 37 /* CAIF sockets */ |
194 | #define AF_MAX 38 /* For now.. */ | 194 | #define AF_ALG 38 /* Algorithm sockets */ |
195 | #define AF_MAX 39 /* For now.. */ | ||
195 | 196 | ||
196 | /* Protocol families, same as address families. */ | 197 | /* Protocol families, same as address families. */ |
197 | #define PF_UNSPEC AF_UNSPEC | 198 | #define PF_UNSPEC AF_UNSPEC |
@@ -232,6 +233,7 @@ struct ucred { | |||
232 | #define PF_PHONET AF_PHONET | 233 | #define PF_PHONET AF_PHONET |
233 | #define PF_IEEE802154 AF_IEEE802154 | 234 | #define PF_IEEE802154 AF_IEEE802154 |
234 | #define PF_CAIF AF_CAIF | 235 | #define PF_CAIF AF_CAIF |
236 | #define PF_ALG AF_ALG | ||
235 | #define PF_MAX AF_MAX | 237 | #define PF_MAX AF_MAX |
236 | 238 | ||
237 | /* Maximum queue length specifiable by listen. */ | 239 | /* Maximum queue length specifiable by listen. */ |
@@ -305,6 +307,7 @@ struct ucred { | |||
305 | #define SOL_RDS 276 | 307 | #define SOL_RDS 276 |
306 | #define SOL_IUCV 277 | 308 | #define SOL_IUCV 277 |
307 | #define SOL_CAIF 278 | 309 | #define SOL_CAIF 278 |
310 | #define SOL_ALG 279 | ||
308 | 311 | ||
309 | /* IPX options */ | 312 | /* IPX options */ |
310 | #define IPX_TYPE 1 | 313 | #define IPX_TYPE 1 |