1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/netinet6/esp.h
|
4 |
|
|
//
|
5 |
|
|
//==========================================================================
|
6 |
|
|
// ####BSDCOPYRIGHTBEGIN####
|
7 |
|
|
// -------------------------------------------
|
8 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
9 |
|
|
//
|
10 |
|
|
// Portions of this software may have been derived from FreeBSD
|
11 |
|
|
// or other sources, and if so are covered by the appropriate copyright
|
12 |
|
|
// and license included herein.
|
13 |
|
|
//
|
14 |
|
|
// Portions created by the Free Software Foundation are
|
15 |
|
|
// Copyright (C) 2002 Free Software Foundation, Inc.
|
16 |
|
|
// -------------------------------------------
|
17 |
|
|
// ####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
|
20 |
|
|
/* $KAME: esp.h,v 1.19 2001/09/04 08:43:19 itojun Exp $ */
|
21 |
|
|
|
22 |
|
|
/*
|
23 |
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
24 |
|
|
* All rights reserved.
|
25 |
|
|
*
|
26 |
|
|
* Redistribution and use in source and binary forms, with or without
|
27 |
|
|
* modification, are permitted provided that the following conditions
|
28 |
|
|
* are met:
|
29 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
30 |
|
|
* notice, this list of conditions and the following disclaimer.
|
31 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
32 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
33 |
|
|
* documentation and/or other materials provided with the distribution.
|
34 |
|
|
* 3. Neither the name of the project nor the names of its contributors
|
35 |
|
|
* may be used to endorse or promote products derived from this software
|
36 |
|
|
* without specific prior written permission.
|
37 |
|
|
*
|
38 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
39 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
40 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
41 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
42 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
43 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
44 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
45 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
46 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
47 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
48 |
|
|
* SUCH DAMAGE.
|
49 |
|
|
*/
|
50 |
|
|
|
51 |
|
|
/*
|
52 |
|
|
* RFC1827/2406 Encapsulated Security Payload.
|
53 |
|
|
*/
|
54 |
|
|
|
55 |
|
|
#ifndef _NETINET6_ESP_H_
|
56 |
|
|
#define _NETINET6_ESP_H_
|
57 |
|
|
|
58 |
|
|
struct esp {
|
59 |
|
|
u_int32_t esp_spi; /* ESP */
|
60 |
|
|
/* variable size, 32bit bound */ /* Initialization Vector */
|
61 |
|
|
/* variable size */ /* Payload data */
|
62 |
|
|
/* variable size */ /* padding */
|
63 |
|
|
/* 8bit */ /* pad size */
|
64 |
|
|
/* 8bit */ /* next header */
|
65 |
|
|
/* 8bit */ /* next header */
|
66 |
|
|
/* variable size, 32bit bound */ /* Authentication data (new IPsec) */
|
67 |
|
|
};
|
68 |
|
|
|
69 |
|
|
struct newesp {
|
70 |
|
|
u_int32_t esp_spi; /* ESP */
|
71 |
|
|
u_int32_t esp_seq; /* Sequence number */
|
72 |
|
|
/* variable size */ /* (IV and) Payload data */
|
73 |
|
|
/* variable size */ /* padding */
|
74 |
|
|
/* 8bit */ /* pad size */
|
75 |
|
|
/* 8bit */ /* next header */
|
76 |
|
|
/* 8bit */ /* next header */
|
77 |
|
|
/* variable size, 32bit bound *//* Authentication data */
|
78 |
|
|
};
|
79 |
|
|
|
80 |
|
|
struct esptail {
|
81 |
|
|
u_int8_t esp_padlen; /* pad length */
|
82 |
|
|
u_int8_t esp_nxt; /* Next header */
|
83 |
|
|
/* variable size, 32bit bound *//* Authentication data (new IPsec)*/
|
84 |
|
|
};
|
85 |
|
|
|
86 |
|
|
#ifdef _KERNEL
|
87 |
|
|
struct secasvar;
|
88 |
|
|
|
89 |
|
|
struct esp_algorithm {
|
90 |
|
|
size_t padbound; /* pad boundary, in byte */
|
91 |
|
|
int ivlenval; /* iv length, in byte */
|
92 |
|
|
int (*mature) __P((struct secasvar *));
|
93 |
|
|
int keymin; /* in bits */
|
94 |
|
|
int keymax; /* in bits */
|
95 |
|
|
int (*schedlen) __P((const struct esp_algorithm *));
|
96 |
|
|
const char *name;
|
97 |
|
|
int (*ivlen) __P((const struct esp_algorithm *, struct secasvar *));
|
98 |
|
|
int (*decrypt) __P((struct mbuf *, size_t,
|
99 |
|
|
struct secasvar *, const struct esp_algorithm *, int));
|
100 |
|
|
int (*encrypt) __P((struct mbuf *, size_t, size_t,
|
101 |
|
|
struct secasvar *, const struct esp_algorithm *, int));
|
102 |
|
|
/* not supposed to be called directly */
|
103 |
|
|
int (*schedule) __P((const struct esp_algorithm *, struct secasvar *));
|
104 |
|
|
int (*blockdecrypt) __P((const struct esp_algorithm *,
|
105 |
|
|
struct secasvar *, u_int8_t *, u_int8_t *));
|
106 |
|
|
int (*blockencrypt) __P((const struct esp_algorithm *,
|
107 |
|
|
struct secasvar *, u_int8_t *, u_int8_t *));
|
108 |
|
|
};
|
109 |
|
|
|
110 |
|
|
extern const struct esp_algorithm *esp_algorithm_lookup __P((int));
|
111 |
|
|
extern int esp_max_ivlen __P((void));
|
112 |
|
|
|
113 |
|
|
/* crypt routines */
|
114 |
|
|
extern int esp4_output __P((struct mbuf *, struct ipsecrequest *));
|
115 |
|
|
#if (defined(__FreeBSD__) && __FreeBSD__ >= 4)
|
116 |
|
|
extern void esp4_input __P((struct mbuf *, int));
|
117 |
|
|
#else
|
118 |
|
|
extern void esp4_input __P((struct mbuf *, ...));
|
119 |
|
|
#endif /* (defined(__FreeBSD__) && __FreeBSD__ >= 4) */
|
120 |
|
|
extern size_t esp_hdrsiz __P((struct ipsecrequest *));
|
121 |
|
|
|
122 |
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 105080000 /* 1.5H */
|
123 |
|
|
extern void *esp4_ctlinput __P((int, struct sockaddr *, void *));
|
124 |
|
|
#endif
|
125 |
|
|
|
126 |
|
|
#ifdef INET6
|
127 |
|
|
extern int esp6_output __P((struct mbuf *, u_char *, struct mbuf *,
|
128 |
|
|
struct ipsecrequest *));
|
129 |
|
|
extern int esp6_input __P((struct mbuf **, int *, int));
|
130 |
|
|
|
131 |
|
|
extern void esp6_ctlinput __P((int, struct sockaddr *, void *));
|
132 |
|
|
#endif /* INET6 */
|
133 |
|
|
|
134 |
|
|
extern int esp_schedule __P((const struct esp_algorithm *, struct secasvar *));
|
135 |
|
|
extern int esp_auth __P((struct mbuf *, size_t, size_t,
|
136 |
|
|
struct secasvar *, u_char *));
|
137 |
|
|
#endif /* _KERNEL */
|
138 |
|
|
|
139 |
|
|
#endif /* _NETINET6_ESP_H_ */
|