xref: /netbsd-src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.h (revision f81322cf185a4db50f71fcf7701f20198272620e)
1 /*	$NetBSD: crypto_openssl.h,v 1.3 2005/11/21 14:20:29 manu Exp $	*/
2 
3 /* Id: crypto_openssl.h,v 1.11 2004/11/13 11:28:01 manubsd 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 _CRYPTO_OPENSSL_H
35 #define _CRYPTO_OPENSSL_H
36 
37 #include "crypto_openssl.h"
38 
39 #include <openssl/x509v3.h>
40 #include <openssl/rsa.h>
41 
42 #define GENT_OTHERNAME	GEN_OTHERNAME
43 #define GENT_EMAIL	GEN_EMAIL
44 #define GENT_DNS	GEN_DNS
45 #define GENT_X400	GEN_X400
46 #define GENT_DIRNAME	GEN_DIRNAME
47 #define GENT_EDIPARTY	GEN_EDIPARTY
48 #define GENT_URI	GEN_URI
49 #define GENT_IPADD	GEN_IPADD
50 #define GENT_RID	GEN_RID
51 
52 extern vchar_t *eay_str2asn1dn __P((const char *, int));
53 extern vchar_t *eay_hex2asn1dn __P((const char *, int));
54 extern int eay_cmp_asn1dn __P((vchar_t *, vchar_t *));
55 extern int eay_check_x509cert __P((vchar_t *, char *, char *, int));
56 extern vchar_t *eay_get_x509asn1subjectname __P((vchar_t *));
57 extern int eay_get_x509subjectaltname __P((vchar_t *, char **, int *, int));
58 extern char *eay_get_x509text __P((vchar_t *));
59 extern vchar_t *eay_get_x509cert __P((char *));
60 extern vchar_t *eay_get_x509sign __P((vchar_t *, vchar_t *));
61 extern int eay_check_x509sign __P((vchar_t *, vchar_t *, vchar_t *));
62 
63 extern int eay_check_rsasign __P((vchar_t *, vchar_t *, RSA *));
64 extern vchar_t *eay_get_rsasign __P((vchar_t *, RSA *));
65 
66 /* RSA */
67 extern vchar_t *eay_rsa_sign __P((vchar_t *, RSA *));
68 extern int eay_rsa_verify __P((vchar_t *, vchar_t *, RSA *));
69 
70 /* ASN.1 */
71 extern vchar_t *eay_get_pkcs1privkey __P((char *));
72 extern vchar_t *eay_get_pkcs1pubkey __P((char *));
73 
74 /* string error */
75 extern char *eay_strerror __P((void));
76 
77 /* OpenSSL initialization */
78 extern void eay_init __P((void));
79 
80 /* Generic EVP */
81 extern vchar_t *evp_crypt __P((vchar_t *data, vchar_t *key, vchar_t *iv,
82 			       const EVP_CIPHER *e, int enc));
83 extern int evp_weakkey __P((vchar_t *key, const EVP_CIPHER *e));
84 extern int evp_keylen __P((int len, const EVP_CIPHER *e));
85 
86 /* DES */
87 extern vchar_t *eay_des_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
88 extern vchar_t *eay_des_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
89 extern int eay_des_weakkey __P((vchar_t *));
90 extern int eay_des_keylen __P((int));
91 
92 /* IDEA */
93 extern vchar_t *eay_idea_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
94 extern vchar_t *eay_idea_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
95 extern int eay_idea_weakkey __P((vchar_t *));
96 extern int eay_idea_keylen __P((int));
97 
98 /* blowfish */
99 extern vchar_t *eay_bf_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
100 extern vchar_t *eay_bf_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
101 extern int eay_bf_weakkey __P((vchar_t *));
102 extern int eay_bf_keylen __P((int));
103 
104 /* RC5 */
105 extern vchar_t *eay_rc5_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
106 extern vchar_t *eay_rc5_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
107 extern int eay_rc5_weakkey __P((vchar_t *));
108 extern int eay_rc5_keylen __P((int));
109 
110 /* 3DES */
111 extern vchar_t *eay_3des_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
112 extern vchar_t *eay_3des_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
113 extern int eay_3des_weakkey __P((vchar_t *));
114 extern int eay_3des_keylen __P((int));
115 
116 /* CAST */
117 extern vchar_t *eay_cast_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
118 extern vchar_t *eay_cast_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
119 extern int eay_cast_weakkey __P((vchar_t *));
120 extern int eay_cast_keylen __P((int));
121 
122 /* AES(RIJNDAEL) */
123 extern vchar_t *eay_aes_encrypt __P((vchar_t *, vchar_t *, vchar_t *));
124 extern vchar_t *eay_aes_decrypt __P((vchar_t *, vchar_t *, vchar_t *));
125 extern int eay_aes_weakkey __P((vchar_t *));
126 extern int eay_aes_keylen __P((int));
127 
128 /* misc */
129 extern int eay_null_keylen __P((int));
130 extern int eay_null_hashlen __P((void));
131 extern int eay_kpdk_hashlen __P((void));
132 extern int eay_twofish_keylen __P((int));
133 
134 /* hash */
135 #if defined(WITH_SHA2)
136 /* HMAC SHA2 */
137 extern vchar_t *eay_hmacsha2_512_one __P((vchar_t *, vchar_t *));
138 extern caddr_t eay_hmacsha2_512_init __P((vchar_t *));
139 extern void eay_hmacsha2_512_update __P((caddr_t, vchar_t *));
140 extern vchar_t *eay_hmacsha2_512_final __P((caddr_t));
141 extern vchar_t *eay_hmacsha2_384_one __P((vchar_t *, vchar_t *));
142 extern caddr_t eay_hmacsha2_384_init __P((vchar_t *));
143 extern void eay_hmacsha2_384_update __P((caddr_t, vchar_t *));
144 extern vchar_t *eay_hmacsha2_384_final __P((caddr_t));
145 extern vchar_t *eay_hmacsha2_256_one __P((vchar_t *, vchar_t *));
146 extern caddr_t eay_hmacsha2_256_init __P((vchar_t *));
147 extern void eay_hmacsha2_256_update __P((caddr_t, vchar_t *));
148 extern vchar_t *eay_hmacsha2_256_final __P((caddr_t));
149 #endif
150 /* HMAC SHA1 */
151 extern vchar_t *eay_hmacsha1_one __P((vchar_t *, vchar_t *));
152 extern caddr_t eay_hmacsha1_init __P((vchar_t *));
153 extern void eay_hmacsha1_update __P((caddr_t, vchar_t *));
154 extern vchar_t *eay_hmacsha1_final __P((caddr_t));
155 /* HMAC MD5 */
156 extern vchar_t *eay_hmacmd5_one __P((vchar_t *, vchar_t *));
157 extern caddr_t eay_hmacmd5_init __P((vchar_t *));
158 extern void eay_hmacmd5_update __P((caddr_t, vchar_t *));
159 extern vchar_t *eay_hmacmd5_final __P((caddr_t));
160 
161 #if defined(WITH_SHA2)
162 /* SHA2 functions */
163 extern caddr_t eay_sha2_512_init __P((void));
164 extern void eay_sha2_512_update __P((caddr_t, vchar_t *));
165 extern vchar_t *eay_sha2_512_final __P((caddr_t));
166 extern vchar_t *eay_sha2_512_one __P((vchar_t *));
167 #endif
168 extern int eay_sha2_512_hashlen __P((void));
169 
170 #if defined(WITH_SHA2)
171 extern caddr_t eay_sha2_384_init __P((void));
172 extern void eay_sha2_384_update __P((caddr_t, vchar_t *));
173 extern vchar_t *eay_sha2_384_final __P((caddr_t));
174 extern vchar_t *eay_sha2_384_one __P((vchar_t *));
175 #endif
176 extern int eay_sha2_384_hashlen __P((void));
177 
178 #if defined(WITH_SHA2)
179 extern caddr_t eay_sha2_256_init __P((void));
180 extern void eay_sha2_256_update __P((caddr_t, vchar_t *));
181 extern vchar_t *eay_sha2_256_final __P((caddr_t));
182 extern vchar_t *eay_sha2_256_one __P((vchar_t *));
183 #endif
184 extern int eay_sha2_256_hashlen __P((void));
185 
186 /* SHA functions */
187 extern caddr_t eay_sha1_init __P((void));
188 extern void eay_sha1_update __P((caddr_t, vchar_t *));
189 extern vchar_t *eay_sha1_final __P((caddr_t));
190 extern vchar_t *eay_sha1_one __P((vchar_t *));
191 extern int eay_sha1_hashlen __P((void));
192 
193 /* MD5 functions */
194 extern caddr_t eay_md5_init __P((void));
195 extern void eay_md5_update __P((caddr_t, vchar_t *));
196 extern vchar_t *eay_md5_final __P((caddr_t));
197 extern vchar_t *eay_md5_one __P((vchar_t *));
198 extern int eay_md5_hashlen __P((void));
199 
200 /* RNG */
201 extern vchar_t *eay_set_random __P((u_int32_t));
202 extern u_int32_t eay_random __P((void));
203 
204 /* DH */
205 extern int eay_dh_generate __P((vchar_t *, u_int32_t, u_int, vchar_t **, vchar_t **));
206 extern int eay_dh_compute __P((vchar_t *, u_int32_t, vchar_t *, vchar_t *, vchar_t *, vchar_t **));
207 
208 /* Base 64 */
209 vchar_t *base64_encode(char *in, long inlen);
210 vchar_t *base64_decode(char *in, long inlen);
211 
212 RSA *base64_pubkey2rsa(char *in);
213 RSA *bignum_pubkey2rsa(BIGNUM *in);
214 
215 /* misc */
216 extern int eay_revbnl __P((vchar_t *));
217 #include <openssl/bn.h>
218 extern int eay_v2bn __P((BIGNUM **, vchar_t *));
219 extern int eay_bn2v __P((vchar_t **, BIGNUM *));
220 
221 extern const char *eay_version __P((void));
222 
223 #define CBC_BLOCKLEN 8
224 #define IPSEC_ENCRYPTKEYLEN 8
225 
226 #endif /* _CRYPTO_OPENSSL_H */
227