upload apache
[bottlenecks.git] / rubbos / app / apache2 / include / ssl_util_ssl.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*                      _             _
18  *  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
19  * | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
20  * | | | | | | (_) | (_| |   \__ \__ \ |
21  * |_| |_| |_|\___/ \__,_|___|___/___/_|
22  *                      |_____|
23  *  ssl_util_ssl.h
24  *  Additional Utility Functions for OpenSSL
25  */
26
27 #ifndef __SSL_UTIL_SSL_H__
28 #define __SSL_UTIL_SSL_H__
29
30 /*
31  * Determine SSL library version number
32  */
33 #define SSL_NIBBLE(x,n) ((x >> (n * 4)) & 0xF)
34
35 #ifdef OPENSSL_VERSION_NUMBER
36 #define SSL_LIBRARY_VERSION OPENSSL_VERSION_NUMBER
37 #define SSL_LIBRARY_NAME    "OpenSSL"
38 #define SSL_LIBRARY_TEXT    OPENSSL_VERSION_TEXT
39 #define SSL_LIBRARY_DYNTEXT SSLeay_version(SSLEAY_VERSION)
40 #elif defined(SSLC_VERSION_NUMBER)
41 #define SSL_LIBRARY_VERSION SSLC_VERSION_NUMBER
42 #define SSL_LIBRARY_NAME    "SSL-C"
43 #define SSL_LIBRARY_TEXT    { 'S', 'S', 'L', '-', 'C', ' ', \
44                               '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,3), '.', \
45                               '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,2), '.', \
46                               '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,1), '.', \
47                               '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,0), 0 }
48 #define SSL_LIBRARY_DYNTEXT SSLC_library_info(SSLC_INFO_VERSION)
49 #elif !defined(SSL_LIBRARY_VERSION)
50 #define SSL_LIBRARY_VERSION 0x0000
51 #define SSL_LIBRARY_NAME    "OtherSSL"
52 #define SSL_LIBRARY_TEXT    "OtherSSL 0.0.0 00 XXX 0000"
53 #define SSL_LIBRARY_DYNTEXT "OtherSSL 0.0.0 00 XXX 0000"
54 #endif
55
56 /*
57  *  Maximum length of a DER encoded session.
58  *  FIXME: There is no define in OpenSSL, but OpenSSL uses 1024*10,
59  *         so this value should be ok. Although we have no warm feeling.
60  */
61 #define SSL_SESSION_MAX_DER 1024*10
62
63 /* max length for SSL_SESSION_id2sz */
64 #define SSL_SESSION_ID_STRING_LEN \
65     ((SSL_MAX_SSL_SESSION_ID_LENGTH + 1) * 2)
66
67 /*  
68  *  Additional Functions
69  */
70 void        SSL_init_app_data2_idx(void);
71 void       *SSL_get_app_data2(SSL *);
72 void        SSL_set_app_data2(SSL *, void *);
73 X509       *SSL_read_X509(char *, X509 **, modssl_read_bio_cb_fn *);
74 EVP_PKEY   *SSL_read_PrivateKey(char *, EVP_PKEY **, modssl_read_bio_cb_fn *, void *);
75 int         SSL_smart_shutdown(SSL *ssl);
76 X509_STORE *SSL_X509_STORE_create(char *, char *);
77 int         SSL_X509_STORE_lookup(X509_STORE *, int, X509_NAME *, X509_OBJECT *);
78 char       *SSL_make_ciphersuite(apr_pool_t *, SSL *);
79 BOOL        SSL_X509_isSGC(X509 *);
80 BOOL        SSL_X509_getBC(X509 *, int *, int *);
81 BOOL        SSL_X509_getCN(apr_pool_t *, X509 *, char **);
82 BOOL        SSL_X509_INFO_load_file(apr_pool_t *, STACK_OF(X509_INFO) *, const char *);
83 BOOL        SSL_X509_INFO_load_path(apr_pool_t *, STACK_OF(X509_INFO) *, const char *);
84 int         SSL_CTX_use_certificate_chain(SSL_CTX *, char *, int, modssl_read_bio_cb_fn *);
85 char       *SSL_SESSION_id2sz(unsigned char *, int, char *, int);
86
87 /* util functions for OpenSSL+sslc compat */
88 int modssl_session_get_time(SSL_SESSION *session);
89
90 DH *modssl_dh_configure(unsigned char *p, int plen,
91                         unsigned char *g, int glen);
92
93 #endif /* __SSL_UTIL_SSL_H__ */