/home/tomh/openhip/hip-0.5/src/include/hip/hip_proto.h

Go to the documentation of this file.
00001 /*
00002  * Host Identity Protocol
00003  * Copyright (C) 2002-06 the Boeing Company
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  *              Definitions for the HIP protocol.
00016  *
00017  *  Version:    @(#)hip.h       1.5     08/12/04
00018  *
00019  *  Authors:    Jeff Ahrenholz, <jeffrey.m.ahrenholz@boeing.com>
00020  *              Tom Henderson, <thomas.r.henderson@boeing.com>
00021  *
00022  *
00023  */
00024 
00025 #ifndef _HIP_PROTOCOL_H_
00026 #define _HIP_PROTOCOL_H_
00027 
00028 #include <openssl/bn.h>
00029 #include <openssl/hmac.h>
00030 #include <openssl/rsa.h>
00031 
00032 
00033 /* 
00034  * Protocol constants 
00035  */ 
00036 
00037 
00038 #define H_PROTO_UDP 17
00039 #define HIP_ESP_UDP_PORT 54500
00040 
00041 #define HIP_PROTO_VER 1
00042 #define H_PROTO_HIP 253 /* IP layer protocol number for private encryption */
00043 #define HIP_PAYLOAD_PROTOCOL 59
00044 #define STATUS_PORT 4051 /* UDP port for obtaining status data */
00045 
00046 #define SPI_RESERVED 255
00047 #define HIP_ALIGN 4
00048 #define ACCEPTABLE_R1_COUNT_RANGE 2
00049 
00050 #define HIT_SIZE 16
00051 #define HIT_PREFIX_TYPE1_SHA1   0x40
00052 
00053 typedef enum {
00054         UNASSOCIATED,   /* State machine start                  */
00055         I1_SENT,        /* Initiating HIP                       */
00056         I2_SENT,        /* Waiting to finish HIP                */
00057         R2_SENT,        /* Waiting to finish HIP                */
00058         ESTABLISHED,    /* HIP SA established                   */
00059         REKEYING,       /* HIP SA established, rekeying         */
00060         CLOSING,        /* HIP SA closing, no data can be sent  */
00061         CLOSED,         /* HIP SA closed, no data can be sent   */
00062         E_FAILED        /* HIP SA establishment failed          */
00063 } HIP_STATES;
00064 
00065 /* HIP packet types */
00066 typedef enum {
00067         HIP_I1=1,
00068         HIP_R1,
00069         HIP_I2,
00070         HIP_R2,
00071         CER,    /* 5 - removed from draft-ietf-hip-base-03 */
00072         BOS=11, /* 11 - removed from draft-ietf-hip-base-01 */
00073         UPDATE=16, /* 16 */
00074         NOTIFY=17, /* 17 */
00075         CLOSE=18,  /* 18 */
00076         CLOSE_ACK=19, /* 19 */
00077 } HIP_PACKETS;
00078 
00079 /* HIP controls */
00080 typedef enum {
00081         CTL_ANON        = 0x0001,
00082 } HIP_CONTROLS;
00083 
00084 
00085 
00086 /* HIP TLV parameters */
00087 #define PARAM_ESP_INFO                  65
00088 #define PARAM_R1_COUNTER                128
00089 #define PARAM_LOCATOR                   193
00090 #define PARAM_PUZZLE                    257
00091 #define PARAM_SOLUTION                  321
00092 #define PARAM_SEQ                       385
00093 #define PARAM_ACK                       449
00094 #define PARAM_DIFFIE_HELLMAN            513
00095 #define PARAM_HIP_TRANSFORM             577
00096 #define PARAM_ENCRYPTED                 641
00097 #define PARAM_HOST_ID                   705
00098 #define PARAM_CERT                      768
00099 #define PARAM_NOTIFY                    832
00100 #define PARAM_ECHO_REQUEST              897
00101 #define PARAM_REG_INFO                  930
00102 #define PARAM_REG_REQUEST               932
00103 #define PARAM_REG_RESPONSE              934
00104 #define PARAM_REG_FAILED                936
00105 #define PARAM_REG_REQUIRED              /* TBD */
00106 #define PARAM_ECHO_RESPONSE             961
00107 #define PARAM_ESP_TRANSFORM             4095
00108 #define PARAM_TRANSFORM_LOW             2048 /* defines range for transforms */
00109 #define PARAM_TRANSFORM_HIGH            4095
00110 #define PARAM_HMAC                      61505
00111 #define PARAM_HMAC_2                    61569
00112 #define PARAM_HIP_SIGNATURE_2           61633
00113 #define PARAM_HIP_SIGNATURE             61697
00114 #define PARAM_ECHO_REQUEST_NOSIG        63661
00115 #define PARAM_ECHO_RESPONSE_NOSIG       63425
00116 #define PARAM_FROM                      65498
00117 #define PARAM_RVS_HMAC                  65500
00118 #define PARAM_VIA_RVS                   65502
00119 #define PARAM_CRITICAL_BIT              0x0001
00120 
00121 /* encryption algorithms */
00122 typedef enum {
00123         RESERVED,                       /* 0 */
00124         ESP_AES_CBC_HMAC_SHA1,          /* 1 */
00125         ESP_3DES_CBC_HMAC_SHA1,         /* 2 */
00126         ESP_3DES_CBC_HMAC_MD5,          /* 3 */
00127         ESP_BLOWFISH_CBC_HMAC_SHA1,     /* 4 */
00128         ESP_NULL_HMAC_SHA1,             /* 5 */
00129         ESP_NULL_HMAC_MD5,              /* 6 */
00130         SUITE_ID_MAX,                   /* 7 */
00131 } SUITE_IDS;
00132 #define ENCR_NULL(a) ((a==ESP_NULL_HMAC_SHA1) || \
00133                         (a==ESP_NULL_HMAC_MD5))
00134 /* Supported transforms are compressed into a bitmask... */
00135 /* Default HIP transforms proposed when none are specified in config */
00136 #define DEFAULT_HIP_TRANS \
00137         ((1 << ESP_AES_CBC_HMAC_SHA1) | \
00138         (1 << ESP_3DES_CBC_HMAC_SHA1) | \
00139         (1 << ESP_3DES_CBC_HMAC_MD5) | \
00140         (1 << ESP_BLOWFISH_CBC_HMAC_SHA1) | \
00141         (1 << ESP_NULL_HMAC_SHA1) | \
00142         (1 << ESP_NULL_HMAC_MD5))
00143 /* Default ESP transforms proposed when none are specified in config */
00144 #define ESP_OFFSET 8
00145 #ifndef __CYGWIN__
00146 #define DEFAULT_ESP_TRANS \
00147         ((1 << (ESP_OFFSET + ESP_AES_CBC_HMAC_SHA1)) | \
00148         (1 << (ESP_OFFSET + ESP_3DES_CBC_HMAC_SHA1)) | \
00149         (1 << (ESP_OFFSET + ESP_3DES_CBC_HMAC_MD5)) | \
00150         (1 << (ESP_OFFSET + ESP_BLOWFISH_CBC_HMAC_SHA1)) | \
00151         (1 << (ESP_OFFSET + ESP_NULL_HMAC_SHA1)) | \
00152         (1 << (ESP_OFFSET + ESP_NULL_HMAC_MD5)))
00153 #else /* Windows transform support more limited. */
00154 #define DEFAULT_ESP_TRANS \
00155         ((1 << (ESP_OFFSET + ESP_3DES_CBC_HMAC_SHA1)) | \
00156         (1 << (ESP_OFFSET + ESP_3DES_CBC_HMAC_MD5)) | \
00157         (1 << (ESP_OFFSET + ESP_NULL_HMAC_SHA1)) | \
00158         (1 << (ESP_OFFSET + ESP_NULL_HMAC_MD5)))
00159 #endif
00160 
00161 /* HI (signature) algorithms  */
00162 enum {
00163         HI_ALG_RESERVED,
00164         HI_ALG_DSA = 3,
00165         HI_ALG_RSA = 5,
00166 } HI_ALGORITHMS;
00167 #define HIP_RSA_DFT_EXP RSA_F4 /* 0x10001L = 65537; 3 and 17 are also common */
00168 #define HI_TYPESTR(a)  ((a==HI_ALG_DSA) ? "DSA" : \
00169                         (a==HI_ALG_RSA) ? "RSA" : "UNKNOWN")
00170 
00171 /* HI Domain Identifier types */
00172 enum {
00173         DIT_NONE,       /* none included */
00174         DIT_FQDN,       /* Fully Qualified Domain Name, in binary format */
00175         DIT_NAI,        /* Network Access Identifier, binary, login@FQDN */
00176 } HI_DIT;
00177 
00178 typedef enum {
00179         UNVERIFIED,
00180         ACTIVE,
00181         DEPRECATED,
00182         DELETED,        /* not in spec, but used when address is removed */
00183 } ADDRESS_STATES;
00184 
00185 typedef enum {
00186         HIP_ENCRYPTION,
00187         HIP_INTEGRITY,
00188         ESP_ENCRYPTION,
00189         ESP_AUTH,
00190 } KEY_TYPES;
00191 
00192 typedef enum {
00193         GL_HIP_ENCRYPTION_KEY,  /* 0 */
00194         GL_HIP_INTEGRITY_KEY,
00195         LG_HIP_ENCRYPTION_KEY,
00196         LG_HIP_INTEGRITY_KEY,
00197         GL_ESP_ENCRYPTION_KEY,
00198         GL_ESP_AUTH_KEY,
00199         LG_ESP_ENCRYPTION_KEY,
00200         LG_ESP_AUTH_KEY /* 7 */
00201 } HIP_KEYMAT_KEYS;
00202 
00203 typedef enum {
00204         KEY_LEN_NULL = 0,       /* RFC 2410 */
00205         KEY_LEN_MD5 = 16,       /* 128 bits per RFC 2403 */
00206         KEY_LEN_SHA1 = 20,      /* 160 bits per RFC 2404 */
00207         KEY_LEN_3DES = 24,      /* 192 bits (3x64-bit keys) RFC 2451 */
00208         KEY_LEN_AES = 16,       /* 128 bits per RFC 3686; also 192, 256-bits */
00209         KEY_LEN_BLOWFISH = 16,  /* 128 bits per RFC 2451 */
00210 } HIP_KEYLENS;
00211 
00212 /* Diffie-Hellman Group IDs */
00213 typedef enum {
00214         DH_RESERVED,
00215         DH_384,
00216         DH_OAKLEY_1,
00217         DH_MODP_1536,
00218         DH_MODP_3072,
00219         DH_MODP_6144,
00220         DH_MODP_8192,
00221         DH_MAX
00222 } DH_GROUP_IDS;
00223 /* choose default DH group here */
00224 #define DEFAULT_DH_GROUP_ID  DH_MODP_1536
00225 #define DH_MAX_LEN 1024
00226 
00227 /* 
00228  * HIP LOCATOR parameters 
00229  */
00230 #define LOCATOR_PREFERRED               0x01
00231 #define LOCATOR_TRAFFIC_TYPE_BOTH       0x00
00232 #define LOCATOR_TRAFFIC_TYPE_SIGNALING  0x01
00233 #define LOCATOR_TRAFFIC_TYPE_DATA       0x02
00234 #define LOCATOR_TYPE_IPV6               0x00
00235 #define LOCATOR_TYPE_SPI_IPV6           0x01
00236 
00237 /*
00238  * Notify error types
00239  */
00240 #define NOTIFY_UNSUPPORTED_CRITICAL_PARAMETER_TYPE        1
00241 #define NOTIFY_INVALID_SYNTAX                             7
00242 #define NOTIFY_NO_DH_PROPOSAL_CHOSEN                     14
00243 #define NOTIFY_INVALID_DH_CHOSEN                         15
00244 #define NOTIFY_NO_HIP_PROPOSAL_CHOSEN                    16
00245 #define NOTIFY_INVALID_HIP_TRANSFORM_CHOSEN              17
00246 #define NOTIFY_NO_ESP_PROPOSAL_CHOSEN                    18
00247 #define NOTIFY_INVALID_ESP_TRANSFORM_CHOSEN              19
00248 #define NOTIFY_AUTHENTICATION_FAILED                     24
00249 #define NOTIFY_CHECKSUM_FAILED                           26
00250 #define NOTIFY_HMAC_FAILED                               28
00251 #define NOTIFY_ENCRYPTION_FAILED                         32
00252 #define NOTIFY_INVALID_HIT                               40
00253 #define NOTIFY_BLOCKED_BY_POLICY                         42
00254 #define NOTIFY_SERVER_BUSY_PLEASE_RETRY                  44
00255 #define NOTIFY_I2_ACKNOWLEDGEMENT                        46
00256 
00257 #endif /* !_HIP_PROTOCOL_H_ */
00258 
00259 
00260 

Generated on Mon Oct 22 11:43:43 2007 for OpenHIP by  doxygen 1.5.1