removing svn keyword $Id$ from all files
[strongswan.git] / src / libfreeswan / ipsec_policy.h
1 #ifndef _IPSEC_POLICY_H
2 /*
3 * policy interface file between pluto and applications
4 * Copyright (C) 2003 Michael Richardson <mcr@freeswan.org>
5 *
6 * This library is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Library General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 * License for more details.
15 */
16 #define _IPSEC_POLICY_H /* seen it, no need to see it again */
17
18
19 /*
20 * this file defines an interface between an application (or rather an
21 * application library) and a key/policy daemon. It provides for inquiries
22 * as to the current state of a connected socket, as well as for general
23 * questions.
24 *
25 * In general, the interface is defined as a series of functional interfaces,
26 * and the policy messages should be internal. However, because this is in
27 * fact an ABI between pieces of the system that may get compiled and revised
28 * seperately, this ABI must be public and revision controlled.
29 *
30 * It is expected that the daemon will always support previous versions.
31 */
32
33 #define IPSEC_POLICY_MSG_REVISION (unsigned)200305061
34
35 enum ipsec_policy_command {
36 IPSEC_CMD_QUERY_FD = 1,
37 IPSEC_CMD_QUERY_HOSTPAIR = 2,
38 IPSEC_CMD_QUERY_DSTONLY = 3,
39 };
40
41 struct ipsec_policy_msg_head {
42 u_int32_t ipm_version;
43 u_int32_t ipm_msg_len;
44 u_int32_t ipm_msg_type;
45 u_int32_t ipm_msg_seq;
46 };
47
48 enum ipsec_privacy_quality {
49 IPSEC_PRIVACY_NONE = 0,
50 IPSEC_PRIVACY_INTEGRAL = 4, /* not private at all. AH-like */
51 IPSEC_PRIVACY_UNKNOWN = 8, /* something is claimed, but details unavail */
52 IPSEC_PRIVACY_ROT13 = 12, /* trivially breakable, i.e. 1DES */
53 IPSEC_PRIVACY_GAK = 16, /* known eavesdroppers */
54 IPSEC_PRIVACY_PRIVATE = 32, /* secure for at least a decade */
55 IPSEC_PRIVACY_STRONG = 64, /* ridiculously secure */
56 IPSEC_PRIVACY_TORTOISE = 192, /* even stronger, but very slow */
57 IPSEC_PRIVACY_OTP = 224, /* some kind of *true* one time pad */
58 };
59
60 enum ipsec_bandwidth_quality {
61 IPSEC_QOS_UNKNOWN = 0, /* unknown bandwidth */
62 IPSEC_QOS_INTERACTIVE = 16, /* reasonably moderate jitter, moderate fast.
63 Good enough for telnet/ssh. */
64 IPSEC_QOS_VOIP = 32, /* faster crypto, predicable jitter */
65 IPSEC_QOS_FTP = 64, /* higher throughput crypto, perhaps hardware
66 offloaded, but latency/jitter may be bad */
67 IPSEC_QOS_WIRESPEED = 128, /* expect to be able to fill your pipe */
68 };
69
70 /* moved from programs/pluto/constants.h */
71 /* IPsec AH transform values
72 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.3
73 * and in http://www.iana.org/assignments/isakmp-registry
74 */
75 enum ipsec_authentication_algo {
76 AH_NONE = 0,
77 AH_MD5 = 2,
78 AH_SHA = 3,
79 AH_DES = 4,
80 AH_SHA2_256 = 5,
81 AH_SHA2_384 = 6,
82 AH_SHA2_512 = 7,
83 AH_RIPEMD = 8,
84 AH_AES_XCBC_MAC = 9,
85 AH_RSA = 10
86 };
87
88 /* IPsec ESP transform values
89 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.4
90 * and from http://www.iana.org/assignments/isakmp-registry
91 */
92
93 enum ipsec_cipher_algo {
94 ESP_NONE = 0,
95 ESP_DES_IV64 = 1,
96 ESP_DES = 2,
97 ESP_3DES = 3,
98 ESP_RC5 = 4,
99 ESP_IDEA = 5,
100 ESP_CAST = 6,
101 ESP_BLOWFISH = 7,
102 ESP_3IDEA = 8,
103 ESP_DES_IV32 = 9,
104 ESP_RC4 = 10,
105 ESP_NULL = 11,
106 ESP_AES = 12,
107 ESP_AES_CTR = 13,
108 ESP_AES_CCM_8 = 14,
109 ESP_AES_CCM_12 = 15,
110 ESP_AES_CCM_16 = 16,
111 ESP_UNASSIGNED_17 = 17,
112 ESP_AES_GCM_8 = 18,
113 ESP_AES_GCM_12 = 19,
114 ESP_AES_GCM_16 = 20,
115 ESP_SEED_CBC = 21,
116 ESP_CAMELLIA = 22,
117 ESP_SERPENT = 252,
118 ESP_TWOFISH = 253
119 };
120
121 /* IPCOMP transform values
122 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.5
123 */
124
125 enum ipsec_comp_algo {
126 IPSCOMP_NONE = 0,
127 IPCOMP_OUI = 1,
128 IPCOMP_DEFLATE = 2,
129 IPCOMP_LZS = 3,
130 IPCOMP_LZJH = 4
131 };
132
133 /* Identification type values
134 * RFC 2407 The Internet IP security Domain of Interpretation for ISAKMP 4.6.2.1
135 */
136
137 enum ipsec_id_type {
138 ID_IMPOSSIBLE= (-2), /* private to Pluto */
139 ID_MYID= (-1), /* private to Pluto */
140 ID_NONE= 0, /* private to Pluto */
141 ID_IPV4_ADDR= 1,
142 ID_FQDN= 2,
143 ID_USER_FQDN= 3,
144 ID_IPV4_ADDR_SUBNET= 4,
145 ID_IPV6_ADDR= 5,
146 ID_IPV6_ADDR_SUBNET= 6,
147 ID_IPV4_ADDR_RANGE= 7,
148 ID_IPV6_ADDR_RANGE= 8,
149 ID_DER_ASN1_DN= 9,
150 ID_DER_ASN1_GN= 10,
151 ID_KEY_ID= 11
152 };
153
154 /* Certificate type values
155 * RFC 2408 ISAKMP, chapter 3.9
156 */
157 enum ipsec_cert_type {
158 CERT_NONE= 0,
159 CERT_PKCS7_WRAPPED_X509= 1,
160 CERT_PGP= 2,
161 CERT_DNS_SIGNED_KEY= 3,
162 CERT_X509_SIGNATURE= 4,
163 CERT_X509_KEY_EXCHANGE= 5,
164 CERT_KERBEROS_TOKENS= 6,
165 CERT_CRL= 7,
166 CERT_ARL= 8,
167 CERT_SPKI= 9,
168 CERT_X509_ATTRIBUTE= 10,
169 CERT_RAW_RSA_KEY= 11
170 };
171
172 /* a SIG record in ASCII */
173 struct ipsec_dns_sig {
174 char fqdn[256];
175 char dns_sig[768]; /* empty string if not signed */
176 };
177
178 struct ipsec_raw_key {
179 char id_name[256];
180 char fs_keyid[8];
181 };
182
183 struct ipsec_identity {
184 enum ipsec_id_type ii_type;
185 enum ipsec_cert_type ii_format;
186 union {
187 struct ipsec_dns_sig ipsec_dns_signed;
188 /* some thing for PGP */
189 /* some thing for PKIX */
190 struct ipsec_raw_key ipsec_raw_key;
191 } ii_credential;
192 };
193
194 #define IPSEC_MAX_CREDENTIALS 32
195
196 struct ipsec_policy_cmd_query {
197 struct ipsec_policy_msg_head head;
198
199 /* Query section */
200 ip_address query_local; /* us */
201 ip_address query_remote; /* them */
202 u_short src_port, dst_port;
203
204 /* Answer section */
205 enum ipsec_privacy_quality strength;
206 enum ipsec_bandwidth_quality bandwidth;
207 enum ipsec_authentication_algo auth_detail;
208 enum ipsec_cipher_algo esp_detail;
209 enum ipsec_comp_algo comp_detail;
210
211 int credential_count;
212
213 struct ipsec_identity credentials[IPSEC_MAX_CREDENTIALS];
214 };
215
216 #define IPSEC_POLICY_SOCKET "/var/run/pluto.info"
217
218 /* prototypes */
219 extern err_t ipsec_policy_lookup(int fd, struct ipsec_policy_cmd_query *result);
220 extern err_t ipsec_policy_init(void);
221 extern err_t ipsec_policy_final(void);
222 extern err_t ipsec_policy_readmsg(int policysock,
223 unsigned char *buf, size_t buflen);
224 extern err_t ipsec_policy_sendrecv(unsigned char *buf, size_t buflen);
225 extern err_t ipsec_policy_cgilookup(struct ipsec_policy_cmd_query *result);
226
227
228 extern const char *ipsec_policy_version_code(void);
229 extern const char *ipsec_policy_version_string(void);
230
231 #endif /* _IPSEC_POLICY_H */