155714Skris/* apps/s_apps.h */
255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
355714Skris * All rights reserved.
455714Skris *
555714Skris * This package is an SSL implementation written
655714Skris * by Eric Young (eay@cryptsoft.com).
755714Skris * The implementation was written so as to conform with Netscapes SSL.
8296465Sdelphij *
955714Skris * This library is free for commercial and non-commercial use as long as
1055714Skris * the following conditions are aheared to.  The following conditions
1155714Skris * apply to all code found in this distribution, be it the RC4, RSA,
1255714Skris * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1355714Skris * included with this distribution is covered by the same copyright terms
1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15296465Sdelphij *
1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in
1755714Skris * the code are not to be removed.
1855714Skris * If this package is used in a product, Eric Young should be given attribution
1955714Skris * as the author of the parts of the library used.
2055714Skris * This can be in the form of a textual message at program startup or
2155714Skris * in documentation (online or textual) provided with the package.
22296465Sdelphij *
2355714Skris * Redistribution and use in source and binary forms, with or without
2455714Skris * modification, are permitted provided that the following conditions
2555714Skris * are met:
2655714Skris * 1. Redistributions of source code must retain the copyright
2755714Skris *    notice, this list of conditions and the following disclaimer.
2855714Skris * 2. Redistributions in binary form must reproduce the above copyright
2955714Skris *    notice, this list of conditions and the following disclaimer in the
3055714Skris *    documentation and/or other materials provided with the distribution.
3155714Skris * 3. All advertising materials mentioning features or use of this software
3255714Skris *    must display the following acknowledgement:
3355714Skris *    "This product includes cryptographic software written by
3455714Skris *     Eric Young (eay@cryptsoft.com)"
3555714Skris *    The word 'cryptographic' can be left out if the rouines from the library
3655714Skris *    being used are not cryptographic related :-).
37296465Sdelphij * 4. If you include any Windows specific code (or a derivative thereof) from
3855714Skris *    the apps directory (application code) you must include an acknowledgement:
3955714Skris *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40296465Sdelphij *
4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4455714Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5155714Skris * SUCH DAMAGE.
52296465Sdelphij *
5355714Skris * The licence and distribution terms for any publically available version or
5455714Skris * derivative of this code cannot be changed.  i.e. this code cannot simply be
5555714Skris * copied and put under another distribution licence
5655714Skris * [including the GNU Public Licence.]
5755714Skris */
58109998Smarkm/* ====================================================================
59109998Smarkm * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
60109998Smarkm *
61109998Smarkm * Redistribution and use in source and binary forms, with or without
62109998Smarkm * modification, are permitted provided that the following conditions
63109998Smarkm * are met:
64109998Smarkm *
65109998Smarkm * 1. Redistributions of source code must retain the above copyright
66296465Sdelphij *    notice, this list of conditions and the following disclaimer.
67109998Smarkm *
68109998Smarkm * 2. Redistributions in binary form must reproduce the above copyright
69109998Smarkm *    notice, this list of conditions and the following disclaimer in
70109998Smarkm *    the documentation and/or other materials provided with the
71109998Smarkm *    distribution.
72109998Smarkm *
73109998Smarkm * 3. All advertising materials mentioning features or use of this
74109998Smarkm *    software must display the following acknowledgment:
75109998Smarkm *    "This product includes software developed by the OpenSSL Project
76109998Smarkm *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77109998Smarkm *
78109998Smarkm * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79109998Smarkm *    endorse or promote products derived from this software without
80109998Smarkm *    prior written permission. For written permission, please contact
81109998Smarkm *    openssl-core@openssl.org.
82109998Smarkm *
83109998Smarkm * 5. Products derived from this software may not be called "OpenSSL"
84109998Smarkm *    nor may "OpenSSL" appear in their names without prior written
85109998Smarkm *    permission of the OpenSSL Project.
86109998Smarkm *
87109998Smarkm * 6. Redistributions of any form whatsoever must retain the following
88109998Smarkm *    acknowledgment:
89109998Smarkm *    "This product includes software developed by the OpenSSL Project
90109998Smarkm *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91109998Smarkm *
92109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93109998Smarkm * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95109998Smarkm * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96109998Smarkm * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97109998Smarkm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98109998Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99109998Smarkm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101109998Smarkm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102109998Smarkm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103109998Smarkm * OF THE POSSIBILITY OF SUCH DAMAGE.
104109998Smarkm * ====================================================================
105109998Smarkm *
106109998Smarkm * This product includes cryptographic software written by Eric Young
107109998Smarkm * (eay@cryptsoft.com).  This product includes software written by Tim
108109998Smarkm * Hudson (tjh@cryptsoft.com).
109109998Smarkm *
110109998Smarkm */
111296465Sdelphij/* conflicts with winsock2 stuff on netware */
112296465Sdelphij#if !defined(OPENSSL_SYS_NETWARE)
113296465Sdelphij# include <sys/types.h>
114160814Ssimon#endif
115109998Smarkm#include <openssl/opensslconf.h>
116109998Smarkm
117120631Snectar#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
118296465Sdelphij# include <conio.h>
119120631Snectar#endif
120120631Snectar
121120631Snectar#ifdef OPENSSL_SYS_MSDOS
122296465Sdelphij# define _kbhit kbhit
123120631Snectar#endif
124120631Snectar
125109998Smarkm#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET)
126296465Sdelphij/*
127296465Sdelphij * VAX C does not defined fd_set and friends, but it's actually quite simple
128296465Sdelphij */
129296465Sdelphij/* These definitions are borrowed from SOCKETSHR.       /Richard Levitte */
130296465Sdelphij# define MAX_NOFILE      32
131296465Sdelphij# define NBBY             8     /* number of bits in a byte */
13255714Skris
133296465Sdelphij# ifndef FD_SETSIZE
134296465Sdelphij#  define FD_SETSIZE      MAX_NOFILE
135296465Sdelphij# endif                         /* FD_SETSIZE */
13655714Skris
13755714Skris/* How many things we'll allow select to use. 0 if unlimited */
138296465Sdelphij# define MAXSELFD        MAX_NOFILE
139296465Sdelphijtypedef int fd_mask;            /* int here! VMS prototypes int, not long */
140296465Sdelphij# define NFDBITS (sizeof(fd_mask) * NBBY)/* bits per mask (power of 2!) */
141296465Sdelphij# define NFDSHIFT 5             /* Shift based on above */
14255714Skris
14355714Skristypedef fd_mask fd_set;
144296465Sdelphij# define FD_SET(n, p)    (*(p) |= (1 << ((n) % NFDBITS)))
145296465Sdelphij# define FD_CLR(n, p)    (*(p) &= ~(1 << ((n) % NFDBITS)))
146296465Sdelphij# define FD_ISSET(n, p)  (*(p) & (1 << ((n) % NFDBITS)))
147296465Sdelphij# define FD_ZERO(p)      memset((char *)(p), 0, sizeof(*(p)))
14855714Skris#endif
14955714Skris
15055714Skris#define PORT            4433
15155714Skris#define PORT_STR        "4433"
15255714Skris#define PROTOCOL        "tcp"
15355714Skris
154296465Sdelphijint do_server(int port, int type, int *ret,
155296465Sdelphij              int (*cb) (char *hostname, int s, unsigned char *context),
156296465Sdelphij              unsigned char *context);
15755714Skris#ifdef HEADER_X509_H
15855714Skrisint MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
15955714Skris#endif
16055714Skris#ifdef HEADER_SSL_H
16155714Skrisint set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
162160814Ssimonint set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key);
16355714Skris#endif
164160814Ssimonint init_client(int *sock, char *server, int port, int type);
16555714Skrisint should_retry(int i);
16655714Skrisint extract_port(char *str, short *port_ptr);
167296465Sdelphijint extract_host_port(char *str, char **host_ptr, unsigned char *ip,
168296465Sdelphij                      short *p);
16955714Skris
170160814Ssimonlong MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp,
171296465Sdelphij                                   int argi, long argl, long ret);
17255714Skris
17355714Skris#ifdef HEADER_SSL_H
174109998Smarkmvoid MS_CALLBACK apps_ssl_info_callback(const SSL *s, int where, int ret);
175296465Sdelphijvoid MS_CALLBACK msg_cb(int write_p, int version, int content_type,
176296465Sdelphij                        const void *buf, size_t len, SSL *ssl, void *arg);
177194206Ssimonvoid MS_CALLBACK tlsext_cb(SSL *s, int client_server, int type,
178296465Sdelphij                           unsigned char *data, int len, void *arg);
17955714Skris#endif
180205128Ssimon
181296465Sdelphijint MS_CALLBACK generate_cookie_callback(SSL *ssl, unsigned char *cookie,
182296465Sdelphij                                         unsigned int *cookie_len);
183296465Sdelphijint MS_CALLBACK verify_cookie_callback(SSL *ssl, unsigned char *cookie,
184296465Sdelphij                                       unsigned int cookie_len);
185