xref: /openbsd/sbin/iked/types.h (revision f36db9c4)
1 /*	$OpenBSD: types.h,v 1.55 2024/07/13 12:22:46 yasuoka Exp $	*/
2 
3 /*
4  * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
5  * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef IKED_TYPES_H
21 #define IKED_TYPES_H
22 
23 #ifndef IKED_USER
24 #define IKED_USER		"_iked"
25 #endif
26 
27 #ifndef IKED_CONFIG
28 #define IKED_CONFIG		"/etc/iked.conf"
29 #endif
30 
31 #define IKED_SOCKET		"/var/run/iked.sock"
32 
33 #ifndef IKED_CA
34 #define IKED_CA			"/etc/iked/"
35 #endif
36 
37 #define IKED_CA_DIR		"ca/"
38 #define IKED_CRL_DIR		"crls/"
39 #define IKED_CERT_DIR		"certs/"
40 #define IKED_PUBKEY_DIR		"pubkeys/"
41 #define IKED_PRIVKEY		IKED_CA "private/local.key"
42 #define IKED_PUBKEY		"local.pub"
43 
44 #define IKED_VENDOR_ID		"OpenIKED-"
45 #define IKED_NAS_ID		"OpenIKED"
46 
47 #define IKED_OCSP_RESPCERT	"ocsp/responder.crt"
48 
49 #define IKED_OPT_VERBOSE	0x00000001
50 #define IKED_OPT_NOACTION	0x00000002
51 #define IKED_OPT_PASSIVE	0x00000004
52 
53 #define IKED_IKE_PORT		500
54 #define IKED_NATT_PORT		4500
55 
56 #define IKED_NONCE_MIN		16	/* XXX 128 bits */
57 #define IKED_NONCE_SIZE		32	/* XXX 256 bits */
58 
59 #define IKED_COOKIE_MIN		1	/* min 1 bytes */
60 #define IKED_COOKIE_MAX		64	/* max 64 bytes */
61 
62 #define IKED_COOKIE2_MIN	8	/* min 8 bytes */
63 #define IKED_COOKIE2_MAX	64	/* max 64 bytes */
64 
65 #define IKED_ID_SIZE		1024	/* XXX should be dynamic */
66 #define IKED_PSK_SIZE		1024	/* XXX should be dynamic */
67 #define IKED_MSGBUF_MAX		8192
68 #define IKED_CFG_MAX		16	/* maximum CP attributes */
69 #define IKED_IPPROTO_MAX	16
70 #define IKED_TAG_SIZE		64
71 #define IKED_CYCLE_BUFFERS	8	/* # of static buffers for mapping */
72 #define IKED_PASSWORD_SIZE	256	/* limited by most EAP types */
73 
74 #define IKED_LIFETIME_BYTES	4294967296ULL	/* 4 GB */
75 #define IKED_LIFETIME_SECONDS	10800	  	/* 3 hours */
76 
77 #define IKED_E			0x1000	/* Decrypted flag */
78 
79 struct iked_constmap {
80 	unsigned int	 cm_type;
81 	const char	*cm_name;
82 	const char	*cm_descr;
83 };
84 
85 struct iked_transform {
86 	uint8_t				 xform_type;
87 	uint16_t			 xform_id;
88 	uint16_t			 xform_length;
89 	uint16_t			 xform_keylength;
90 	unsigned int			 xform_score;
91 	struct iked_constmap		*xform_map;
92 };
93 
94 enum imsg_type {
95 	IMSG_NONE,
96 	IMSG_CTL_OK,
97 	IMSG_CTL_FAIL,
98 	IMSG_CTL_VERBOSE,
99 	IMSG_CTL_NOTIFY,
100 	IMSG_CTL_RELOAD,
101 	IMSG_CTL_RESET,
102 	IMSG_CTL_COUPLE,
103 	IMSG_CTL_DECOUPLE,
104 	IMSG_CTL_ACTIVE,
105 	IMSG_CTL_PASSIVE,
106 	IMSG_CTL_RESET_ID,
107 	IMSG_CTL_SHOW_SA,
108 	IMSG_CTL_STATIC,
109 	IMSG_COMPILE,
110 	IMSG_UDP_SOCKET,
111 	IMSG_PFKEY_SOCKET,
112 	IMSG_IKE_MESSAGE,
113 	IMSG_CFG_POLICY,
114 	IMSG_CFG_FLOW,
115 	IMSG_CFG_USER,
116 	IMSG_CFG_RADAUTH,
117 	IMSG_CFG_RADACCT,
118 	IMSG_CFG_RADSERVER,
119 	IMSG_CFG_RADCFGMAP,
120 	IMSG_CFG_RADDAE,
121 	IMSG_CFG_RADDAECLIENT,
122 	IMSG_CERTREQ,
123 	IMSG_CERT,
124 	IMSG_CERTVALID,
125 	IMSG_CERTINVALID,
126 	IMSG_SCERT,
127 	IMSG_IF_ADDADDR,
128 	IMSG_IF_DELADDR,
129 	IMSG_VROUTE_ADD,
130 	IMSG_VROUTE_DEL,
131 	IMSG_VROUTE_CLONE,
132 	IMSG_VDNS_ADD,
133 	IMSG_VDNS_DEL,
134 	IMSG_OCSP_FD,
135 	IMSG_OCSP_CFG,
136 	IMSG_AUTH,
137 	IMSG_PRIVKEY,
138 	IMSG_PUBKEY,
139 	IMSG_CTL_SHOW_CERTSTORE,
140 	IMSG_CTL_SHOW_STATS,
141 	IMSG_CTL_PROCFD,
142 	IMSG_CTL_PROCREADY,
143 };
144 
145 enum privsep_procid {
146 	PROC_PARENT = 0,
147 	PROC_CONTROL,
148 	PROC_CERT,
149 	PROC_IKEV2,
150 	PROC_MAX
151 };
152 
153 enum flushmode {
154 	RESET_RELOAD	= 0,
155 	RESET_ALL,
156 	RESET_CA,
157 	RESET_POLICY,
158 	RESET_SA,
159 	RESET_USER,
160 	RESET_RADIUS,
161 };
162 
163 #ifndef nitems
164 #define nitems(_a)   (sizeof((_a)) / sizeof((_a)[0]))
165 #endif
166 
167 #endif /* IKED_TYPES_H */
168