/* -*- Mode: C; c-file-style: "bsd" -*- */
/*-
* easy-tls.c -- generic TLS proxy.
* $Id: easy-tls.c,v 1.4 2002/03/05 09:07:16 bodo Exp $
*/
/*-
(c) Copyright 1999 Bodo Moeller. All rights reserved.
This is free software; you can redistributed and/or modify it
unter the terms of either
- the GNU General Public License as published by the
Free Software Foundation, version 1, or (at your option)
any later version,
or
- the following license:
*/
/*-
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that each of the following
* conditions is met:
*
* 1. Redistributions qualify as "freeware" or "Open Source Software" under
* one of the following terms:
*
* (a) Redistributions are made at no charge beyond the reasonable cost of
* materials and delivery.
*
* (b) Redistributions are accompanied by a copy of the Source Code
* or by an irrevocable offer to provide a copy of the Source Code
* for up to three years at the cost of materials and delivery.
* Such redistributions must allow further use, modification, and
* redistribution of the Source Code under substantially the same
* terms as this license.
*
* 2. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 3. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 4. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by Bodo Moeller."
* (If available, substitute umlauted o for oe.)
*
* 5. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by Bodo Moeller."
*
* THIS SOFTWARE IS PROVIDED BY BODO MOELLER ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BODO MOELLER OR
* HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Attribution for OpenSSL library:
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
* This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)
*/
static char const rcsid[] =
"$Id: easy-tls.c,v 1.4 2002/03/05 09:07:16 bodo Exp $";
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <openssl/crypto.h>
#include <openssl/dh.h>
#include <openssl/dsa.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/opensslv.h>
#include <openssl/pem.h>
#include <openssl/rand.h>
#ifndef NO_RSA
# include <openssl/rsa.h>
#endif
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#if OPENSSL_VERSION_NUMBER < 0x00904000L /* 0.9.4-dev */
# error "This program needs OpenSSL 0.9.4 or later."
#endif
#include "easy-tls.h" /* include after <openssl/ssl.h> if both are
* needed */
#if TLS_INFO_SIZE > PIPE_BUF
# if PIPE_BUF < 512
# error "PIPE_BUF < 512" /* non-POSIX */
# endif
# error "TLS_INFO_SIZE > PIPE_BUF"
#endif
/*****************************************************************************/
#ifdef TLS_APP
# include TLS_APP
#endif
/*-
* Applications can define:
* TLS_APP_PROCESS_INIT -- void ...(int fd, int client_p, void *apparg)