[388] | 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 | * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
|
---|
| 9 | * によって公表されている GNU General Public License の Version 2 に記
|
---|
| 10 | * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
|
---|
| 11 | * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
| 12 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
| 13 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 14 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 15 | * スコード中に含まれていること.
|
---|
| 16 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 17 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 18 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 19 | * の無保証規定を掲載すること.
|
---|
| 20 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 21 | * 用できない形で再配布する場合には,次の条件を満たすこと.
|
---|
| 22 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 23 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 24 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 25 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 26 | *
|
---|
| 27 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 28 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
|
---|
| 29 | * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
|
---|
| 30 | * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
|
---|
| 31 | *
|
---|
| 32 | * @(#) $Id$
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | /* $FreeBSD: src/sys/netinet6/esp.h,v 1.6 2002/04/19 04:46:22 suz Exp $ */
|
---|
| 36 | /* $KAME: esp.h,v 1.19 2001/09/04 08:43:19 itojun Exp $ */
|
---|
| 37 |
|
---|
| 38 | /*
|
---|
| 39 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
---|
| 40 | * All rights reserved.
|
---|
| 41 | *
|
---|
| 42 | * Redistribution and use in source and binary forms, with or without
|
---|
| 43 | * modification, are permitted provided that the following conditions
|
---|
| 44 | * are met:
|
---|
| 45 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 46 | * notice, this list of conditions and the following disclaimer.
|
---|
| 47 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 48 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 49 | * documentation and/or other materials provided with the distribution.
|
---|
| 50 | * 3. Neither the name of the project nor the names of its contributors
|
---|
| 51 | * may be used to endorse or promote products derived from this software
|
---|
| 52 | * without specific prior written permission.
|
---|
| 53 | *
|
---|
| 54 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
---|
| 55 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 56 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
---|
| 58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
| 60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
| 61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
| 62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
| 63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 64 | * SUCH DAMAGE.
|
---|
| 65 | */
|
---|
| 66 |
|
---|
| 67 | #ifndef _ESP_H_
|
---|
| 68 | #define _ESP_H_
|
---|
| 69 |
|
---|
| 70 | /*
|
---|
| 71 | * RFC2406 暗号化ヘッダ
|
---|
| 72 | */
|
---|
| 73 |
|
---|
| 74 | typedef struct t_esp_hdr {
|
---|
| 75 | int32_t spi; /* Security Parameter Index (SPI) */
|
---|
| 76 | int32_t seq; /* シーケンス番号 */
|
---|
| 77 | } __attribute__((packed, aligned(2)))T_ESP_HDR;
|
---|
| 78 |
|
---|
| 79 | typedef struct t_esp_tail {
|
---|
| 80 | int8_t padlen; /* パディング長 */
|
---|
| 81 | int8_t next; /* Next Header */
|
---|
| 82 | } __attribute__((packed, aligned(2)))T_ESP_TAIL;
|
---|
| 83 |
|
---|
| 84 | struct t_secas_var;
|
---|
| 85 |
|
---|
| 86 | struct t_esp_algorithm {
|
---|
| 87 | size_t padbound; /* pad boundary, in byte */
|
---|
| 88 | int_t ivlenval; /* iv length, in byte */
|
---|
| 89 | int_t (*mature) (struct t_secas_var *);
|
---|
| 90 | int_t keymin; /* in bits */
|
---|
| 91 | int_t keymax; /* in bits */
|
---|
| 92 | //int_t (*schedlen) (const struct t_esp_algorithm *);
|
---|
| 93 | int32_t (*schedlen) (const struct t_esp_algorithm *);
|
---|
| 94 | const char *name;
|
---|
| 95 | int_t (*ivlen) (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
| 96 | int_t (*decrypt) (T_NET_BUF *, size_t,
|
---|
| 97 | struct t_secas_var *, const struct t_esp_algorithm *, int_t,
|
---|
| 98 | T_NET_BUF *, size_t);
|
---|
| 99 | int_t (*encrypt) (T_NET_BUF *, size_t, size_t, int8_t*,
|
---|
| 100 | struct t_secas_var *, const struct t_esp_algorithm *, int_t,
|
---|
| 101 | T_NET_BUF *, size_t);
|
---|
| 102 | /* not supposed to be called directly */
|
---|
| 103 | int_t (*schedule) (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
| 104 | int_t (*blockdecrypt) (const struct t_esp_algorithm *,
|
---|
| 105 | struct t_secas_var *, int8_t *, int8_t *);
|
---|
| 106 | int_t (*blockencrypt) (const struct t_esp_algorithm *,
|
---|
| 107 | struct t_secas_var *, int8_t *, int8_t *);
|
---|
| 108 | };
|
---|
| 109 |
|
---|
| 110 | typedef struct t_esp_algorithm T_ESP_ALGORITHM;
|
---|
| 111 |
|
---|
| 112 | #define MAXIVLEN 16
|
---|
| 113 |
|
---|
| 114 | /*
|
---|
| 115 | * 関数
|
---|
| 116 | */
|
---|
| 117 |
|
---|
| 118 | extern const struct t_esp_algorithm *esp_algorithm_lookup (int_t);
|
---|
| 119 | extern int_t esp_max_ivlen (void);
|
---|
| 120 | extern int_t esp_schedule (const struct t_esp_algorithm *, struct t_secas_var *);
|
---|
| 121 | extern int_t esp4_input(T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
|
---|
| 122 |
|
---|
| 123 | #ifdef T_IPSEC_REQUEST_DEFINED
|
---|
| 124 |
|
---|
| 125 | extern int_t esp4_output(T_NET_BUF *m, T_IPSEC_REQUEST *isr, T_NET_BUF** result);
|
---|
| 126 |
|
---|
| 127 | #endif /* of #ifdef T_IPSEC_REQUEST_DEFINED */
|
---|
| 128 |
|
---|
| 129 | #endif /* of #ifndef _ESP_H_ */
|
---|