ssl_util.c revision 421d9002d73db52972bcca8f4497fe5d603b6b8e
/* _ _
** _ __ ___ ___ __| | ___ ___| | mod_ssl
** | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
** | | | | | | (_) | (_| | \__ \__ \ | www.modssl.org
** |_| |_| |_|\___/ \__,_|___|___/___/_| ftp.modssl.org
** |_____|
** ssl_util.c
** Utility Functions
*/
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``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 THE APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*/
/* ``Every day of my life
I am forced to add another
name to the list of people
who piss me off!''
-- Calvin */
#include "mod_ssl.h"
#include "ap_mpm.h"
/* _________________________________________________________________
**
** Utility Functions
** _________________________________________________________________
*/
{
char *id;
char *host;
host = s->server_hostname;
if (s->port != 0)
else {
sc = mySrvConfig(s);
else
}
return id;
}
void ssl_util_strupper(char *s)
{
for (; *s; ++s)
*s = apr_toupper(*s);
return;
}
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
{
ssl_util_uuencode_binary((unsigned char *)szTo,
(const unsigned char *)szFrom,
}
void ssl_util_uuencode_binary(unsigned char *szTo,
const unsigned char *szFrom,
{
const unsigned char *s;
int nPad = 0;
if (--nLength == 0) {
nPad = 2;
break;
}
if (--nLength == 0) {
nPad = 1;
break;
}
--nLength;
}
}
return;
}
{
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
}
{
return;
}
/*
* Run a filter program and read the first line of its stdout output
*/
{
static char buf[MAX_STRING_LEN];
apr_file_t *fp;
char c;
int k;
return NULL;
if (c == '\n' || c == '\r')
break;
buf[k++] = c;
}
ssl_util_ppclose(s, p, fp);
return buf;
}
{
return FALSE;
APR_FINFO_TYPE|APR_FINFO_SIZE, p) != 0)
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
}
{
ssl_algo_t t;
t = SSL_ALGO_UNKNOWN;
case EVP_PKEY_RSA:
t = SSL_ALGO_RSA;
break;
case EVP_PKEY_DSA:
t = SSL_ALGO_DSA;
break;
default:
break;
}
}
return t;
}
char *ssl_util_algotypestr(ssl_algo_t t)
{
char *cp;
cp = "UNKNOWN";
switch (t) {
case SSL_ALGO_RSA:
cp = "RSA";
break;
case SSL_ALGO_DSA:
cp = "DSA";
break;
default:
break;
}
return cp;
}
{
#define MAX_PTXTSUB 100
char *cppMatch[MAX_PTXTSUB];
char *cpResult;
int nResult;
int nLine;
int nSubst;
int nMatch;
char *cpI;
char *cpO;
char *cp;
int i;
/*
* Pass 1: find substitution locations and calculate sizes
*/
}
else {
break;
}
}
if (i == 0)
return NULL;
/*
* Pass 2: allocate memory and assemble result
*/
i++) {
}
return cpResult;
}
{
}
{
!= APR_SUCCESS) {
ssl_log(s, SSL_LOG_TRACE,
"Unable to retrieve SSLModConfig from global pool");
}
return mc;
}
{
if (c != NULL)
return mc;
}
/*
* To ensure thread-safetyness in OpenSSL - work in progress
*/
static long lock_count[CRYPTO_NUM_LOCKS];
{
if (mode & CRYPTO_LOCK) {
lock_count[type]++;
}
else {
}
}
#if APR_HAS_THREADS
static unsigned long ssl_util_thr_id(void)
{
return (unsigned long) apr_os_thread_current();
}
#endif
{
int i;
for (i = 0; i < CRYPTO_NUM_LOCKS; i++) {
apr_lock_destroy(lock_cs[i]);
}
return APR_SUCCESS;
}
{
int i, threaded_mpm;
if (!threaded_mpm) {
return;
}
/*
* XXX: CRYPTO_NUM_LOCKS == 28
* should determine if there are lock types we do not need
* for example: debug_malloc, debug_malloc2 (see crypto/cryptlib.c)
*/
for (i = 0; i < CRYPTO_NUM_LOCKS; i++) {
lock_count[i]=0;
mc->szMutexFile, p);
}
#if APR_HAS_THREADS
#endif
}