ssl_util.c revision b40799adcfd0f0a2a465c2934585986f7bbc9bbc
/* _ _
** _ __ ___ ___ __| | ___ ___| | 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-2003 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"
#include "apr_thread_mutex.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;
}
const char * const *argv)
{
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
*/
const char * const *argv)
{
static char buf[MAX_STRING_LEN];
apr_file_t *fp;
char c;
int k;
return NULL;
/* XXX: we are reading 1 byte at a time here */
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;
switch (EVP_PKEY_key_type(pKey)) {
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;
}
/*
* certain key and cert data needs to survive restarts,
* which are stored in the user data table of s->process->pool.
* rather than apr_palloc and these wrappers to help make sure
* we do not leak the malloc-ed data.
*/
const char *key,
long int length)
{
/*
* if a value for this key already exists,
* reuse as much of the already malloc-ed data
* as possible.
*/
if (asn1) {
}
}
else {
}
}
}
const char *key)
{
}
const char *key)
{
if (!asn1) {
return;
}
}
}
const char *ssl_asn1_keystr(int keytype)
{
if (keytype >= SSL_AIDX_MAX) {
return NULL;
}
return ssl_asn1_key_types[keytype];
}
const char *ssl_asn1_table_keyfmt(apr_pool_t *p,
const char *id,
int keytype)
{
}
#if APR_HAS_THREADS
/*
* To ensure thread-safetyness in OpenSSL - work in progress
*/
static apr_thread_mutex_t **lock_cs;
static int lock_num_locks;
#ifdef SSLC_VERSION_NUMBER
#if SSLC_VERSION_NUMBER >= 0x2000
#else
#endif
#else
#endif
{
if (type < lock_num_locks) {
if (mode & CRYPTO_LOCK) {
}
else {
}
#ifdef HAVE_SSLC
#if SSLC_VERSION_NUMBER > 0x2000
return 1;
}
else {
return -1;
#endif
#endif
}
}
static unsigned long ssl_util_thr_id(void)
{
/* OpenSSL needs this to return an unsigned long. On OS/390, the pthread
* id is a structure twice that big. Use the TCB pointer instead as a
* unique unsigned long.
*/
#ifdef __MVS__
struct PSA {
char unmapped[540];
unsigned long PSATOLD;
} *psaptr = 0;
#else
return (unsigned long) apr_os_thread_current();
#endif
}
{
/* Let the registered mutex cleanups do their own thing
*/
return APR_SUCCESS;
}
void ssl_util_thread_setup(apr_pool_t *p)
{
int i;
for (i = 0; i < lock_num_locks; i++) {
}
}
#endif