xref: /netbsd-src/crypto/dist/ipsec-tools/src/racoon/algorithm.h (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1 /*	$NetBSD: algorithm.h,v 1.3 2005/11/21 14:20:28 manu Exp $	*/
2 
3 /* Id: algorithm.h,v 1.8 2004/11/18 15:14:44 ludvigm Exp */
4 
5 /*
6  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the project nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 #ifndef _ALGORITHM_H
35 #define _ALGORITHM_H
36 
37 #include <gnuc.h>
38 
39 /* algorithm class */
40 enum {
41 	algclass_ipsec_enc,
42 	algclass_ipsec_auth,
43 	algclass_ipsec_comp,
44 	algclass_isakmp_enc,
45 	algclass_isakmp_hash,
46 	algclass_isakmp_dh,
47 	algclass_isakmp_ameth,	/* authentication method. */
48 #define MAXALGCLASS	7
49 };
50 
51 #define ALG_DEFAULT_KEYLEN	64
52 
53 #define ALGTYPE_NOTHING		0
54 
55 /* algorithm type */
56 enum algtype {
57 	algtype_nothing = 0,
58 
59 	/* enc */
60 	algtype_des_iv64,
61 	algtype_des,
62 	algtype_3des,
63 	algtype_rc5,
64 	algtype_idea,
65 	algtype_cast128,
66 	algtype_blowfish,
67 	algtype_3idea,
68 	algtype_des_iv32,
69 	algtype_rc4,
70 	algtype_null_enc,
71 	algtype_aes,
72 	algtype_twofish,
73 
74 	/* ipsec auth */
75 	algtype_hmac_md5,
76 	algtype_hmac_sha1,
77 	algtype_des_mac,
78 	algtype_kpdk,
79 	algtype_non_auth,
80 	algtype_hmac_sha2_256,
81 	algtype_hmac_sha2_384,
82 	algtype_hmac_sha2_512,
83 
84 	/* ipcomp */
85 	algtype_oui,
86 	algtype_deflate,
87 	algtype_lzs,
88 
89 	/* hash */
90 	algtype_md5,
91 	algtype_sha1,
92 	algtype_tiger,
93 	algtype_sha2_256,
94 	algtype_sha2_384,
95 	algtype_sha2_512,
96 
97 	/* dh_group */
98 	algtype_modp768,
99 	algtype_modp1024,
100 	algtype_ec2n155,
101 	algtype_ec2n185,
102 	algtype_modp1536,
103 	algtype_modp2048,
104 	algtype_modp3072,
105 	algtype_modp4096,
106 	algtype_modp6144,
107 	algtype_modp8192,
108 
109 	/* authentication method. */
110 	algtype_psk,
111 	algtype_dsssig,
112 	algtype_rsasig,
113 	algtype_rsaenc,
114 	algtype_rsarev,
115 	algtype_gssapikrb,
116 #ifdef ENABLE_HYBRID
117 	algtype_hybrid_rsa_s,
118 	algtype_hybrid_dss_s,
119 	algtype_hybrid_rsa_c,
120 	algtype_hybrid_dss_c,
121 #endif
122 };
123 
124 struct hmac_algorithm {
125 	char *name;
126 	int type;
127 	int doi;
128 	caddr_t (*init) __P((vchar_t *));
129 	void (*update) __P((caddr_t, vchar_t *));
130 	vchar_t *(*final) __P((caddr_t));
131 	int (*hashlen) __P((void));
132 	vchar_t *(*one) __P((vchar_t *, vchar_t *));
133 };
134 
135 struct hash_algorithm {
136 	char *name;
137 	int type;
138 	int doi;
139 	caddr_t (*init) __P((void));
140 	void (*update) __P((caddr_t, vchar_t *));
141 	vchar_t *(*final) __P((caddr_t));
142 	int (*hashlen) __P((void));
143 	vchar_t *(*one) __P((vchar_t *));
144 };
145 
146 struct enc_algorithm {
147 	char *name;
148 	int type;
149 	int doi;
150 	int blocklen;
151 	vchar_t *(*encrypt) __P((vchar_t *, vchar_t *, vchar_t *));
152 	vchar_t *(*decrypt) __P((vchar_t *, vchar_t *, vchar_t *));
153 	int (*weakkey) __P((vchar_t *));
154 	int (*keylen) __P((int));
155 };
156 
157 /* dh group */
158 struct dh_algorithm {
159 	char *name;
160 	int type;
161 	int doi;
162 	struct dhgroup *dhgroup;
163 };
164 
165 /* ipcomp, auth meth, dh group */
166 struct misc_algorithm {
167 	char *name;
168 	int type;
169 	int doi;
170 };
171 
172 extern int alg_oakley_hashdef_ok __P((int));
173 extern int alg_oakley_hashdef_doi __P((int));
174 extern int alg_oakley_hashdef_hashlen __P((int));
175 extern vchar_t *alg_oakley_hashdef_one __P((int, vchar_t *));
176 
177 extern int alg_oakley_hmacdef_doi __P((int));
178 extern vchar_t *alg_oakley_hmacdef_one __P((int, vchar_t *, vchar_t *));
179 
180 extern int alg_oakley_encdef_ok __P((int));
181 extern int alg_oakley_encdef_doi __P((int));
182 extern int alg_oakley_encdef_keylen __P((int, int));
183 extern int alg_oakley_encdef_blocklen __P((int));
184 extern vchar_t *alg_oakley_encdef_decrypt __P((int, vchar_t *, vchar_t *, vchar_t *));
185 extern vchar_t *alg_oakley_encdef_encrypt __P((int, vchar_t *, vchar_t *, vchar_t *));
186 
187 extern int alg_ipsec_encdef_doi __P((int));
188 extern int alg_ipsec_encdef_keylen __P((int, int));
189 
190 extern int alg_ipsec_hmacdef_doi __P((int));
191 extern int alg_ipsec_hmacdef_hashlen __P((int));
192 
193 extern int alg_ipsec_compdef_doi __P((int));
194 
195 extern int alg_oakley_dhdef_doi __P((int));
196 extern int alg_oakley_dhdef_ok __P((int));
197 extern struct dhgroup *alg_oakley_dhdef_group __P((int));
198 
199 extern int alg_oakley_authdef_doi __P((int));
200 
201 extern int default_keylen __P((int, int));
202 extern int check_keylen __P((int, int, int));
203 extern int algtype2doi __P((int, int));
204 extern int algclass2doi __P((int));
205 
206 extern const char *alg_oakley_encdef_name __P((int));
207 extern const char *alg_oakley_hashdef_name __P((int));
208 extern const char *alg_oakley_dhdef_name __P((int));
209 extern const char *alg_oakley_authdef_name __P((int));
210 
211 #endif /* _ALGORITHM_H */
212