1 /*                      _             _
2 **  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
3 ** | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
4 ** | | | | | | (_) | (_| |   \__ \__ \ |  www.modssl.org
5 ** |_| |_| |_|\___/ \__,_|___|___/___/_|  ftp.modssl.org
6 **                      |_____|
7 **  ssl_util_ssl.h
8 **  Additional Utility Functions for OpenSSL
9 */
10 
11 /* ====================================================================
12  * Copyright (c) 1998-2003 Ralf S. Engelschall. All rights reserved.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  *
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  *
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following
23  *    disclaimer in the documentation and/or other materials
24  *    provided with the distribution.
25  *
26  * 3. All advertising materials mentioning features or use of this
27  *    software must display the following acknowledgment:
28  *    "This product includes software developed by
29  *     Ralf S. Engelschall <rse@engelschall.com> for use in the
30  *     mod_ssl project (http://www.modssl.org/)."
31  *
32  * 4. The names "mod_ssl" must not be used to endorse or promote
33  *    products derived from this software without prior written
34  *    permission. For written permission, please contact
35  *    rse@engelschall.com.
36  *
37  * 5. Products derived from this software may not be called "mod_ssl"
38  *    nor may "mod_ssl" appear in their names without prior
39  *    written permission of Ralf S. Engelschall.
40  *
41  * 6. Redistributions of any form whatsoever must retain the following
42  *    acknowledgment:
43  *    "This product includes software developed by
44  *     Ralf S. Engelschall <rse@engelschall.com> for use in the
45  *     mod_ssl project (http://www.modssl.org/)."
46  *
47  * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
48  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL RALF S. ENGELSCHALL OR
51  * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58  * OF THE POSSIBILITY OF SUCH DAMAGE.
59  * ====================================================================
60  */
61 
62 #ifndef SSL_UTIL_SSL_H
63 #define SSL_UTIL_SSL_H
64 
65 /*
66  * Determine SSL library version number
67  */
68 #ifdef OPENSSL_VERSION_NUMBER
69 #define SSL_LIBRARY_VERSION OPENSSL_VERSION_NUMBER
70 #define SSL_LIBRARY_NAME    "OpenSSL"
71 #define SSL_LIBRARY_TEXT    OPENSSL_VERSION_TEXT
72 #else
73 #define SSL_LIBRARY_VERSION 0x0000
74 #define SSL_LIBRARY_NAME    "OtherSSL"
75 #define SSL_LIBRARY_TEXT    "OtherSSL 0.0.0 00 XXX 0000"
76 #endif
77 
78 /*
79  * Support for retrieving/overriding states
80  */
81 #ifndef SSL_get_state
82 #define SSL_get_state(ssl) SSL_state(ssl)
83 #endif
84 #define SSL_set_state(ssl,val) (ssl)->state = val
85 
86 /*
87  * Backward compatibility.
88  */
89 #if SSL_LIBRARY_VERSION < 0x00906100
90 #define OPENSSL_free free
91 #endif
92 
93 /*
94  *  Maximum length of a DER encoded session.
95  *  FIXME: There is no define in OpenSSL, but OpenSSL uses 1024*10,
96  *         so this value should be ok. Although we have no warm feeling.
97  */
98 #define SSL_SESSION_MAX_DER 1024*10
99 
100 /*
101  *  Additional Functions
102  */
103 int         SSL_get_app_data2_idx(void);
104 void       *SSL_get_app_data2(SSL *);
105 void        SSL_set_app_data2(SSL *, void *);
106 X509       *SSL_read_X509(FILE *, X509 **, int (*)());
107 EVP_PKEY   *SSL_read_PrivateKey(FILE *, EVP_PKEY **, int (*)());
108 int         SSL_smart_shutdown(SSL *ssl);
109 X509_STORE *SSL_X509_STORE_create(char *, char *);
110 int         SSL_X509_STORE_lookup(X509_STORE *, int, X509_NAME *, X509_OBJECT *);
111 char       *SSL_make_ciphersuite(pool *, SSL *);
112 BOOL        SSL_X509_isSGC(X509 *);
113 BOOL        SSL_X509_getBC(X509 *, int *, int *);
114 BOOL        SSL_X509_getCN(pool *, X509 *, char **);
115 #ifdef SSL_EXPERIMENTAL_PROXY
116 BOOL        SSL_load_CrtAndKeyInfo_file(pool *, STACK_OF(X509_INFO) *, char *);
117 BOOL        SSL_load_CrtAndKeyInfo_path(pool *, STACK_OF(X509_INFO) *, char *);
118 #endif /* SSL_EXPERIMENTAL_PROXY */
119 int         SSL_CTX_use_certificate_chain(SSL_CTX *, char *, int, int (*)());
120 char       *SSL_SESSION_id2sz(unsigned char *, int);
121 
122 #endif /* SSL_UTIL_SSL_H */
123