net_help.h revision 1.1.1.4 1 1.1 christos /*
2 1.1 christos * util/net_help.h - network help functions
3 1.1 christos *
4 1.1 christos * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 1.1 christos *
6 1.1 christos * This software is open source.
7 1.1 christos *
8 1.1 christos * Redistribution and use in source and binary forms, with or without
9 1.1 christos * modification, are permitted provided that the following conditions
10 1.1 christos * are met:
11 1.1 christos *
12 1.1 christos * Redistributions of source code must retain the above copyright notice,
13 1.1 christos * this list of conditions and the following disclaimer.
14 1.1 christos *
15 1.1 christos * Redistributions in binary form must reproduce the above copyright notice,
16 1.1 christos * this list of conditions and the following disclaimer in the documentation
17 1.1 christos * and/or other materials provided with the distribution.
18 1.1 christos *
19 1.1 christos * Neither the name of the NLNET LABS nor the names of its contributors may
20 1.1 christos * be used to endorse or promote products derived from this software without
21 1.1 christos * specific prior written permission.
22 1.1 christos *
23 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 1.1 christos * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 1.1 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 1.1 christos * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 1.1 christos * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 1.1 christos * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 1.1 christos * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 1.1 christos * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 1.1 christos */
35 1.1 christos
36 1.1 christos /**
37 1.1 christos * \file
38 1.1 christos *
39 1.1 christos * This file contains functions to perform network related tasks.
40 1.1 christos */
41 1.1 christos
42 1.1 christos #ifndef NET_HELP_H
43 1.1 christos #define NET_HELP_H
44 1.1 christos #include "util/log.h"
45 1.1 christos struct sock_list;
46 1.1 christos struct regional;
47 1.1.1.4 christos struct config_strlist;
48 1.1 christos
49 1.1 christos /** DNS constants for uint16_t style flag manipulation. host byteorder.
50 1.1 christos * 1 1 1 1 1 1
51 1.1 christos * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
52 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
53 1.1 christos * |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
54 1.1 christos * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
55 1.1 christos */
56 1.1 christos /** CD flag */
57 1.1 christos #define BIT_CD 0x0010
58 1.1 christos /** AD flag */
59 1.1 christos #define BIT_AD 0x0020
60 1.1 christos /** Z flag */
61 1.1 christos #define BIT_Z 0x0040
62 1.1 christos /** RA flag */
63 1.1 christos #define BIT_RA 0x0080
64 1.1 christos /** RD flag */
65 1.1 christos #define BIT_RD 0x0100
66 1.1 christos /** TC flag */
67 1.1 christos #define BIT_TC 0x0200
68 1.1 christos /** AA flag */
69 1.1 christos #define BIT_AA 0x0400
70 1.1 christos /** QR flag */
71 1.1 christos #define BIT_QR 0x8000
72 1.1 christos /** get RCODE bits from uint16 flags */
73 1.1 christos #define FLAGS_GET_RCODE(f) ((f) & 0xf)
74 1.1 christos /** set RCODE bits in uint16 flags */
75 1.1 christos #define FLAGS_SET_RCODE(f, r) (f = (((f) & 0xfff0) | (r)))
76 1.1 christos
77 1.1.1.3 christos /** timeout in milliseconds for UDP queries to auth servers. */
78 1.1.1.3 christos #define UDP_AUTH_QUERY_TIMEOUT 3000
79 1.1.1.3 christos /** timeout in milliseconds for TCP queries to auth servers. */
80 1.1.1.3 christos #define TCP_AUTH_QUERY_TIMEOUT 3000
81 1.1 christos /** Advertised version of EDNS capabilities */
82 1.1 christos #define EDNS_ADVERTISED_VERSION 0
83 1.1 christos /** Advertised size of EDNS capabilities */
84 1.1 christos extern uint16_t EDNS_ADVERTISED_SIZE;
85 1.1 christos /** bits for EDNS bitfield */
86 1.1 christos #define EDNS_DO 0x8000 /* Dnssec Ok */
87 1.1 christos /** byte size of ip4 address */
88 1.1 christos #define INET_SIZE 4
89 1.1 christos /** byte size of ip6 address */
90 1.1 christos #define INET6_SIZE 16
91 1.1 christos
92 1.1 christos /** DNSKEY zone sign key flag */
93 1.1 christos #define DNSKEY_BIT_ZSK 0x0100
94 1.1 christos /** DNSKEY secure entry point, KSK flag */
95 1.1 christos #define DNSKEY_BIT_SEP 0x0001
96 1.1 christos
97 1.1 christos /** minimal responses when positive answer */
98 1.1 christos extern int MINIMAL_RESPONSES;
99 1.1 christos
100 1.1 christos /** rrset order roundrobin */
101 1.1 christos extern int RRSET_ROUNDROBIN;
102 1.1 christos
103 1.1.1.4 christos /** log tag queries with name instead of 'info' for filtering */
104 1.1.1.4 christos extern int LOG_TAG_QUERYREPLY;
105 1.1.1.4 christos
106 1.1 christos /**
107 1.1 christos * See if string is ip4 or ip6.
108 1.1 christos * @param str: IP specification.
109 1.1 christos * @return: true if string addr is an ip6 specced address.
110 1.1 christos */
111 1.1 christos int str_is_ip6(const char* str);
112 1.1 christos
113 1.1 christos /**
114 1.1 christos * Set fd nonblocking.
115 1.1 christos * @param s: file descriptor.
116 1.1 christos * @return: 0 on error (error is printed to log).
117 1.1 christos */
118 1.1 christos int fd_set_nonblock(int s);
119 1.1 christos
120 1.1 christos /**
121 1.1 christos * Set fd (back to) blocking.
122 1.1 christos * @param s: file descriptor.
123 1.1 christos * @return: 0 on error (error is printed to log).
124 1.1 christos */
125 1.1 christos int fd_set_block(int s);
126 1.1 christos
127 1.1 christos /**
128 1.1 christos * See if number is a power of 2.
129 1.1 christos * @param num: the value.
130 1.1 christos * @return: true if the number is a power of 2.
131 1.1 christos */
132 1.1 christos int is_pow2(size_t num);
133 1.1 christos
134 1.1 christos /**
135 1.1 christos * Allocate memory and copy over contents.
136 1.1 christos * @param data: what to copy over.
137 1.1 christos * @param len: length of data.
138 1.1 christos * @return: NULL on malloc failure, or newly malloced data.
139 1.1 christos */
140 1.1 christos void* memdup(void* data, size_t len);
141 1.1 christos
142 1.1 christos /**
143 1.1 christos * Prints the sockaddr in readable format with log_info. Debug helper.
144 1.1 christos * @param v: at what verbosity level to print this.
145 1.1 christos * @param str: descriptive string printed with it.
146 1.1 christos * @param addr: the sockaddr to print. Can be ip4 or ip6.
147 1.1 christos * @param addrlen: length of addr.
148 1.1 christos */
149 1.1 christos void log_addr(enum verbosity_value v, const char* str,
150 1.1 christos struct sockaddr_storage* addr, socklen_t addrlen);
151 1.1 christos
152 1.1 christos /**
153 1.1 christos * Prints zone name and sockaddr in readable format with log_info. Debug.
154 1.1 christos * @param v: at what verbosity level to print this.
155 1.1 christos * @param str: descriptive string printed with it.
156 1.1 christos * @param zone: DNS domain name, uncompressed wireformat.
157 1.1 christos * @param addr: the sockaddr to print. Can be ip4 or ip6.
158 1.1 christos * @param addrlen: length of addr.
159 1.1 christos */
160 1.1 christos void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone,
161 1.1 christos struct sockaddr_storage* addr, socklen_t addrlen);
162 1.1 christos
163 1.1 christos /**
164 1.1 christos * Log errno and addr.
165 1.1 christos * @param str: descriptive string printed with it.
166 1.1 christos * @param err: errno string to print, i.e. strerror(errno).
167 1.1 christos * @param addr: the sockaddr to print. Can be ip4 or ip6.
168 1.1 christos * @param addrlen: length of addr.
169 1.1 christos */
170 1.1 christos void log_err_addr(const char* str, const char* err,
171 1.1 christos struct sockaddr_storage* addr, socklen_t addrlen);
172 1.1 christos
173 1.1 christos /**
174 1.1 christos * Convert address string, with "@port" appendix, to sockaddr.
175 1.1 christos * Uses DNS port by default.
176 1.1 christos * @param str: the string
177 1.1 christos * @param addr: where to store sockaddr.
178 1.1 christos * @param addrlen: length of stored sockaddr is returned.
179 1.1 christos * @return 0 on error.
180 1.1 christos */
181 1.1 christos int extstrtoaddr(const char* str, struct sockaddr_storage* addr,
182 1.1 christos socklen_t* addrlen);
183 1.1 christos
184 1.1 christos /**
185 1.1 christos * Convert ip address string and port to sockaddr.
186 1.1 christos * @param ip: ip4 or ip6 address string.
187 1.1 christos * @param port: port number, host format.
188 1.1 christos * @param addr: where to store sockaddr.
189 1.1 christos * @param addrlen: length of stored sockaddr is returned.
190 1.1 christos * @return 0 on error.
191 1.1 christos */
192 1.1 christos int ipstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr,
193 1.1 christos socklen_t* addrlen);
194 1.1 christos
195 1.1 christos /**
196 1.1 christos * Convert ip netblock (ip/netsize) string and port to sockaddr.
197 1.1.1.3 christos * performs a copy internally to avoid writing over 'ip' string.
198 1.1 christos * @param ip: ip4 or ip6 address string.
199 1.1 christos * @param port: port number, host format.
200 1.1 christos * @param addr: where to store sockaddr.
201 1.1 christos * @param addrlen: length of stored sockaddr is returned.
202 1.1 christos * @param net: netblock size is returned.
203 1.1 christos * @return 0 on error.
204 1.1 christos */
205 1.1 christos int netblockstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr,
206 1.1 christos socklen_t* addrlen, int* net);
207 1.1 christos
208 1.1 christos /**
209 1.1.1.3 christos * Convert address string, with "@port" appendix, to sockaddr.
210 1.1.1.3 christos * It can also have an "#tls-auth-name" appendix (after the port).
211 1.1.1.3 christos * The returned tls-auth-name string is a pointer into the input string.
212 1.1.1.3 christos * Uses DNS port by default.
213 1.1.1.3 christos * @param str: the string
214 1.1.1.3 christos * @param addr: where to store sockaddr.
215 1.1.1.3 christos * @param addrlen: length of stored sockaddr is returned.
216 1.1.1.3 christos * @param auth_name: returned pointer to tls_auth_name, or NULL if none.
217 1.1.1.3 christos * @return 0 on error.
218 1.1.1.3 christos */
219 1.1.1.3 christos int authextstrtoaddr(char* str, struct sockaddr_storage* addr,
220 1.1.1.3 christos socklen_t* addrlen, char** auth_name);
221 1.1.1.3 christos
222 1.1.1.3 christos /**
223 1.1.1.3 christos * Store port number into sockaddr structure
224 1.1.1.3 christos * @param addr: sockaddr structure, ip4 or ip6.
225 1.1.1.3 christos * @param addrlen: length of addr.
226 1.1.1.3 christos * @param port: port number to put into the addr.
227 1.1.1.3 christos */
228 1.1.1.3 christos void sockaddr_store_port(struct sockaddr_storage* addr, socklen_t addrlen,
229 1.1.1.3 christos int port);
230 1.1.1.3 christos
231 1.1.1.3 christos /**
232 1.1 christos * Print string with neat domain name, type and class.
233 1.1 christos * @param v: at what verbosity level to print this.
234 1.1 christos * @param str: string of message.
235 1.1 christos * @param name: domain name uncompressed wireformat.
236 1.1 christos * @param type: host format RR type.
237 1.1 christos * @param dclass: host format RR class.
238 1.1 christos */
239 1.1 christos void log_nametypeclass(enum verbosity_value v, const char* str,
240 1.1 christos uint8_t* name, uint16_t type, uint16_t dclass);
241 1.1 christos
242 1.1 christos /**
243 1.1.1.4 christos * Like log_nametypeclass, but logs with log_query for query logging
244 1.1.1.4 christos */
245 1.1.1.4 christos void log_query_in(const char* str, uint8_t* name, uint16_t type,
246 1.1.1.4 christos uint16_t dclass);
247 1.1.1.4 christos
248 1.1.1.4 christos /**
249 1.1 christos * Compare two sockaddrs. Imposes an ordering on the addresses.
250 1.1 christos * Compares address and port.
251 1.1 christos * @param addr1: address 1.
252 1.1 christos * @param len1: lengths of addr1.
253 1.1 christos * @param addr2: address 2.
254 1.1 christos * @param len2: lengths of addr2.
255 1.1 christos * @return: 0 if addr1 == addr2. -1 if addr1 is smaller, +1 if larger.
256 1.1 christos */
257 1.1 christos int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1,
258 1.1 christos struct sockaddr_storage* addr2, socklen_t len2);
259 1.1 christos
260 1.1 christos /**
261 1.1 christos * Compare two sockaddrs. Compares address, not the port.
262 1.1 christos * @param addr1: address 1.
263 1.1 christos * @param len1: lengths of addr1.
264 1.1 christos * @param addr2: address 2.
265 1.1 christos * @param len2: lengths of addr2.
266 1.1 christos * @return: 0 if addr1 == addr2. -1 if addr1 is smaller, +1 if larger.
267 1.1 christos */
268 1.1 christos int sockaddr_cmp_addr(struct sockaddr_storage* addr1, socklen_t len1,
269 1.1 christos struct sockaddr_storage* addr2, socklen_t len2);
270 1.1 christos
271 1.1 christos /**
272 1.1 christos * Checkout address family.
273 1.1 christos * @param addr: the sockaddr to examine.
274 1.1 christos * @param len: the length of addr.
275 1.1 christos * @return: true if sockaddr is ip6.
276 1.1 christos */
277 1.1 christos int addr_is_ip6(struct sockaddr_storage* addr, socklen_t len);
278 1.1 christos
279 1.1 christos /**
280 1.1 christos * Make sure the sockaddr ends in zeroes. For tree insertion and subsequent
281 1.1 christos * comparison.
282 1.1 christos * @param addr: the ip4 or ip6 addr.
283 1.1 christos * @param len: length of addr.
284 1.1 christos * @param net: number of bits to leave untouched, the rest of the netblock
285 1.1 christos * address is zeroed.
286 1.1 christos */
287 1.1 christos void addr_mask(struct sockaddr_storage* addr, socklen_t len, int net);
288 1.1 christos
289 1.1 christos /**
290 1.1 christos * See how many bits are shared, equal, between two addrs.
291 1.1 christos * @param addr1: first addr.
292 1.1 christos * @param net1: netblock size of first addr.
293 1.1 christos * @param addr2: second addr.
294 1.1 christos * @param net2: netblock size of second addr.
295 1.1 christos * @param addrlen: length of first addr and of second addr.
296 1.1 christos * They must be of the same length (i.e. same type IP4, IP6).
297 1.1 christos * @return: number of bits the same.
298 1.1 christos */
299 1.1 christos int addr_in_common(struct sockaddr_storage* addr1, int net1,
300 1.1 christos struct sockaddr_storage* addr2, int net2, socklen_t addrlen);
301 1.1 christos
302 1.1 christos /**
303 1.1 christos * Put address into string, works for IPv4 and IPv6.
304 1.1 christos * @param addr: address
305 1.1 christos * @param addrlen: length of address
306 1.1 christos * @param buf: result string stored here
307 1.1 christos * @param len: length of buf.
308 1.1 christos * On failure a string with "error" is stored inside.
309 1.1 christos */
310 1.1 christos void addr_to_str(struct sockaddr_storage* addr, socklen_t addrlen,
311 1.1 christos char* buf, size_t len);
312 1.1 christos
313 1.1 christos /**
314 1.1 christos * See if sockaddr is an ipv6 mapped ipv4 address, "::ffff:0.0.0.0"
315 1.1 christos * @param addr: address
316 1.1 christos * @param addrlen: length of address
317 1.1 christos * @return true if so
318 1.1 christos */
319 1.1 christos int addr_is_ip4mapped(struct sockaddr_storage* addr, socklen_t addrlen);
320 1.1 christos
321 1.1 christos /**
322 1.1 christos * See if sockaddr is 255.255.255.255.
323 1.1 christos * @param addr: address
324 1.1 christos * @param addrlen: length of address
325 1.1 christos * @return true if so
326 1.1 christos */
327 1.1 christos int addr_is_broadcast(struct sockaddr_storage* addr, socklen_t addrlen);
328 1.1 christos
329 1.1 christos /**
330 1.1 christos * See if sockaddr is 0.0.0.0 or ::0.
331 1.1 christos * @param addr: address
332 1.1 christos * @param addrlen: length of address
333 1.1 christos * @return true if so
334 1.1 christos */
335 1.1 christos int addr_is_any(struct sockaddr_storage* addr, socklen_t addrlen);
336 1.1 christos
337 1.1 christos /**
338 1.1 christos * Insert new socket list item. If fails logs error.
339 1.1 christos * @param list: pointer to pointer to first item.
340 1.1 christos * @param addr: address or NULL if 'cache'.
341 1.1 christos * @param len: length of addr, or 0 if 'cache'.
342 1.1 christos * @param region: where to allocate
343 1.1 christos */
344 1.1 christos void sock_list_insert(struct sock_list** list, struct sockaddr_storage* addr,
345 1.1 christos socklen_t len, struct regional* region);
346 1.1 christos
347 1.1 christos /**
348 1.1 christos * Append one list to another. Must both be from same qstate(regional).
349 1.1 christos * @param list: pointer to result list that is modified.
350 1.1 christos * @param add: item(s) to add. They are prepended to list.
351 1.1 christos */
352 1.1 christos void sock_list_prepend(struct sock_list** list, struct sock_list* add);
353 1.1 christos
354 1.1 christos /**
355 1.1 christos * Find addr in list.
356 1.1 christos * @param list: to search in
357 1.1 christos * @param addr: address to look for.
358 1.1 christos * @param len: length. Can be 0, look for 'cache entry'.
359 1.1 christos * @return true if found.
360 1.1 christos */
361 1.1 christos int sock_list_find(struct sock_list* list, struct sockaddr_storage* addr,
362 1.1 christos socklen_t len);
363 1.1 christos
364 1.1 christos /**
365 1.1 christos * Merge socklist into another socket list. Allocates the new entries
366 1.1 christos * freshly and copies them over, so also performs a region switchover.
367 1.1 christos * Allocation failures are logged.
368 1.1 christos * @param list: the destination list (checked for duplicates)
369 1.1 christos * @param region: where to allocate
370 1.1 christos * @param add: the list of entries to add.
371 1.1 christos */
372 1.1 christos void sock_list_merge(struct sock_list** list, struct regional* region,
373 1.1 christos struct sock_list* add);
374 1.1 christos
375 1.1 christos /**
376 1.1 christos * Log libcrypto error with descriptive string. Calls log_err().
377 1.1 christos * @param str: what failed.
378 1.1 christos */
379 1.1 christos void log_crypto_err(const char* str);
380 1.1 christos
381 1.1.1.2 christos /**
382 1.1.1.2 christos * Set SSL_OP_NOxxx options on SSL context to disable bad crypto
383 1.1.1.2 christos * @param ctxt: SSL_CTX*
384 1.1.1.2 christos * @return false on failure.
385 1.1.1.2 christos */
386 1.1.1.2 christos int listen_sslctx_setup(void* ctxt);
387 1.1.1.2 christos
388 1.1.1.2 christos /**
389 1.1.1.2 christos * Further setup of listening SSL context, after keys loaded.
390 1.1.1.2 christos * @param ctxt: SSL_CTX*
391 1.1.1.2 christos */
392 1.1.1.2 christos void listen_sslctx_setup_2(void* ctxt);
393 1.1.1.2 christos
394 1.1 christos /**
395 1.1 christos * create SSL listen context
396 1.1 christos * @param key: private key file.
397 1.1 christos * @param pem: public key cert.
398 1.1 christos * @param verifypem: if nonNULL, verifylocation file.
399 1.1 christos * return SSL_CTX* or NULL on failure (logged).
400 1.1 christos */
401 1.1 christos void* listen_sslctx_create(char* key, char* pem, char* verifypem);
402 1.1 christos
403 1.1 christos /**
404 1.1 christos * create SSL connect context
405 1.1 christos * @param key: if nonNULL (also pem nonNULL), the client private key.
406 1.1 christos * @param pem: client public key (or NULL if key is NULL).
407 1.1 christos * @param verifypem: if nonNULL used for verifylocation file.
408 1.1.1.3 christos * @param wincert: add system certificate store to ctx (add to verifypem ca
409 1.1.1.3 christos * certs).
410 1.1 christos * @return SSL_CTX* or NULL on failure (logged).
411 1.1 christos */
412 1.1.1.3 christos void* connect_sslctx_create(char* key, char* pem, char* verifypem, int wincert);
413 1.1 christos
414 1.1 christos /**
415 1.1 christos * accept a new fd and wrap it in a BIO in SSL
416 1.1 christos * @param sslctx: the SSL_CTX to use (from listen_sslctx_create()).
417 1.1 christos * @param fd: from accept, nonblocking.
418 1.1 christos * @return SSL or NULL on alloc failure.
419 1.1 christos */
420 1.1 christos void* incoming_ssl_fd(void* sslctx, int fd);
421 1.1 christos
422 1.1 christos /**
423 1.1 christos * connect a new fd and wrap it in a BIO in SSL
424 1.1 christos * @param sslctx: the SSL_CTX to use (from connect_sslctx_create())
425 1.1 christos * @param fd: from connect.
426 1.1 christos * @return SSL or NULL on alloc failure
427 1.1 christos */
428 1.1 christos void* outgoing_ssl_fd(void* sslctx, int fd);
429 1.1 christos
430 1.1 christos /**
431 1.1 christos * Initialize openssl locking for thread safety
432 1.1 christos * @return false on failure (alloc failure).
433 1.1 christos */
434 1.1 christos int ub_openssl_lock_init(void);
435 1.1 christos
436 1.1 christos /**
437 1.1 christos * De-init the allocated openssl locks
438 1.1 christos */
439 1.1 christos void ub_openssl_lock_delete(void);
440 1.1 christos
441 1.1.1.4 christos /**
442 1.1.1.4 christos * setup TLS session ticket
443 1.1.1.4 christos * @param sslctx: the SSL_CTX to use (from connect_sslctx_create())
444 1.1.1.4 christos * @param tls_session_ticket_keys: TLS ticket secret filenames
445 1.1.1.4 christos * @return false on failure (alloc failure).
446 1.1.1.4 christos */
447 1.1.1.4 christos int listen_sslctx_setup_ticket_keys(void* sslctx,
448 1.1.1.4 christos struct config_strlist* tls_session_ticket_keys);
449 1.1.1.4 christos
450 1.1.1.4 christos /**
451 1.1.1.4 christos * callback TLS session ticket encrypt and decrypt
452 1.1.1.4 christos * For use with SSL_CTX_set_tlsext_ticket_key_cb
453 1.1.1.4 christos * @param s: the SSL_CTX to use (from connect_sslctx_create())
454 1.1.1.4 christos * @param key_name: secret name, 16 bytes
455 1.1.1.4 christos * @param iv: up to EVP_MAX_IV_LENGTH.
456 1.1.1.4 christos * @param evp_ctx: the evp cipher context, function sets this.
457 1.1.1.4 christos * @param hmac_ctx: the hmax context, function sets this.
458 1.1.1.4 christos * @param enc: 1 is encrypt, 0 is decrypt
459 1.1.1.4 christos * @return 0 on no ticket, 1 for okay, and 2 for okay but renew the ticket
460 1.1.1.4 christos * (the ticket is decrypt only). and <0 for failures.
461 1.1.1.4 christos */
462 1.1.1.4 christos int tls_session_ticket_key_cb(void *s, unsigned char* key_name,unsigned char* iv, void *evp_ctx, void *hmac_ctx, int enc);
463 1.1.1.4 christos
464 1.1.1.4 christos /** Free memory used for TLS session ticket keys */
465 1.1.1.4 christos void listen_sslctx_delete_ticket_keys(void);
466 1.1.1.4 christos
467 1.1 christos #endif /* NET_HELP_H */
468