1 /* $NetBSD: ipsec_doi.h,v 1.14 2012/11/29 15:31:25 vanhu Exp $ */ 2 3 /* Id: ipsec_doi.h,v 1.15 2006/08/11 16:06:30 vanhu Exp */ 4 5 /* 6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the project nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef _IPSEC_DOI_H 35 #define _IPSEC_DOI_H 36 37 #include "isakmp.h" 38 39 /* refered to RFC2407 */ 40 41 #define IPSEC_DOI 1 42 43 /* 4.2 IPSEC Situation Definition */ 44 #define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001 45 #define IPSECDOI_SIT_SECRECY 0x00000002 46 #define IPSECDOI_SIT_INTEGRITY 0x00000004 47 48 /* 4.4.1 IPSEC Security Protocol Identifiers */ 49 /* 4.4.2 IPSEC ISAKMP Transform Values */ 50 #define IPSECDOI_PROTO_ISAKMP 1 51 #define IPSECDOI_KEY_IKE 1 52 53 /* 4.4.1 IPSEC Security Protocol Identifiers */ 54 #define IPSECDOI_PROTO_IPSEC_AH 2 55 /* 4.4.3 IPSEC AH Transform Values */ 56 #define IPSECDOI_AH_MD5 2 57 #define IPSECDOI_AH_SHA 3 58 #define IPSECDOI_AH_DES 4 59 #define IPSECDOI_AH_SHA256 5 60 #define IPSECDOI_AH_SHA384 6 61 #define IPSECDOI_AH_SHA512 7 62 63 /* 4.4.1 IPSEC Security Protocol Identifiers */ 64 #define IPSECDOI_PROTO_IPSEC_ESP 3 65 /* 4.4.4 IPSEC ESP Transform Identifiers */ 66 #define IPSECDOI_ESP_DES_IV64 1 67 #define IPSECDOI_ESP_DES 2 68 #define IPSECDOI_ESP_3DES 3 69 #define IPSECDOI_ESP_RC5 4 70 #define IPSECDOI_ESP_IDEA 5 71 #define IPSECDOI_ESP_CAST 6 72 #define IPSECDOI_ESP_BLOWFISH 7 73 #define IPSECDOI_ESP_3IDEA 8 74 #define IPSECDOI_ESP_DES_IV32 9 75 #define IPSECDOI_ESP_RC4 10 76 #define IPSECDOI_ESP_NULL 11 77 #define IPSECDOI_ESP_AES 12 78 #define IPSECDOI_ESP_AESGCM16 20 79 #define IPSECDOI_ESP_CAMELLIA 22 80 #if 1 81 /* draft-ietf-ipsec-ciph-aes-cbc-00.txt */ 82 #define IPSECDOI_ESP_TWOFISH 253 83 #else 84 /* SSH uses these value for now */ 85 #define IPSECDOI_ESP_TWOFISH 250 86 #endif 87 88 /* 4.4.1 IPSEC Security Protocol Identifiers */ 89 #define IPSECDOI_PROTO_IPCOMP 4 90 /* 4.4.5 IPSEC IPCOMP Transform Identifiers */ 91 #define IPSECDOI_IPCOMP_OUI 1 92 #define IPSECDOI_IPCOMP_DEFLATE 2 93 #define IPSECDOI_IPCOMP_LZS 3 94 95 /* 4.5 IPSEC Security Association Attributes */ 96 /* NOTE: default value is not included in a packet. */ 97 #define IPSECDOI_ATTR_SA_LD_TYPE 1 /* B */ 98 #define IPSECDOI_ATTR_SA_LD_TYPE_DEFAULT 1 99 #define IPSECDOI_ATTR_SA_LD_TYPE_SEC 1 100 #define IPSECDOI_ATTR_SA_LD_TYPE_KB 2 101 #define IPSECDOI_ATTR_SA_LD_TYPE_MAX 3 102 #define IPSECDOI_ATTR_SA_LD 2 /* V */ 103 #define IPSECDOI_ATTR_SA_LD_SEC_DEFAULT 28800 /* 8 hours */ 104 #define IPSECDOI_ATTR_SA_LD_KB_MAX (~(1 << ((sizeof(int) << 3) - 1))) 105 #define IPSECDOI_ATTR_GRP_DESC 3 /* B */ 106 #define IPSECDOI_ATTR_ENC_MODE 4 /* B */ 107 /* default value: host dependent */ 108 #define IPSECDOI_ATTR_ENC_MODE_ANY 0 /* NOTE:internal use */ 109 #define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1 110 #define IPSECDOI_ATTR_ENC_MODE_TRNS 2 111 112 /* NAT-T draft-ietf-ipsec-nat-t-ike-05 and later */ 113 #define IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC 3 114 #define IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC 4 115 116 /* NAT-T up to draft-ietf-ipsec-nat-t-ike-04 */ 117 #define IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT 61443 118 #define IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT 61444 119 120 #define IPSECDOI_ATTR_AUTH 5 /* B */ 121 /* 0 means not to use authentication. */ 122 #define IPSECDOI_ATTR_AUTH_HMAC_MD5 1 123 #define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2 124 #define IPSECDOI_ATTR_AUTH_DES_MAC 3 125 #define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/ 126 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_256 5 127 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_384 6 128 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_512 7 129 #define IPSECDOI_ATTR_AUTH_NONE 254 /* NOTE:internal use */ 130 /* 131 * When negotiating ESP without authentication, the Auth 132 * Algorithm attribute MUST NOT be included in the proposal. 133 * When negotiating ESP without confidentiality, the Auth 134 * Algorithm attribute MUST be included in the proposal and 135 * the ESP transform ID must be ESP_NULL. 136 */ 137 #define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */ 138 #define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */ 139 #define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */ 140 #define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */ 141 142 #ifdef HAVE_SECCTX 143 #define IPSECDOI_ATTR_SECCTX 10 /* V */ 144 #endif 145 146 /* 4.6.1 Security Association Payload */ 147 struct ipsecdoi_pl_sa { 148 struct isakmp_gen h; 149 struct ipsecdoi_sa_b { 150 u_int32_t doi; /* Domain of Interpretation */ 151 u_int32_t sit; /* Situation */ 152 } b; 153 /* followed by Leveled Domain Identifier and so on. */ 154 } __attribute__((__packed__)); 155 156 struct ipsecdoi_secrecy_h { 157 u_int16_t len; 158 u_int16_t reserved; 159 /* followed by the value */ 160 } __attribute__((__packed__)); 161 162 /* 4.6.2 Identification Payload Content */ 163 struct ipsecdoi_pl_id { 164 struct isakmp_gen h; 165 struct ipsecdoi_id_b { 166 u_int8_t type; /* ID Type */ 167 u_int8_t proto_id; /* Protocol ID */ 168 u_int16_t port; /* Port */ 169 } b; 170 /* followed by Identification Data */ 171 } __attribute__((__packed__)); 172 173 #define IPSECDOI_ID_IPV4_ADDR 1 174 #define IPSECDOI_ID_FQDN 2 175 #define IPSECDOI_ID_USER_FQDN 3 176 #define IPSECDOI_ID_IPV4_ADDR_SUBNET 4 177 #define IPSECDOI_ID_IPV6_ADDR 5 178 #define IPSECDOI_ID_IPV6_ADDR_SUBNET 6 179 #define IPSECDOI_ID_IPV4_ADDR_RANGE 7 180 #define IPSECDOI_ID_IPV6_ADDR_RANGE 8 181 #define IPSECDOI_ID_DER_ASN1_DN 9 182 #define IPSECDOI_ID_DER_ASN1_GN 10 183 #define IPSECDOI_ID_KEY_ID 11 184 185 /* compressing doi type, it's internal use. */ 186 #define IDTYPE_UNDEFINED 0 187 #define IDTYPE_FQDN 1 188 #define IDTYPE_USERFQDN 2 189 #define IDTYPE_KEYID 3 190 #define IDTYPE_ADDRESS 4 191 #define IDTYPE_ASN1DN 5 192 #define IDTYPE_SUBNET 6 193 194 /* qualifiers for KEYID (and maybe others) */ 195 #define IDQUAL_UNSPEC 0 196 #define IDQUAL_FILE 1 197 #define IDQUAL_TAG 2 198 199 /* The use for checking proposal payload. This is not exchange type. */ 200 #define IPSECDOI_TYPE_PH1 0 201 #define IPSECDOI_TYPE_PH2 1 202 203 /* 204 * Prefix that will make ipsecdoi_sockaddr2id() generate address type 205 * identities without knowning the exact length of address. 206 */ 207 #define IPSECDOI_PREFIX_HOST 0xff 208 209 struct isakmpsa; 210 struct ipsecdoi_pl_sa; 211 struct saprop; 212 struct saproto; 213 struct satrns; 214 struct prop_pair; 215 216 extern int ipsecdoi_checkph1proposal __P((vchar_t *, struct ph1handle *)); 217 extern int ipsecdoi_selectph2proposal __P((struct ph2handle *)); 218 extern int ipsecdoi_checkph2proposal __P((struct ph2handle *)); 219 220 extern struct prop_pair **get_proppair __P((vchar_t *, int)); 221 extern vchar_t *get_sabyproppair __P((u_int32_t, u_int32_t, struct prop_pair *)); 222 extern int ipsecdoi_updatespi __P((struct ph2handle *iph2)); 223 extern vchar_t *get_sabysaprop __P((struct saprop *, vchar_t *)); 224 extern int ipsecdoi_chkcmpids( const vchar_t *, const vchar_t *, int ); 225 extern int ipsecdoi_checkid1 __P((struct ph1handle *)); 226 extern int ipsecdoi_setid1 __P((struct ph1handle *)); 227 extern int set_identifier __P((vchar_t **, int, const vchar_t * const)); 228 extern int set_identifier_qual __P((vchar_t **, int, const vchar_t * const, int)); 229 extern int ipsecdoi_setid2 __P((struct ph2handle *)); 230 extern vchar_t *ipsecdoi_sockaddr2id __P((struct sockaddr *, u_int, u_int)); 231 extern int ipsecdoi_id2sockaddr __P((vchar_t *, struct sockaddr *, 232 u_int8_t *, u_int16_t *)); 233 extern char *ipsecdoi_id2str __P((const vchar_t *)); 234 extern vchar_t *ipsecdoi_sockrange2id __P(( struct sockaddr *, 235 struct sockaddr *, u_int)); 236 237 extern vchar_t *ipsecdoi_setph1proposal __P((struct remoteconf *, 238 struct isakmpsa *)); 239 extern int ipsecdoi_setph2proposal __P((struct ph2handle *)); 240 extern int ipsecdoi_transportmode __P((struct saprop *)); 241 extern int ipsecdoi_get_defaultlifetime __P((void)); 242 extern int ipsecdoi_checkalgtypes __P((int, int, int, int)); 243 extern int ipproto2doi __P((int)); 244 extern int doi2ipproto __P((int)); 245 246 extern int ipsecdoi_t2satrns __P((struct isakmp_pl_t *, 247 struct saprop *, struct saproto *, struct satrns *)); 248 extern int ipsecdoi_authalg2trnsid __P((int)); 249 extern int idtype2doi __P((int)); 250 extern int doi2idtype __P((int)); 251 252 extern int ipsecdoi_parse_responder_lifetime __P((struct isakmp_pl_n *notify, 253 u_int32_t *lifetime_sec, u_int32_t *liftime_kb)); 254 255 256 #endif /* _IPSEC_DOI_H */ 257