1 | /*
|
---|
2 | * TINET (TCP/IP Protocol Stack)
|
---|
3 | *
|
---|
4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
5 | * Tomakomai National College of Technology, JAPAN
|
---|
6 | * Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
|
---|
7 | *
|
---|
8 | * ä¸è¨èä½æ¨©è
|
---|
9 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
10 | * ã«ãã£ã¦å
|
---|
11 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
12 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
13 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
14 | å¸ï¼ä»¥ä¸ï¼
|
---|
15 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
16 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
17 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
18 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
19 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
20 | * ç¨ã§ããå½¢ã§åé
|
---|
21 | å¸ããå ´åã«ã¯ï¼åé
|
---|
22 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
23 | * è
|
---|
24 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
25 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
26 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
27 | * ç¨ã§ããªãå½¢ã§åé
|
---|
28 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
29 | * (a) åé
|
---|
30 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
31 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
32 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
33 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
34 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
35 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
36 | 責ãããã¨ï¼
|
---|
37 | *
|
---|
38 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
39 | ã
|
---|
40 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
41 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
42 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
43 | *
|
---|
44 | * @(#) $Id: esp.h 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
45 | */
|
---|
46 |
|
---|
47 | /* $FreeBSD: src/sys/netinet6/esp.h,v 1.6 2002/04/19 04:46:22 suz Exp $ */
|
---|
48 | /* $KAME: esp.h,v 1.19 2001/09/04 08:43:19 itojun Exp $ */
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
---|
52 | * All rights reserved.
|
---|
53 | *
|
---|
54 | * Redistribution and use in source and binary forms, with or without
|
---|
55 | * modification, are permitted provided that the following conditions
|
---|
56 | * are met:
|
---|
57 | * 1. Redistributions of source code must retain the above copyright
|
---|
58 | * notice, this list of conditions and the following disclaimer.
|
---|
59 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
60 | * notice, this list of conditions and the following disclaimer in the
|
---|
61 | * documentation and/or other materials provided with the distribution.
|
---|
62 | * 3. Neither the name of the project nor the names of its contributors
|
---|
63 | * may be used to endorse or promote products derived from this software
|
---|
64 | * without specific prior written permission.
|
---|
65 | *
|
---|
66 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
---|
67 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
68 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
69 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
---|
70 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
71 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
72 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
73 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
74 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
75 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
76 | * SUCH DAMAGE.
|
---|
77 | */
|
---|
78 |
|
---|
79 | #ifndef _ESP_H_
|
---|
80 | #define _ESP_H_
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * RFC2406 æå·åããã
|
---|
84 | */
|
---|
85 |
|
---|
86 | typedef struct t_esp_hdr {
|
---|
87 | int32_t spi; /* Security Parameter Index (SPI) */
|
---|
88 | int32_t seq; /* ã·ã¼ã±ã³ã¹çªå· */
|
---|
89 | } __attribute__((packed, aligned(2)))T_ESP_HDR;
|
---|
90 |
|
---|
91 | typedef struct t_esp_tail {
|
---|
92 | int8_t padlen; /* ããã£ã³ã°é· */
|
---|
93 | int8_t next; /* Next Header */
|
---|
94 | } __attribute__((packed, aligned(2)))T_ESP_TAIL;
|
---|
95 |
|
---|
96 | struct t_secas_var;
|
---|
97 |
|
---|
98 | struct t_esp_algorithm {
|
---|
99 | size_t padbound; /* pad boundary, in byte */
|
---|
100 | int_t ivlenval; /* iv length, in byte */
|
---|
101 | int_t (*mature) (struct t_secas_var *);
|
---|
102 | int_t keymin; /* in bits */
|
---|
103 | int_t keymax; /* in bits */
|
---|
104 | //int_t (*schedlen) (const struct t_esp_algorithm *);
|
---|
105 | int32_t (*schedlen) (const struct t_esp_algorithm *);
|
---|
106 | const char *name;
|
---|
107 | int_t (*ivlen) (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
108 | int_t (*decrypt) (T_NET_BUF *, size_t,
|
---|
109 | struct t_secas_var *, const struct t_esp_algorithm *, int_t,
|
---|
110 | T_NET_BUF *, size_t);
|
---|
111 | int_t (*encrypt) (T_NET_BUF *, size_t, size_t, int8_t*,
|
---|
112 | struct t_secas_var *, const struct t_esp_algorithm *, int_t,
|
---|
113 | T_NET_BUF *, size_t);
|
---|
114 | /* not supposed to be called directly */
|
---|
115 | int_t (*schedule) (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
116 | int_t (*blockdecrypt) (const struct t_esp_algorithm *,
|
---|
117 | struct t_secas_var *, int8_t *, int8_t *);
|
---|
118 | int_t (*blockencrypt) (const struct t_esp_algorithm *,
|
---|
119 | struct t_secas_var *, int8_t *, int8_t *);
|
---|
120 | };
|
---|
121 |
|
---|
122 | typedef struct t_esp_algorithm T_ESP_ALGORITHM;
|
---|
123 |
|
---|
124 | #define MAXIVLEN 16
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * é¢æ°
|
---|
128 | */
|
---|
129 |
|
---|
130 | extern const struct t_esp_algorithm *esp_algorithm_lookup (int_t);
|
---|
131 | extern int_t esp_max_ivlen (void);
|
---|
132 | extern int_t esp_schedule (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
133 | extern int_t esp4_input(T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
|
---|
134 |
|
---|
135 | #ifdef T_IPSEC_REQUEST_DEFINED
|
---|
136 |
|
---|
137 | extern int_t esp4_output(T_NET_BUF *m, T_IPSEC_REQUEST *isr, T_NET_BUF** result);
|
---|
138 |
|
---|
139 | #endif /* of #ifdef T_IPSEC_REQUEST_DEFINED */
|
---|
140 |
|
---|
141 | #endif /* of #ifndef _ESP_H_ */
|
---|