2 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
67 #undef DEVRANDOM /* set this to your 'random' device if you have one */
74 /********************************************************************
76 ********************************************************************/
77 /* The following is used becaue of the small stack in some
78 * Microsoft operating systems */
79 #if defined(WIN16) || defined(MSDOS)
80 # define MS_STATIC static
85 #if defined(WIN32) || defined(WIN16)
95 # define MS_CALLBACK _far _loadds
102 #if defined(WINDOWS) || defined(MSDOS)
105 #define S_IFDIR _S_IFDIR
109 #define S_IFMT _S_IFMT
112 #define strncasecmp(a,b,c) strnicmp((a),(b),(c))
115 # include <windows.h>
124 #if defined(WIN16) && (!defined(MONOLITH) || defined(SSLEAY)) && defined(_WINEXITNOPERSIST)
125 # define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); \
128 # define EXIT(n) return(n);
130 # define LIST_SEPARATOR_CHAR ';'
140 # define SSLEAY_CONF "ssleay.cnf"
141 # define NUL_DEV "nul"
142 # define RFILE ".rnd"
144 #else /* The non-microsoft world world */
147 # include <unixlib.h>
152 # define SSLEAY_CONF "ssleay.cnf"
153 # define RFILE ".rnd"
154 # define LIST_SEPARATOR_CHAR ':'
156 # define EXIT(n) exit(n); return(n)
158 # define EXIT(n) return(n)
160 # define NUL_DEV "/dev/null"
162 # define SSLeay_getpid() getpid()
169 # if defined(WINDOWS) || defined(MSDOS)
173 # define SSLeay_Write(a,b,c) (-1)
174 # define SSLeay_Read(a,b,c) (-1)
175 # define SHUTDOWN(fd) close(fd)
176 # define SHUTDOWN2(fd) close(fd)
178 # include <winsock.h>
179 extern HINSTANCE _hInstance;
180 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
181 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
182 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
183 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
192 # include <sys/types.h>
193 # include <sys/socket.h>
194 # include <sys/param.h>
195 # include <sys/time.h> /* Needed under linux for FD_XXX */
196 # include <netinet/in.h>
199 # if defined(NeXT) || defined(_NEXT_SOURCE)
200 # include <sys/fcntl.h>
201 # include <sys/types.h>
205 # include <sys/select.h>
209 # include <sys/filio.h>
211 # include <sys/ioctl.h>
218 # define SSLeay_Read(a,b,c) read((a),(b),(c))
219 # define SSLeay_Write(a,b,c) write((a),(b),(c))
220 # define SHUTDOWN(fd) { shutdown((fd),0); close((fd)); }
221 # define SHUTDOWN2(fd) { shutdown((fd),2); close((fd)); }
222 # define INVALID_SOCKET -1
226 #if defined(THREADS) || defined(sun)
232 /***********************************************/
235 #define P_CC_CC const void *,const void *
236 #define P_I_I int,int
237 #define P_I_I_P_I int,int,char *,int
238 #define P_IP_I_I_P_I int *,int,int,char *,int
252 /* do we need to do this for getenv.
253 * Just define getenv for use under windows */
256 /* How to do this needs to be thought out a bit more.... */
257 /*char *GETENV(char *);
258 #define Getenv GETENV*/
259 #define Getenv getenv
261 #define Getenv getenv
264 #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
267 #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
271 #define MD2_Init MD2Init
272 #define MD2_Update MD2Update
273 #define MD2_Final MD2Final
274 #define MD2_DIGEST_LENGTH 16
277 #define MD5_Init MD5Init
278 #define MD5_Update MD5Update
279 #define MD5_Final MD5Final
280 #define MD5_DIGEST_LENGTH 16