OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / klips / net / ipsec / ipsec_esp.h
1 /*
2  * Copyright (C) 1996, 1997  John Ioannidis.
3  * Copyright (C) 1998, 1999, 2000, 2001  Richard Guy Briggs.
4  * 
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
9  * 
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  *
15  * RCSID $Id: ipsec_esp.h,v 1.17 2002/02/20 01:27:07 rgb Exp $
16  */
17
18 #include "ipsec_md5h.h"
19 #include "ipsec_sha1.h"
20
21 #include "des.h"
22
23 #ifndef IPPROTO_ESP
24 #define IPPROTO_ESP 50
25 #endif /* IPPROTO_ESP */
26
27 #define ESP_HEADER_LEN          8       /* 64 bits header (spi+rpl)*/
28
29 #define EMT_ESPDESCBC_ULEN      20      /* coming from user mode */
30 #define EMT_ESPDES_KMAX         64      /* 512 bit secret key enough? */
31 #define EMT_ESPDES_KEY_SZ       8       /* 56 bit secret key with parity = 64 bits */
32 #define EMT_ESP3DES_KEY_SZ      24      /* 168 bit secret key with parity = 192 bits */
33 #define EMT_ESPDES_IV_SZ        8       /* IV size */
34 #define ESP_DESCBC_BLKLEN       8       /* DES-CBC block size */
35
36 #ifdef USE_IXP4XX_CRYPTO
37 #define EMT_ESPAES_KMAX             32  /* 256 bit AES secret key  */
38 #define EMT_ESPAES128_KEY_SZ    16      /* 128 bit AES secret key */
39 #define EMT_ESPAES192_KEY_SZ    24      /* 192 bit AES secret key */
40 #define EMT_ESPAES256_KEY_SZ    32      /* 256 bit AES secret key */
41 #define EMT_ESPAES_CBC_IV_SZ    16      /* IV size */
42 #define ESP_AESCBC_BLKLEN       16  /* AES-CBC block size */
43 #endif /* USE_IXP4XX_CRYPTO */
44
45 #define ESP_IV_MAXSZ            16      /* This is _critical_ */
46 #define ESP_IV_MAXSZ_INT        (ESP_IV_MAXSZ/sizeof(int))
47
48 #define DB_ES_PKTRX     0x0001
49 #define DB_ES_PKTRX2    0x0002
50 #define DB_ES_TDB       0x0010
51 #define DB_ES_XF        0x0020
52 #define DB_ES_IPAD      0x0040
53 #define DB_ES_INAU      0x0080
54 #define DB_ES_OINFO     0x0100
55 #define DB_ES_OINFO2    0x0200
56 #define DB_ES_OH        0x0400
57 #define DB_ES_REPLAY    0x0800
58
59 #ifdef __KERNEL__
60 struct des_eks {
61         des_key_schedule ks;
62 };
63
64 extern struct inet_protocol esp_protocol;
65
66 struct options;
67
68 extern int
69 esp_rcv(struct sk_buff *skb,
70         struct device *dev,
71         struct options *opt, 
72         __u32 daddr,
73         unsigned short len,
74         __u32 saddr,
75         int redo,
76         struct inet_protocol *protocol);
77
78 /* XXX: only for 64 bits IVs, eg. ESP_3DES */
79 struct esp
80 {
81         __u32   esp_spi;                /* Security Parameters Index */
82         __u32   esp_rpl;                /* Replay counter */
83 #ifndef USE_IXP4XX_CRYPTO
84         __u8    esp_iv[8];              /* iv */
85 #else
86         /*__u8  esp_iv[8];*/            /* iv is not part of ESP header, it
87                                         should be the first block of data to
88                                         ESP packet. IV size is different for
89                                         3DES and AES, therefore we can't have
90                                         a fix 8-byte of IV in the header. IV
91                                         has been moved out and become payload*/
92 #endif /* USE_IXP4XX_CRYPTO */
93 };
94
95 #ifdef CONFIG_IPSEC_DEBUG
96 extern int debug_esp;
97 #endif /* CONFIG_IPSEC_DEBUG */
98 #endif /* __KERNEL__ */
99
100 /*
101  * $Log: ipsec_esp.h,v $
102  * Revision 1.17  2002/02/20 01:27:07  rgb
103  * Ditched a pile of structs only used by the old Netlink interface.
104  *
105  * Revision 1.16  2001/12/11 02:35:57  rgb
106  * Change "struct net_device" to "struct device" for 2.2 compatibility.
107  *
108  * Revision 1.15  2001/11/26 09:23:48  rgb
109  * Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
110  *
111  * Revision 1.14.2.3  2001/10/23 04:16:42  mcr
112  *      get definition of des_key_schedule from des.h
113  *
114  * Revision 1.14.2.2  2001/10/22 20:33:13  mcr
115  *      use "des_key_schedule" structure instead of cooking our own.
116  *
117  * Revision 1.14.2.1  2001/09/25 02:18:25  mcr
118  *      replace "struct device" with "struct netdevice"
119  *
120  * Revision 1.14  2001/06/14 19:35:08  rgb
121  * Update copyright date.
122  *
123  * Revision 1.13  2000/09/08 19:12:56  rgb
124  * Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
125  *
126  * Revision 1.12  2000/08/01 14:51:50  rgb
127  * Removed _all_ remaining traces of DES.
128  *
129  * Revision 1.11  2000/01/10 16:36:20  rgb
130  * Ditch last of EME option flags, including initiator.
131  *
132  * Revision 1.10  1999/12/07 18:16:22  rgb
133  * Fixed comments at end of #endif lines.
134  *
135  * Revision 1.9  1999/04/11 00:28:57  henry
136  * GPL boilerplate
137  *
138  * Revision 1.8  1999/04/06 04:54:25  rgb
139  * Fix/Add RCSID Id: and Log: bits to make PHMDs happy.  This includes
140  * patch shell fixes.
141  *
142  * Revision 1.7  1999/01/26 02:06:00  rgb
143  * Removed CONFIG_IPSEC_ALGO_SWITCH macro.
144  *
145  * Revision 1.6  1999/01/22 15:22:05  rgb
146  * Re-enable IV in the espblkrply_edata structure to avoid breaking pluto
147  * until pluto can be fixed properly.
148  *
149  * Revision 1.5  1999/01/22 06:18:16  rgb
150  * Updated macro comments.
151  * Added key schedule types to support algorithm switch code.
152  *
153  * Revision 1.4  1998/08/12 00:07:32  rgb
154  * Added data structures for new xforms: null, {,3}dessha1.
155  *
156  * Revision 1.3  1998/07/14 15:57:01  rgb
157  * Add #ifdef __KERNEL__ to protect kernel-only structures.
158  *
159  * Revision 1.2  1998/06/25 19:33:46  rgb
160  * Add prototype for protocol receive function.
161  * Rearrange for more logical layout.
162  *
163  * Revision 1.1  1998/06/18 21:27:45  henry
164  * move sources from klips/src to klips/net/ipsec, to keep stupid
165  * kernel-build scripts happier in the presence of symlinks
166  *
167  * Revision 1.6  1998/06/05 02:28:08  rgb
168  * Minor comment fix.
169  *
170  * Revision 1.5  1998/05/27 22:34:00  rgb
171  * Changed structures to accomodate key separation.
172  *
173  * Revision 1.4  1998/05/18 22:28:43  rgb
174  * Disable key printing facilities from /proc/net/ipsec_*.
175  *
176  * Revision 1.3  1998/04/21 21:29:07  rgb
177  * Rearrange debug switches to change on the fly debug output from user
178  * space.  Only kernel changes checked in at this time.  radij.c was also
179  * changed to temporarily remove buggy debugging code in rj_delete causing
180  * an OOPS and hence, netlink device open errors.
181  *
182  * Revision 1.2  1998/04/12 22:03:20  rgb
183  * Updated ESP-3DES-HMAC-MD5-96,
184  *      ESP-DES-HMAC-MD5-96,
185  *      AH-HMAC-MD5-96,
186  *      AH-HMAC-SHA1-96 since Henry started freeswan cvs repository
187  * from old standards (RFC182[5-9] to new (as of March 1998) drafts.
188  *
189  * Fixed eroute references in /proc/net/ipsec*.
190  *
191  * Started to patch module unloading memory leaks in ipsec_netlink and
192  * radij tree unloading.
193  *
194  * Revision 1.1  1998/04/09 03:06:00  henry
195  * sources moved up from linux/net/ipsec
196  *
197  * Revision 1.1.1.1  1998/04/08 05:35:02  henry
198  * RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
199  *
200  * Revision 0.5  1997/06/03 04:24:48  ji
201  * Added ESP-3DES-MD5-96 transform.
202  *
203  * Revision 0.4  1997/01/15 01:28:15  ji
204  * Added definitions for new ESP transforms.
205  *
206  * Revision 0.3  1996/11/20 14:35:48  ji
207  * Minor Cleanup.
208  * Rationalized debugging code.
209  *
210  * Revision 0.2  1996/11/02 00:18:33  ji
211  * First limited release.
212  *
213  *
214  */