| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kopenssl.cc

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2001 George Staikos <staikos@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License version 2 as published by the Free Software Foundation.
    00007
    00008    This library is distributed in the hope that it will be useful,
    00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00011    Library General Public License for more details.
    00012
    00013    You should have received a copy of the GNU Library General Public License
    00014    along with this library; see the file COPYING.LIB.  If not, write to
    00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018
    00019 #include <config.h>
    00020
    00021
    00022 #ifdef KSSL_HAVE_SSL
    00023 #include <openssl/opensslv.h>
    00024 #endif
    00025
    00026 #include <kdebug.h>
    00027 #include <kconfig.h>
    00028 #include <kstaticdeleter.h>
    00029 #include <qregexp.h>
    00030
    00031
    00032 #include <stdio.h>
    00033 #include <unistd.h>
    00034 #include "kopenssl.h"
    00035
    00036 extern "C" {
    00037 #ifdef KSSL_HAVE_SSL
    00038 static int (*K_SSL_connect)     (SSL *) = NULL;
    00039 static int (*K_SSL_accept)      (SSL *) = NULL;
    00040 static int (*K_SSL_read)        (SSL *, void *, int) = NULL;
    00041 static int (*K_SSL_write)       (SSL *, const void *, int) = NULL;
    00042 static SSL *(*K_SSL_new)        (SSL_CTX *) = NULL;
    00043 static void (*K_SSL_free)       (SSL *) = NULL;
    00044 static int (*K_SSL_shutdown)    (SSL *) = NULL;
    00045 static SSL_CTX *(*K_SSL_CTX_new)(SSL_METHOD *) = NULL;
    00046 static void (*K_SSL_CTX_free)   (SSL_CTX *) = NULL;
    00047 static int (*K_SSL_set_fd)      (SSL *, int) = NULL;
    00048 static int (*K_SSL_pending)     (SSL *) = NULL;
    00049 static int (*K_SSL_peek)        (SSL *, void *, int) = NULL;
    00050 static int (*K_SSL_CTX_set_cipher_list)(SSL_CTX *, const char *) = NULL;
    00051 static void (*K_SSL_CTX_set_verify)(SSL_CTX *, int,
    00052                          int (*)(int, X509_STORE_CTX *)) = NULL;
    00053 static int (*K_SSL_use_certificate)(SSL *, X509 *) = NULL;
    00054 static SSL_CIPHER *(*K_SSL_get_current_cipher)(SSL *) = NULL;
    00055 static long (*K_SSL_ctrl)      (SSL *,int, long, char *) = NULL;
    00056 static int (*K_RAND_egd)        (const char *) = NULL;
    00057 static const char* (*K_RAND_file_name) (char *, size_t) = NULL;
    00058 static int (*K_RAND_load_file)  (const char *, long) = NULL;
    00059 static int (*K_RAND_write_file) (const char *) = NULL;
    00060 static SSL_METHOD * (*K_TLSv1_client_method) () = NULL;
    00061 static SSL_METHOD * (*K_SSLv2_client_method) () = NULL;
    00062 static SSL_METHOD * (*K_SSLv3_client_method) () = NULL;
    00063 static SSL_METHOD * (*K_SSLv23_client_method) () = NULL;
    00064 static X509 * (*K_SSL_get_peer_certificate) (SSL *) = NULL;
    00065 static int (*K_SSL_CIPHER_get_bits) (SSL_CIPHER *,int *) = NULL;
    00066 static char * (*K_SSL_CIPHER_get_version) (SSL_CIPHER *) = NULL;
    00067 static const char * (*K_SSL_CIPHER_get_name) (SSL_CIPHER *) = NULL;
    00068 static char * (*K_SSL_CIPHER_description) (SSL_CIPHER *, char *, int) = NULL;
    00069 static X509 * (*K_d2i_X509) (X509 **,unsigned char **,long) = NULL;
    00070 static int (*K_i2d_X509) (X509 *,unsigned char **) = NULL;
    00071 static int (*K_X509_cmp) (X509 *, X509 *) = NULL;
    00072 static void (*K_X509_STORE_CTX_free) (X509_STORE_CTX *) = NULL;
    00073 static int (*K_X509_verify_cert) (X509_STORE_CTX *) = NULL;
    00074 static X509_STORE_CTX *(*K_X509_STORE_CTX_new) (void) = NULL;
    00075 static void (*K_X509_STORE_free) (X509_STORE *) = NULL;
    00076 static X509_STORE *(*K_X509_STORE_new) (void) = NULL;
    00077 static void (*K_X509_free) (X509 *) = NULL;
    00078 static char *(*K_X509_NAME_oneline) (X509_NAME *,char *,int) = NULL;
    00079 static X509_NAME *(*K_X509_get_subject_name) (X509 *) = NULL;
    00080 static X509_NAME *(*K_X509_get_issuer_name) (X509 *) = NULL;
    00081 static X509_LOOKUP *(*K_X509_STORE_add_lookup) (X509_STORE *, X509_LOOKUP_METHOD *) = NULL;
    00082 static X509_LOOKUP_METHOD *(*K_X509_LOOKUP_file)(void) = NULL;
    00083 static void (*K_X509_LOOKUP_free)(X509_LOOKUP *) = NULL;
    00084 static int (*K_X509_LOOKUP_ctrl)(X509_LOOKUP *, int, const char *, long, char **) = NULL;
    00085 static void (*K_X509_STORE_CTX_init)(X509_STORE_CTX *, X509_STORE *, X509 *, STACK_OF(X509) *) = NULL;
    00086 static void (*K_CRYPTO_free)       (void *) = NULL;
    00087 static X509* (*K_X509_dup)         (X509 *) = NULL;
    00088 static BIO* (*K_BIO_new_fp)   (FILE *, int) = NULL;
    00089 static int  (*K_BIO_free)           (BIO *) = NULL;
    00090 static int (*K_PEM_ASN1_write_bio) (int (*)(),const char *,BIO *,char *,
    00091                                    const EVP_CIPHER *,unsigned char *,int ,
    00092                                             pem_password_cb *, void *) = NULL;
    00093 static ASN1_METHOD* (*K_X509_asn1_meth) (void) = NULL;
    00094 static int (*K_ASN1_i2d_fp)(int (*)(),FILE *,unsigned char *) = NULL;
    00095 static int (*K_i2d_ASN1_HEADER)(ASN1_HEADER *, unsigned char **) = NULL;
    00096 static int (*K_X509_print_fp)  (FILE *, X509*) = NULL;
    00097 static int (*K_i2d_PKCS12)  (PKCS12*, unsigned char**) = NULL;
    00098 static int (*K_i2d_PKCS12_fp)  (FILE *, PKCS12*) = NULL;
    00099 static int (*K_PKCS12_newpass) (PKCS12*, char*, char*) = NULL;
    00100 static PKCS12* (*K_d2i_PKCS12_fp) (FILE*, PKCS12**) = NULL;
    00101 static PKCS12* (*K_PKCS12_new) (void) = NULL;
    00102 static void (*K_PKCS12_free) (PKCS12 *) = NULL;
    00103 static int (*K_PKCS12_parse) (PKCS12*, const char *, EVP_PKEY**,
    00104                                              X509**, STACK_OF(X509)**) = NULL;
    00105 static void (*K_EVP_PKEY_free) (EVP_PKEY *) = NULL;
    00106 static EVP_PKEY* (*K_EVP_PKEY_new) () = NULL;
    00107 static void (*K_X509_REQ_free) (X509_REQ *) = NULL;
    00108 static X509_REQ* (*K_X509_REQ_new) () = NULL;
    00109 static int (*K_SSL_CTX_use_PrivateKey) (SSL_CTX*, EVP_PKEY*) = NULL;
    00110 static int (*K_SSL_CTX_use_certificate) (SSL_CTX*, X509*) = NULL;
    00111 static int (*K_SSL_get_error) (SSL*, int) = NULL;
    00112 static STACK_OF(X509)* (*K_SSL_get_peer_cert_chain) (SSL*) = NULL;
    00113 static void (*K_X509_STORE_CTX_set_chain) (X509_STORE_CTX *, STACK_OF(X509)*) = NULL;
    00114 static void (*K_X509_STORE_CTX_set_purpose) (X509_STORE_CTX *, int) = NULL;
    00115 static void (*K_sk_free) (STACK*) = NULL;
    00116 static int (*K_sk_num) (STACK*) = NULL;
    00117 static char* (*K_sk_pop) (STACK*) = NULL;
    00118 static char* (*K_sk_value) (STACK*, int) = NULL;
    00119 static STACK* (*K_sk_new) (int (*)()) = NULL;
    00120 static int (*K_sk_push) (STACK*, char*) = NULL;
    00121 static STACK* (*K_sk_dup) (STACK *) = NULL;
    00122 static char * (*K_i2s_ASN1_INTEGER) (X509V3_EXT_METHOD *, ASN1_INTEGER *) =NULL;
    00123 static ASN1_INTEGER * (*K_X509_get_serialNumber) (X509 *) = NULL;
    00124 static EVP_PKEY *(*K_X509_get_pubkey)(X509 *) = NULL;
    00125 static int (*K_i2d_PublicKey)(EVP_PKEY *, unsigned char **) = NULL;
    00126 static int (*K_X509_check_private_key)(X509 *, EVP_PKEY *) = NULL;
    00127 static char * (*K_BN_bn2hex)(const BIGNUM *) = NULL;
    00128 static int (*K_X509_digest)(const X509 *,const EVP_MD *, unsigned char *, unsigned int *) = NULL;
    00129 static EVP_MD* (*K_EVP_md5)() = NULL;
    00130 static void (*K_ASN1_INTEGER_free)(ASN1_INTEGER *) = NULL;
    00131 static int (*K_OBJ_obj2nid)(ASN1_OBJECT *) = NULL;
    00132 static const char * (*K_OBJ_nid2ln)(int) = NULL;
    00133 static int (*K_X509_get_ext_count)(X509*) = NULL;
    00134 static int (*K_X509_get_ext_by_NID)(X509*, int, int) = NULL;
    00135 static int (*K_X509_get_ext_by_OBJ)(X509*,ASN1_OBJECT*,int) = NULL;
    00136 static X509_EXTENSION *(*K_X509_get_ext)(X509*, int loc) = NULL;
    00137 static X509_EXTENSION *(*K_X509_delete_ext)(X509*, int) = NULL;
    00138 static int (*K_X509_add_ext)(X509*, X509_EXTENSION*, int) = NULL;
    00139 static void *(*K_X509_get_ext_d2i)(X509*, int, int*, int*) = NULL;
    00140 static char *(*K_i2s_ASN1_OCTET_STRING)(X509V3_EXT_METHOD*, ASN1_OCTET_STRING*) = NULL;
    00141 static int (*K_ASN1_BIT_STRING_get_bit)(ASN1_BIT_STRING*, int) = NULL;
    00142 static PKCS7 *(*K_PKCS7_new)() = NULL;
    00143 static void (*K_PKCS7_free)(PKCS7*) = NULL;
    00144 static void (*K_PKCS7_content_free)(PKCS7*) = NULL;
    00145 static int (*K_i2d_PKCS7)(PKCS7*, unsigned char**) = NULL;
    00146 static PKCS7 *(*K_d2i_PKCS7)(PKCS7**, unsigned char**,long) = NULL;
    00147 static int (*K_i2d_PKCS7_fp)(FILE*,PKCS7*) = NULL;
    00148 static PKCS7* (*K_d2i_PKCS7_fp)(FILE*,PKCS7**) = NULL;
    00149 static PKCS7* (*K_PKCS7_dup)(PKCS7*) = NULL;
    00150 static STACK_OF(X509_NAME) *(*K_SSL_load_client_CA_file)(const char*) = NULL;
    00151 static STACK_OF(X509_INFO) *(*K_PEM_X509_INFO_read)(FILE*, STACK_OF(X509_INFO)*, pem_password_cb*, void*) = NULL;
    00152 static char *(*K_ASN1_d2i_fp)(char *(*)(),char *(*)(),FILE*,unsigned char**) = NULL;
    00153 static X509 *(*K_X509_new)() = NULL;
    00154 static int (*K_X509_PURPOSE_get_count)() = NULL;
    00155 static int (*K_X509_PURPOSE_get_id)(X509_PURPOSE *) = NULL;
    00156 static int (*K_X509_check_purpose)(X509*,int,int) = NULL;
    00157 static X509_PURPOSE* (*K_X509_PURPOSE_get0)(int) = NULL;
    00158 static int (*K_EVP_PKEY_assign)(EVP_PKEY*, int, char*) = NULL;
    00159 static int (*K_X509_REQ_set_pubkey)(X509_REQ*, EVP_PKEY*) = NULL;
    00160 static RSA *(*K_RSA_generate_key)(int, unsigned long, void (*)(int,int,void *), void *) = NULL;
    00161 static int (*K_i2d_X509_REQ_fp)(FILE*, X509_REQ*) = NULL;
    00162 static void (*K_ERR_clear_error)() = NULL;
    00163 static void (*K_ERR_print_errors_fp)(FILE*) = NULL;
    00164 static int (*K_PKCS7_verify)(PKCS7*,STACK_OF(X509)*,X509_STORE*,BIO*,BIO*,int) = NULL;
    00165
    00166 #endif
    00167 }
    00168
    00169
    00170 bool KOpenSSLProxy::hasLibSSL() const {
    00171    return _sslLib != NULL;
    00172 }
    00173
    00174
    00175 bool KOpenSSLProxy::hasLibCrypto() const {
    00176    return _cryptoLib != NULL;
    00177 }
    00178
    00179
    00180 void KOpenSSLProxy::destroy() {
    00181   delete this;
    00182   _me = NULL;
    00183 }
    00184
    00185 #ifdef __OpenBSD__
    00186 #include <qdir.h>
    00187 #include <qstring.h>
    00188 #include <qstringlist.h>
    00189
    00190 static QString findMostRecentLib(QString dir, QString name)
    00191 {
    00192        // Grab all shared libraries in the directory
    00193        QString filter = "lib"+name+".so.*";
    00194        QDir d(dir, filter);
    00195        if (!d.exists())
    00196                return NULL;
    00197        QStringList l = d.entryList();
    00198
    00199        // Find the best one
    00200        int bestmaj = -1;
    00201        int bestmin = -1;
    00202        QString best = NULL;
    00203        // where do we start
    00204        uint s = filter.length()-1;
    00205        for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
    00206                QString numberpart = (*it).mid(s);
    00207                uint endmaj = numberpart.find('.');
    00208                if (endmaj == -1)
    00209                        continue;
    00210                bool ok;
    00211                int maj = numberpart.left(endmaj).toInt(&ok);
    00212                if (!ok)
    00213                        continue;
    00214                int min = numberpart.mid(endmaj+1).toInt(&ok);
    00215                if (!ok)
    00216                        continue;
    00217                if (maj > bestmaj || (maj == bestmaj && min > bestmin)) {
    00218                        bestmaj = maj;
    00219                        bestmin = min;
    00220                        best = (*it);
    00221                }
    00222        }
    00223        if (best.isNull())
    00224                return NULL;
    00225        else
    00226                return dir+"/"+best;
    00227 }
    00228 #endif
    00229
    00230
    00231 KOpenSSLProxy::KOpenSSLProxy() {
    00232 KLibLoader *ll = KLibLoader::self();
    00233 _ok = false;
    00234 QStringList libpaths, libnamesc, libnamess;
    00235 KConfig *cfg;
    00236
    00237    _cryptoLib = NULL;
    00238    _sslLib = NULL;
    00239
    00240    cfg = new KConfig("cryptodefaults", false, false);
    00241    cfg->setGroup("OpenSSL");
    00242    QString upath = cfg->readPathEntry("Path");
    00243    if (!upath.isEmpty())
    00244       libpaths << upath;
    00245
    00246    delete cfg;
    00247
    00248 #ifdef __OpenBSD__
    00249    {
    00250    QString libname = findMostRecentLib("/usr/lib", "crypto");
    00251    if (!libname.isNull())
    00252          _cryptoLib = ll->globalLibrary(libname.latin1());
    00253    }
    00254 #else
    00255    libpaths
    00256             #ifdef _AIX
    00257             << "/opt/freeware/lib/"
    00258             #endif
    00259             << "/usr/lib/"
    00260             << "/usr/ssl/lib/"
    00261             << "/usr/local/lib/"
    00262             << "/usr/local/openssl/lib/"
    00263             << "/usr/local/ssl/lib/"
    00264             << "/opt/openssl/lib/"
    00265             << "/lib/"
    00266             << "";
    00267
    00268 // FIXME: #define here for the various OS types to optimize
    00269    libnamess
    00270              #ifdef hpux
    00271              << "libssl.sl"
    00272              #elif defined(_AIX)
    00273              << "libssl.a(libssl.so.0)"
    00274              #elif defined(__APPLE__)
    00275              << "libssl.dylib"
    00276              << "libssl.0.9.dylib"
    00277              #else
    00278              #ifdef SHLIB_VERSION_NUMBER
    00279              << "libssl.so." SHLIB_VERSION_NUMBER
    00280              #endif
    00281              << "libssl.so"
    00282              << "libssl.so.0"
    00283              #endif
    00284              ;
    00285
    00286    libnamesc
    00287              #ifdef hpux
    00288              << "libcrypto.sl"
    00289              #elif defined(_AIX)
    00290              << "libcrypto.a(libcrypto.so.0)"
    00291              #elif defined(__APPLE__)
    00292              << "libcrypto.dylib"
    00293              << "libcrypto.0.9.dylib"
    00294              #else
    00295              #ifdef SHLIB_VERSION_NUMBER
    00296              << "libcrypto.so." SHLIB_VERSION_NUMBER
    00297              #endif
    00298              << "libcrypto.so"
    00299              << "libcrypto.so.0"
    00300              #endif
    00301              ;
    00302
    00303    for (QStringList::Iterator it = libpaths.begin();
    00304                               it != libpaths.end();
    00305                               ++it) {
    00306       for (QStringList::Iterator shit = libnamesc.begin();
    00307                                  shit != libnamesc.end();
    00308                                  ++shit) {
    00309          QString alib = *it;
    00310          if (!alib.isEmpty() && !alib.endsWith("/"))
    00311             alib += "/";
    00312          alib += *shit;
    00313          QString tmpStr(alib.latin1());
    00314          tmpStr.replace(QRegExp("\\(.*\\)"), "");
    00315          if (!access(tmpStr.latin1(), R_OK))
    00316             _cryptoLib = ll->globalLibrary(alib.latin1());
    00317          if (_cryptoLib) break;
    00318       }
    00319       if (_cryptoLib) break;
    00320    }
    00321 #endif
    00322
    00323    if (_cryptoLib) {
    00324 #ifdef KSSL_HAVE_SSL
    00325       K_X509_free = (void (*) (X509 *)) _cryptoLib->symbol("X509_free");
    00326       K_RAND_egd = (int (*)(const char *)) _cryptoLib->symbol("RAND_egd");
    00327       K_RAND_load_file = (int (*)(const char *, long)) _cryptoLib->symbol("RAND_load_file");
    00328       K_RAND_file_name = (const char* (*)(char *, size_t)) _cryptoLib->symbol("RAND_file_name");
    00329       K_RAND_write_file = (int (*)(const char *)) _cryptoLib->symbol("RAND_write_file");
    00330       K_CRYPTO_free = (void (*) (void *)) _cryptoLib->symbol("CRYPTO_free");
    00331       K_d2i_X509 = (X509 * (*)(X509 **,unsigned char **,long)) _cryptoLib->symbol("d2i_X509");
    00332       K_i2d_X509 = (int (*)(X509 *,unsigned char **)) _cryptoLib->symbol("i2d_X509");
    00333       K_X509_cmp = (int (*)(X509 *, X509 *)) _cryptoLib->symbol("X509_cmp");
    00334       K_X509_STORE_CTX_new = (X509_STORE_CTX * (*) (void)) _cryptoLib->symbol("X509_STORE_CTX_new");
    00335       K_X509_STORE_CTX_free = (void (*) (X509_STORE_CTX *)) _cryptoLib->symbol("X509_STORE_CTX_free");
    00336       K_X509_verify_cert = (int (*) (X509_STORE_CTX *)) _cryptoLib->symbol("X509_verify_cert");
    00337       K_X509_STORE_new = (X509_STORE * (*) (void)) _cryptoLib->symbol("X509_STORE_new");
    00338       K_X509_STORE_free = (void (*) (X509_STORE *)) _cryptoLib->symbol("X509_STORE_free");
    00339       K_X509_NAME_oneline = (char * (*) (X509_NAME *,char *,int)) _cryptoLib->symbol("X509_NAME_oneline");
    00340       K_X509_get_subject_name = (X509_NAME * (*) (X509 *)) _cryptoLib->symbol("X509_get_subject_name");
    00341       K_X509_get_issuer_name = (X509_NAME * (*) (X509 *)) _cryptoLib->symbol("X509_get_issuer_name");
    00342       K_X509_STORE_add_lookup = (X509_LOOKUP *(*) (X509_STORE *, X509_LOOKUP_METHOD *)) _cryptoLib->symbol("X509_STORE_add_lookup");
    00343       K_X509_LOOKUP_file = (X509_LOOKUP_METHOD *(*)(void)) _cryptoLib->symbol("X509_LOOKUP_file");
    00344       K_X509_LOOKUP_free = (void (*)(X509_LOOKUP *)) _cryptoLib->symbol("X509_LOOKUP_free");
    00345       K_X509_LOOKUP_ctrl = (int (*)(X509_LOOKUP *, int, const char *, long, char **)) _cryptoLib->symbol("X509_LOOKUP_ctrl");
    00346       K_X509_STORE_CTX_init = (void (*)(X509_STORE_CTX *, X509_STORE *, X509 *, STACK_OF(X509) *)) _cryptoLib->symbol("X509_STORE_CTX_init");
    00347       K_X509_dup = (X509* (*)(X509*)) _cryptoLib->symbol("X509_dup");
    00348       K_BIO_new_fp = (BIO* (*)(FILE*, int)) _cryptoLib->symbol("BIO_new_fp");
    00349       K_BIO_free = (int (*)(BIO*)) _cryptoLib->symbol("BIO_free");
    00350       K_PEM_ASN1_write_bio = (int (*)(int (*)(), const char *,BIO*, char*, const EVP_CIPHER *, unsigned char *, int, pem_password_cb *, void *)) _cryptoLib->symbol("PEM_ASN1_write_bio");
    00351       K_X509_asn1_meth = (ASN1_METHOD* (*)(void)) _cryptoLib->symbol("X509_asn1_meth");
    00352       K_ASN1_i2d_fp = (int (*)(int (*)(), FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_i2d_fp");
    00353       K_i2d_ASN1_HEADER = (int (*)(ASN1_HEADER *, unsigned char **)) _cryptoLib->symbol("i2d_ASN1_HEADER");
    00354       K_X509_print_fp = (int (*)(FILE*, X509*)) _cryptoLib->symbol("X509_print_fp");
    00355       K_i2d_PKCS12 = (int (*)(PKCS12*, unsigned char**)) _cryptoLib->symbol("i2d_PKCS12");
    00356       K_i2d_PKCS12_fp = (int (*)(FILE *, PKCS12*)) _cryptoLib->symbol("i2d_PKCS12_fp");
    00357       K_PKCS12_newpass = (int (*)(PKCS12*, char*, char*)) _cryptoLib->symbol("PKCS12_newpass");
    00358       K_d2i_PKCS12_fp = (PKCS12* (*)(FILE*, PKCS12**)) _cryptoLib->symbol("d2i_PKCS12_fp");
    00359       K_PKCS12_new = (PKCS12* (*)()) _cryptoLib->symbol("PKCS12_new");
    00360       K_PKCS12_free = (void (*)(PKCS12 *)) _cryptoLib->symbol("PKCS12_free");
    00361       K_PKCS12_parse = (int (*)(PKCS12*, const char *, EVP_PKEY**,
    00362                 X509**, STACK_OF(X509)**)) _cryptoLib->symbol("PKCS12_parse");
    00363       K_EVP_PKEY_free = (void (*) (EVP_PKEY *)) _cryptoLib->symbol("EVP_PKEY_free");
    00364       K_EVP_PKEY_new = (EVP_PKEY* (*)()) _cryptoLib->symbol("EVP_PKEY_new");
    00365       K_X509_REQ_free = (void (*)(X509_REQ*)) _cryptoLib->symbol("X509_REQ_free");
    00366       K_X509_REQ_new = (X509_REQ* (*)()) _cryptoLib->symbol("X509_REQ_new");
    00367       K_X509_STORE_CTX_set_chain = (void (*)(X509_STORE_CTX *, STACK_OF(X509)*)) _cryptoLib->symbol("X509_STORE_CTX_set_chain");
    00368       K_X509_STORE_CTX_set_purpose = (void (*)(X509_STORE_CTX *, int)) _cryptoLib->symbol("X509_STORE_CTX_set_purpose");
    00369       K_sk_free = (void (*) (STACK *)) _cryptoLib->symbol("sk_free");
    00370       K_sk_num = (int (*) (STACK *)) _cryptoLib->symbol("sk_num");
    00371       K_sk_pop = (char* (*) (STACK *)) _cryptoLib->symbol("sk_pop");
    00372       K_sk_value = (char* (*) (STACK *, int)) _cryptoLib->symbol("sk_value");
    00373       K_sk_new = (STACK* (*) (int (*)())) _cryptoLib->symbol("sk_new");
    00374       K_sk_push = (int (*) (STACK*, char*)) _cryptoLib->symbol("sk_push");
    00375       K_sk_dup = (STACK* (*) (STACK *)) _cryptoLib->symbol("sk_dup");
    00376       K_i2s_ASN1_INTEGER = (char *(*) (X509V3_EXT_METHOD *, ASN1_INTEGER *)) _cryptoLib->symbol("i2s_ASN1_INTEGER");
    00377       K_X509_get_serialNumber = (ASN1_INTEGER * (*) (X509 *)) _cryptoLib->symbol("X509_get_serialNumber");
    00378       K_X509_get_pubkey = (EVP_PKEY *(*)(X509 *)) _cryptoLib->symbol("X509_get_pubkey");
    00379       K_i2d_PublicKey = (int (*)(EVP_PKEY *, unsigned char **)) _cryptoLib->symbol("i2d_PublicKey");
    00380       K_X509_check_private_key = (int (*)(X509 *, EVP_PKEY *)) _cryptoLib->symbol("X509_check_private_key");
    00381       K_BN_bn2hex = (char *(*)(const BIGNUM *)) _cryptoLib->symbol("BN_bn2hex");
    00382       K_X509_digest = (int (*)(const X509 *,const EVP_MD *, unsigned char *, unsigned int *)) _cryptoLib->symbol("X509_digest");
    00383       K_EVP_md5 = (EVP_MD *(*)()) _cryptoLib->symbol("EVP_md5");
    00384       K_ASN1_INTEGER_free = (void (*)(ASN1_INTEGER *)) _cryptoLib->symbol("ASN1_INTEGER_free");
    00385       K_OBJ_obj2nid = (int (*)(ASN1_OBJECT *)) _cryptoLib->symbol("OBJ_obj2nid");
    00386       K_OBJ_nid2ln = (const char *(*)(int)) _cryptoLib->symbol("OBJ_nid2ln");
    00387       K_X509_get_ext_count = (int (*)(X509*)) _cryptoLib->symbol("X509_get_ext_count");
    00388       K_X509_get_ext_by_NID = (int (*)(X509*,int,int)) _cryptoLib->symbol("X509_get_ext_by_NID");
    00389       K_X509_get_ext_by_OBJ = (int (*)(X509*,ASN1_OBJECT*,int)) _cryptoLib->symbol("X509_get_ext_by_OBJ");
    00390       K_X509_get_ext = (X509_EXTENSION* (*)(X509*,int)) _cryptoLib->symbol("X509_get_ext");
    00391       K_X509_delete_ext = (X509_EXTENSION* (*)(X509*,int)) _cryptoLib->symbol("X509_delete_ext");
    00392       K_X509_add_ext = (int (*)(X509*,X509_EXTENSION*,int)) _cryptoLib->symbol("X509_add_ext");
    00393       K_X509_get_ext_d2i = (void* (*)(X509*,int,int*,int*)) _cryptoLib->symbol("X509_get_ext_d2i");
    00394       K_i2s_ASN1_OCTET_STRING = (char *(*)(X509V3_EXT_METHOD*,ASN1_OCTET_STRING*)) _cryptoLib->symbol("i2s_ASN1_OCTET_STRING");
    00395       K_ASN1_BIT_STRING_get_bit = (int (*)(ASN1_BIT_STRING*,int)) _cryptoLib->symbol("ASN1_BIT_STRING_get_bit");
    00396       K_PKCS7_new = (PKCS7 *(*)()) _cryptoLib->symbol("PKCS7_new");
    00397       K_PKCS7_free = (void (*)(PKCS7*)) _cryptoLib->symbol("PKCS7_free");
    00398       K_PKCS7_content_free = (void (*)(PKCS7*)) _cryptoLib->symbol("PKCS7_content_free");
    00399       K_i2d_PKCS7 = (int (*)(PKCS7*, unsigned char**)) _cryptoLib->symbol("i2d_PKCS7");
    00400       K_i2d_PKCS7_fp = (int (*)(FILE*,PKCS7*)) _cryptoLib->symbol("i2d_PKCS7_fp");
    00401       K_d2i_PKCS7 = (PKCS7* (*)(PKCS7**,unsigned char**,long)) _cryptoLib->symbol("d2i_PKCS7");
    00402       K_d2i_PKCS7_fp = (PKCS7 *(*)(FILE *,PKCS7**)) _cryptoLib->symbol("d2i_PKCS7_fp");
    00403       K_PKCS7_dup = (PKCS7* (*)(PKCS7*)) _cryptoLib->symbol("PKCS7_dup");
    00404       K_PKCS7_verify = (int (*)(PKCS7*,STACK_OF(X509)*,X509_STORE*,BIO*,BIO*,int)) _cryptoLib->symbol("PKCS7_verify");
    00405       K_PEM_X509_INFO_read = (STACK_OF(X509_INFO) *(*)(FILE*, STACK_OF(X509_INFO)*, pem_password_cb*, void *)) _cryptoLib->symbol("PEM_X509_INFO_read");
    00406       K_ASN1_d2i_fp = (char *(*)(char *(*)(),char *(*)(),FILE*,unsigned char**)) _cryptoLib->symbol("ASN1_d2i_fp");
    00407       K_X509_new = (X509 *(*)()) _cryptoLib->symbol("X509_new");
    00408       K_X509_PURPOSE_get_count = (int (*)()) _cryptoLib->symbol("X509_PURPOSE_get_count");
    00409       K_X509_PURPOSE_get_id = (int (*)(X509_PURPOSE *)) _cryptoLib->symbol("X509_PURPOSE_get_id");
    00410       K_X509_check_purpose = (int (*)(X509*,int,int)) _cryptoLib->symbol("X509_check_purpose");
    00411       K_X509_PURPOSE_get0 = (X509_PURPOSE *(*)(int)) _cryptoLib->symbol("X509_PURPOSE_get0");
    00412       K_EVP_PKEY_assign = (int (*)(EVP_PKEY*, int, char*)) _cryptoLib->symbol("EVP_PKEY_assign");
    00413       K_X509_REQ_set_pubkey = (int (*)(X509_REQ*, EVP_PKEY*)) _cryptoLib->symbol("X509_REQ_set_pubkey");
    00414       K_RSA_generate_key = (RSA* (*)(int, unsigned long, void (*)(int,int,void *), void *)) _cryptoLib->symbol("RSA_generate_key");
    00415       K_i2d_X509_REQ_fp = (int (*)(FILE *, X509_REQ *)) _cryptoLib->symbol("i2d_X509_REQ_fp");
    00416       K_ERR_clear_error = (void (*)()) _cryptoLib->symbol("ERR_clear_error");
    00417       K_ERR_print_errors_fp = (void (*)(FILE*)) _cryptoLib->symbol("ERR_print_errors_fp");
    00418 #endif
    00419    }
    00420
    00421 #ifdef __OpenBSD__
    00422    {
    00423    QString libname = findMostRecentLib("/usr/lib", "ssl");
    00424    if (!libname.isNull())
    00425          _sslLib = ll->globalLibrary(libname.latin1());
    00426    }
    00427 #else
    00428    for (QStringList::Iterator it = libpaths.begin();
    00429                               it != libpaths.end();
    00430                               ++it) {
    00431       for (QStringList::Iterator shit = libnamess.begin();
    00432                                  shit != libnamess.end();
    00433                                  ++shit) {
    00434          QString alib = *it;
    00435          if (!alib.isEmpty() && !alib.endsWith("/"))
    00436             alib += "/";
    00437          alib += *shit;
    00438          QString tmpStr(alib.latin1());
    00439          tmpStr.replace(QRegExp("\\(.*\\)"), "");
    00440          if (!access(tmpStr.latin1(), R_OK))
    00441                 _sslLib = ll->globalLibrary(alib.latin1());
    00442          if (_sslLib) break;
    00443       }
    00444       if (_sslLib) break;
    00445    }
    00446 #endif
    00447
    00448    if (_sslLib) {
    00449 #ifdef KSSL_HAVE_SSL
    00450       // stand back from your monitor and look at this.  it's fun! :)
    00451       K_SSL_connect = (int (*)(SSL *)) _sslLib->symbol("SSL_connect");
    00452       K_SSL_accept = (int (*)(SSL *)) _sslLib->symbol("SSL_accept");
    00453       K_SSL_read = (int (*)(SSL *, void *, int)) _sslLib->symbol("SSL_read");
    00454       K_SSL_write = (int (*)(SSL *, const void *, int))
    00455                             _sslLib->symbol("SSL_write");
    00456       K_SSL_new = (SSL* (*)(SSL_CTX *)) _sslLib->symbol("SSL_new");
    00457       K_SSL_free = (void (*)(SSL *)) _sslLib->symbol("SSL_free");
    00458       K_SSL_shutdown = (int (*)(SSL *)) _sslLib->symbol("SSL_shutdown");
    00459       K_SSL_CTX_new = (SSL_CTX* (*)(SSL_METHOD*)) _sslLib->symbol("SSL_CTX_new");
    00460       K_SSL_CTX_free = (void (*)(SSL_CTX*)) _sslLib->symbol("SSL_CTX_free");
    00461       K_SSL_set_fd = (int (*)(SSL *, int)) _sslLib->symbol("SSL_set_fd");
    00462       K_SSL_pending = (int (*)(SSL *)) _sslLib->symbol("SSL_pending");
    00463       K_SSL_CTX_set_cipher_list = (int (*)(SSL_CTX *, const char *))
    00464                                   _sslLib->symbol("SSL_CTX_set_cipher_list");
    00465       K_SSL_CTX_set_verify = (void (*)(SSL_CTX*, int, int (*)(int, X509_STORE_CTX*))) _sslLib->symbol("SSL_CTX_set_verify");
    00466       K_SSL_use_certificate = (int (*)(SSL*, X509*))
    00467                                   _sslLib->symbol("SSL_CTX_use_certificate");
    00468       K_SSL_get_current_cipher = (SSL_CIPHER *(*)(SSL *))
    00469                                   _sslLib->symbol("SSL_get_current_cipher");
    00470       K_SSL_ctrl = (long (*)(SSL * ,int, long, char *))
    00471                                   _sslLib->symbol("SSL_ctrl");
    00472       K_TLSv1_client_method = (SSL_METHOD *(*)()) _sslLib->symbol("TLSv1_client_method");
    00473       K_SSLv2_client_method = (SSL_METHOD *(*)()) _sslLib->symbol("SSLv2_client_method");
    00474       K_SSLv3_client_method = (SSL_METHOD *(*)()) _sslLib->symbol("SSLv3_client_method");
    00475       K_SSLv23_client_method = (SSL_METHOD *(*)()) _sslLib->symbol("SSLv23_client_method");
    00476       K_SSL_get_peer_certificate = (X509 *(*)(SSL *)) _sslLib->symbol("SSL_get_peer_certificate");
    00477       K_SSL_CIPHER_get_bits = (int (*)(SSL_CIPHER *,int *)) _sslLib->symbol("SSL_CIPHER_get_bits");
    00478       K_SSL_CIPHER_get_version = (char * (*)(SSL_CIPHER *)) _sslLib->symbol("SSL_CIPHER_get_version");
    00479       K_SSL_CIPHER_get_name = (const char * (*)(SSL_CIPHER *)) _sslLib->symbol("SSL_CIPHER_get_name");
    00480       K_SSL_CIPHER_description = (char * (*)(SSL_CIPHER *, char *, int)) _sslLib->symbol("SSL_CIPHER_description");
    00481       K_SSL_CTX_use_PrivateKey = (int (*)(SSL_CTX*, EVP_PKEY*)) _sslLib->symbol("SSL_CTX_use_PrivateKey");
    00482       K_SSL_CTX_use_certificate = (int (*)(SSL_CTX*, X509*)) _sslLib->symbol("SSL_CTX_use_certificate");
    00483       K_SSL_get_error = (int (*)(SSL*, int)) _sslLib->symbol("SSL_get_error");
    00484       K_SSL_get_peer_cert_chain = (STACK_OF(X509)* (*)(SSL*)) _sslLib->symbol("SSL_get_peer_cert_chain");
    00485       K_SSL_load_client_CA_file = (STACK_OF(X509_NAME)* (*)(const char *)) _sslLib->symbol("SSL_load_client_CA_file");
    00486       K_SSL_peek = (int (*)(SSL*,void*,int)) _sslLib->symbol("SSL_peek");
    00487 #endif
    00488
    00489
    00490       // Initialize the library (once only!)
    00491       void *x;
    00492       x = _sslLib->symbol("SSL_library_init");
    00493       if (_cryptoLib) {
    00494          if (x) ((int (*)())x)();
    00495          x = _cryptoLib->symbol("OpenSSL_add_all_algorithms");
    00496          if (x) {
    00497            ((void (*)())x)();
    00498          } else {
    00499            x = _cryptoLib->symbol("OpenSSL_add_all_algorithms_conf");
    00500            if (x) {
    00501              ((void (*)())x)();
    00502            } else {
    00503              x = _cryptoLib->symbol("OpenSSL_add_all_algorithms_noconf");
    00504              if (x)
    00505                ((void (*)())x)();
    00506            }
    00507          }
    00508          x = _cryptoLib->symbol("OpenSSL_add_all_ciphers");
    00509          if (x) ((void (*)())x)();
    00510          x = _cryptoLib->symbol("OpenSSL_add_all_digests");
    00511          if (x) ((void (*)())x)();
    00512       }
    00513    }
    00514
    00515 }
    00516
    00517
    00518 KOpenSSLProxy* KOpenSSLProxy::_me = NULL;
    00519 static KStaticDeleter<KOpenSSLProxy> med;
    00520
    00521
    00522
    00523 KOpenSSLProxy::~KOpenSSLProxy() {
    00524    if (_sslLib)
    00525         _sslLib->unload();
    00526    if (_cryptoLib)
    00527         _cryptoLib->unload();
    00528    med.setObject(0);
    00529 }
    00530
    00531
    00532 // FIXME: we should check "ok" and allow this to init the lib if !ok.
    00533
    00534 KOpenSSLProxy *KOpenSSLProxy::self() {
    00535 #ifdef KSSL_HAVE_SSL
    00536    if (!_me) {
    00537       _me = med.setObject(new KOpenSSLProxy);
    00538    }
    00539 #endif
    00540    return _me;
    00541 }
    00542
    00543
    00544
    00545
    00546
    00547
    00548
    00549 #ifdef KSSL_HAVE_SSL
    00550
    00551
    00552
    00553 int KOpenSSLProxy::SSL_connect(SSL *ssl) {
    00554    if (K_SSL_connect) return (K_SSL_connect)(ssl);
    00555    return -1;
    00556 }
    00557
    00558
    00559 int KOpenSSLProxy::SSL_accept(SSL *ssl) {
    00560    if (K_SSL_accept) return (K_SSL_accept)(ssl);
    00561    return -1;
    00562 }
    00563
    00564
    00565 int KOpenSSLProxy::SSL_read(SSL *ssl, void *buf, int num) {
    00566    if (K_SSL_read) return (K_SSL_read)(ssl, buf, num);
    00567    return -1;
    00568 }
    00569
    00570
    00571 int KOpenSSLProxy::SSL_write(SSL *ssl, const void *buf, int num) {
    00572    if (K_SSL_write) return (K_SSL_write)(ssl, buf, num);
    00573    return -1;
    00574 }
    00575
    00576
    00577 SSL *KOpenSSLProxy::SSL_new(SSL_CTX *ctx) {
    00578    if (K_SSL_new) return (K_SSL_new)(ctx);
    00579    return NULL;
    00580 }
    00581
    00582
    00583 void KOpenSSLProxy::SSL_free(SSL *ssl) {
    00584    if (K_SSL_free) (K_SSL_free)(ssl);
    00585 }
    00586
    00587
    00588 int KOpenSSLProxy::SSL_shutdown(SSL *ssl) {
    00589    if (K_SSL_shutdown) return (K_SSL_shutdown)(ssl);
    00590    return -1;
    00591 }
    00592
    00593
    00594 SSL_CTX *KOpenSSLProxy::SSL_CTX_new(SSL_METHOD *method) {
    00595    if (K_SSL_CTX_new) return (K_SSL_CTX_new)(method);
    00596    return NULL;
    00597 }
    00598
    00599
    00600 void KOpenSSLProxy::SSL_CTX_free(SSL_CTX *ctx) {
    00601    if (K_SSL_CTX_free) (K_SSL_CTX_free)(ctx);
    00602 }
    00603
    00604
    00605 int KOpenSSLProxy::SSL_set_fd(SSL *ssl, int fd) {
    00606    if (K_SSL_set_fd) return (K_SSL_set_fd)(ssl, fd);
    00607    return -1;
    00608 }
    00609
    00610
    00611 int KOpenSSLProxy::SSL_pending(SSL *ssl) {
    00612    if (K_SSL_pending) return (K_SSL_pending)(ssl);
    00613    return -1;
    00614 }
    00615
    00616
    00617 int KOpenSSLProxy::SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
    00618    if (K_SSL_CTX_set_cipher_list) return (K_SSL_CTX_set_cipher_list)(ctx, str);
    00619    return -1;
    00620 }
    00621
    00622
    00623 void KOpenSSLProxy::SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
    00624                               int (*verify_callback)(int, X509_STORE_CTX *)) {
    00625    if (K_SSL_CTX_set_verify) (K_SSL_CTX_set_verify)(ctx, mode, verify_callback);
    00626 }
    00627
    00628
    00629 int KOpenSSLProxy::SSL_use_certificate(SSL *ssl, X509 *x) {
    00630    if (K_SSL_use_certificate) return (K_SSL_use_certificate)(ssl, x);
    00631    return -1;
    00632 }
    00633
    00634
    00635 SSL_CIPHER *KOpenSSLProxy::SSL_get_current_cipher(SSL *ssl) {
    00636    if (K_SSL_get_current_cipher) return (K_SSL_get_current_cipher)(ssl);
    00637    return NULL;
    00638 }
    00639
    00640
    00641 long KOpenSSLProxy::SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg) {
    00642    if (K_SSL_ctrl) return (K_SSL_ctrl)(ssl, cmd, larg, parg);
    00643    return -1;
    00644 }
    00645
    00646
    00647 int KOpenSSLProxy::RAND_egd(const char *path) {
    00648    if (K_RAND_egd) return (K_RAND_egd)(path);
    00649    return -1;
    00650 }
    00651
    00652
    00653 SSL_METHOD *KOpenSSLProxy::TLSv1_client_method() {
    00654    if (K_TLSv1_client_method) return (K_TLSv1_client_method)();
    00655    return NULL;
    00656 }
    00657
    00658
    00659 SSL_METHOD *KOpenSSLProxy::SSLv2_client_method() {
    00660    if (K_SSLv2_client_method) return (K_SSLv2_client_method)();
    00661    return NULL;
    00662 }
    00663
    00664
    00665 SSL_METHOD *KOpenSSLProxy::SSLv3_client_method() {
    00666    if (K_SSLv3_client_method) return (K_SSLv3_client_method)();
    00667    return NULL;
    00668 }
    00669
    00670
    00671 SSL_METHOD *KOpenSSLProxy::SSLv23_client_method() {
    00672    if (K_SSLv23_client_method) return (K_SSLv23_client_method)();
    00673    return NULL;
    00674 }
    00675
    00676
    00677 X509 *KOpenSSLProxy::SSL_get_peer_certificate(SSL *s) {
    00678    if (K_SSL_get_peer_certificate) return (K_SSL_get_peer_certificate)(s);
    00679    return NULL;
    00680 }
    00681
    00682
    00683 int KOpenSSLProxy::SSL_CIPHER_get_bits(SSL_CIPHER *c,int *alg_bits) {
    00684    if (K_SSL_CIPHER_get_bits) return (K_SSL_CIPHER_get_bits)(c, alg_bits);
    00685    return -1;
    00686 }
    00687
    00688
    00689 char * KOpenSSLProxy::SSL_CIPHER_get_version(SSL_CIPHER *c) {
    00690    if (K_SSL_CIPHER_get_version) return (K_SSL_CIPHER_get_version)(c);
    00691    return NULL;
    00692 }
    00693
    00694
    00695 const char * KOpenSSLProxy::SSL_CIPHER_get_name(SSL_CIPHER *c) {
    00696    if (K_SSL_CIPHER_get_name) return (K_SSL_CIPHER_get_name)(c);
    00697    return NULL;
    00698 }
    00699
    00700
    00701 char * KOpenSSLProxy::SSL_CIPHER_description(SSL_CIPHER *c,char *buf,int size) {
    00702    if (K_SSL_CIPHER_description) return (K_SSL_CIPHER_description)(c,buf,size);
    00703    return NULL;
    00704 }
    00705
    00706
    00707 X509 * KOpenSSLProxy::d2i_X509(X509 **a,unsigned char **pp,long length) {
    00708    if (K_d2i_X509) return (K_d2i_X509)(a,pp,length);
    00709    return NULL;
    00710 }
    00711
    00712
    00713 int KOpenSSLProxy::i2d_X509(X509 *a,unsigned char **pp) {
    00714    if (K_i2d_X509) return (K_i2d_X509)(a,pp);
    00715    return -1;
    00716 }
    00717
    00718
    00719 int KOpenSSLProxy::X509_cmp(X509 *a, X509 *b) {
    00720    if (K_X509_cmp) return (K_X509_cmp)(a,b);
    00721    return 0;
    00722 }
    00723
    00724
    00725 X509_STORE *KOpenSSLProxy::X509_STORE_new(void) {
    00726    if (K_X509_STORE_new) return (K_X509_STORE_new)();
    00727    return NULL;
    00728 }
    00729
    00730
    00731 void KOpenSSLProxy::X509_STORE_free(X509_STORE *v) {
    00732    if (K_X509_STORE_free) (K_X509_STORE_free)(v);
    00733 }
    00734
    00735
    00736 X509_STORE_CTX *KOpenSSLProxy::X509_STORE_CTX_new(void) {
    00737    if (K_X509_STORE_CTX_new) return (K_X509_STORE_CTX_new)();
    00738    return NULL;
    00739 }
    00740
    00741
    00742 void KOpenSSLProxy::X509_STORE_CTX_free(X509_STORE_CTX *ctx) {
    00743    if (K_X509_STORE_CTX_free) (K_X509_STORE_CTX_free)(ctx);
    00744 }
    00745
    00746
    00747 int KOpenSSLProxy::X509_verify_cert(X509_STORE_CTX *ctx) {
    00748    if (K_X509_verify_cert) return (K_X509_verify_cert)(ctx);
    00749    return -1;
    00750 }
    00751
    00752
    00753 void KOpenSSLProxy::X509_free(X509 *a) {
    00754    if (K_X509_free) (K_X509_free)(a);
    00755 }
    00756
    00757
    00758 char *KOpenSSLProxy::X509_NAME_oneline(X509_NAME *a,char *buf,int size) {
    00759    if (K_X509_NAME_oneline) return (K_X509_NAME_oneline)(a,buf,size);
    00760    return NULL;
    00761 }
    00762
    00763
    00764 X509_NAME *KOpenSSLProxy::X509_get_subject_name(X509 *a) {
    00765    if (K_X509_get_subject_name) return (K_X509_get_subject_name)(a);
    00766    return NULL;
    00767 }
    00768
    00769
    00770 X509_NAME *KOpenSSLProxy::X509_get_issuer_name(X509 *a) {
    00771    if (K_X509_get_issuer_name) return (K_X509_get_issuer_name)(a);
    00772    return NULL;
    00773 }
    00774
    00775
    00776 X509_LOOKUP *KOpenSSLProxy::X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m) {
    00777    if (K_X509_STORE_add_lookup) return (K_X509_STORE_add_lookup)(v,m);
    00778    return NULL;
    00779 }
    00780
    00781
    00782 X509_LOOKUP_METHOD *KOpenSSLProxy::X509_LOOKUP_file(void) {
    00783    if (K_X509_LOOKUP_file) return (K_X509_LOOKUP_file)();
    00784    return NULL;
    00785 }
    00786
    00787
    00788 void KOpenSSLProxy::X509_LOOKUP_free(X509_LOOKUP *x) {
    00789    if (K_X509_LOOKUP_free) (K_X509_LOOKUP_free)(x);
    00790 }
    00791
    00792
    00793 int KOpenSSLProxy::X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret) {
    00794    if (K_X509_LOOKUP_ctrl) return (K_X509_LOOKUP_ctrl)(ctx,cmd,argc,argl,ret);
    00795    return -1;
    00796 }
    00797
    00798
    00799 void KOpenSSLProxy::X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, STACK_OF(X509) *chain) {
    00800    if (K_X509_STORE_CTX_init) (K_X509_STORE_CTX_init)(ctx,store,x509,chain);
    00801 }
    00802
    00803
    00804 void KOpenSSLProxy::CRYPTO_free(void *x) {
    00805    if (K_CRYPTO_free) (K_CRYPTO_free)(x);
    00806 }
    00807
    00808
    00809 X509 *KOpenSSLProxy::X509_dup(X509 *x509) {
    00810    if (K_X509_dup) return (K_X509_dup)(x509);
    00811    return NULL;
    00812 }
    00813
    00814
    00815 BIO *KOpenSSLProxy::BIO_new_fp(FILE *stream, int close_flag) {
    00816    if (K_BIO_new_fp) return (K_BIO_new_fp)(stream, close_flag);
    00817    return NULL;
    00818 }
    00819
    00820
    00821 int KOpenSSLProxy::BIO_free(BIO *a) {
    00822    if (K_BIO_free) return (K_BIO_free)(a);
    00823    return -1;
    00824 }
    00825
    00826
    00827 int KOpenSSLProxy::PEM_write_bio_X509(BIO *bp, X509 *x) {
    00828    if (K_PEM_ASN1_write_bio) return (K_PEM_ASN1_write_bio) ((int (*)())K_i2d_X509, PEM_STRING_X509, bp, (char *)x, NULL, NULL, 0, NULL, NULL);
    00829    else return -1;
    00830 }
    00831
    00832
    00833 ASN1_METHOD *KOpenSSLProxy::X509_asn1_meth(void) {
    00834    if (K_X509_asn1_meth) return (K_X509_asn1_meth)();
    00835    else return NULL;
    00836 }
    00837
    00838
    00839 int KOpenSSLProxy::ASN1_i2d_fp(FILE *out,unsigned char *x) {
    00840    if (K_ASN1_i2d_fp && K_i2d_ASN1_HEADER)
    00841         return (K_ASN1_i2d_fp)((int (*)())K_i2d_ASN1_HEADER, out, x);
    00842    else return -1;
    00843 }
    00844
    00845
    00846 int KOpenSSLProxy::X509_print(FILE *fp, X509 *x) {
    00847    if (K_X509_print_fp) return (K_X509_print_fp)(fp, x);
    00848    return -1;
    00849 }
    00850
    00851
    00852 PKCS12 *KOpenSSLProxy::d2i_PKCS12_fp(FILE *fp, PKCS12 **p12) {
    00853    if (K_d2i_PKCS12_fp) return (K_d2i_PKCS12_fp)(fp, p12);
    00854    else return NULL;
    00855 }
    00856
    00857
    00858 int KOpenSSLProxy::PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) {
    00859    if (K_PKCS12_newpass) return (K_PKCS12_newpass)(p12, oldpass, newpass);
    00860    else return -1;
    00861 }
    00862
    00863
    00864 int KOpenSSLProxy::i2d_PKCS12(PKCS12 *p12, unsigned char **p) {
    00865    if (K_i2d_PKCS12) return (K_i2d_PKCS12)(p12, p);
    00866    else return -1;
    00867 }
    00868
    00869
    00870 int KOpenSSLProxy::i2d_PKCS12_fp(FILE *fp, PKCS12 *p12) {
    00871    if (K_i2d_PKCS12_fp) return (K_i2d_PKCS12_fp)(fp, p12);
    00872    else return -1;
    00873 }
    00874
    00875
    00876 PKCS12 *KOpenSSLProxy::PKCS12_new(void) {
    00877    if (K_PKCS12_new) return (K_PKCS12_new)();
    00878    else return NULL;
    00879 }
    00880
    00881
    00882 void KOpenSSLProxy::PKCS12_free(PKCS12 *a) {
    00883    if (K_PKCS12_free) (K_PKCS12_free)(a);
    00884 }
    00885
    00886
    00887 int KOpenSSLProxy::PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey,
    00888                     X509 **cert, STACK_OF(X509) **ca) {
    00889    if (K_PKCS12_parse) return (K_PKCS12_parse) (p12, pass, pkey, cert, ca);
    00890    else return -1;
    00891 }
    00892
    00893
    00894 void KOpenSSLProxy::EVP_PKEY_free(EVP_PKEY *x) {
    00895    if (K_EVP_PKEY_free) (K_EVP_PKEY_free)(x);
    00896 }
    00897
    00898
    00899 EVP_PKEY* KOpenSSLProxy::EVP_PKEY_new() {
    00900    if (K_EVP_PKEY_new) return (K_EVP_PKEY_new)();
    00901    else return NULL;
    00902 }
    00903
    00904
    00905 void KOpenSSLProxy::X509_REQ_free(X509_REQ *x) {
    00906    if (K_X509_REQ_free) (K_X509_REQ_free)(x);
    00907 }
    00908
    00909
    00910 X509_REQ* KOpenSSLProxy::X509_REQ_new() {
    00911    if (K_X509_REQ_new) return (K_X509_REQ_new)();
    00912    else return NULL;
    00913 }
    00914
    00915
    00916 int KOpenSSLProxy::SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) {
    00917    if (K_SSL_CTX_use_PrivateKey) return (K_SSL_CTX_use_PrivateKey)(ctx,pkey);
    00918    else return -1;
    00919 }
    00920
    00921
    00922 int KOpenSSLProxy::SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x) {
    00923    if (K_SSL_CTX_use_certificate) return (K_SSL_CTX_use_certificate)(ctx,x);
    00924    else return -1;
    00925 }
    00926
    00927
    00928 int KOpenSSLProxy::SSL_get_error(SSL *ssl, int rc) {
    00929    if (K_SSL_get_error) return (K_SSL_get_error)(ssl,rc);
    00930    else return -1;
    00931 }
    00932
    00933
    00934 STACK_OF(X509) *KOpenSSLProxy::SSL_get_peer_cert_chain(SSL *s) {
    00935    if (K_SSL_get_peer_cert_chain) return (K_SSL_get_peer_cert_chain)(s);
    00936    else return NULL;
    00937 }
    00938
    00939
    00940 void KOpenSSLProxy::sk_free(STACK *s) {
    00941    if (K_sk_free) (K_sk_free)(s);
    00942 }
    00943
    00944
    00945 int KOpenSSLProxy::sk_num(STACK *s) {
    00946    if (K_sk_num) return (K_sk_num)(s);
    00947    else return -1;
    00948 }
    00949
    00950
    00951 char *KOpenSSLProxy::sk_pop(STACK *s) {
    00952    if (K_sk_pop) return (K_sk_pop)(s);
    00953    else return NULL;
    00954 }
    00955
    00956
    00957 char *KOpenSSLProxy::sk_value(STACK *s, int n) {
    00958    if (K_sk_value) return (K_sk_value)(s, n);
    00959    else return NULL;
    00960 }
    00961
    00962
    00963 void KOpenSSLProxy::X509_STORE_CTX_set_chain(X509_STORE_CTX *v, STACK_OF(X509)* x) {
    00964    if (K_X509_STORE_CTX_set_chain) (K_X509_STORE_CTX_set_chain)(v,x);
    00965 }
    00966
    00967 void KOpenSSLProxy::X509_STORE_CTX_set_purpose(X509_STORE_CTX *v, int purpose) {
    00968    if (K_X509_STORE_CTX_set_purpose) (K_X509_STORE_CTX_set_purpose)(v,purpose);
    00969 }
    00970
    00971
    00972 STACK* KOpenSSLProxy::sk_dup(STACK *s) {
    00973    if (K_sk_dup) return (K_sk_dup)(s);
    00974    else return NULL;
    00975 }
    00976
    00977
    00978 STACK* KOpenSSLProxy::sk_new(int (*cmp)()) {
    00979    if (K_sk_new) return (K_sk_new)(cmp);
    00980    else return NULL;
    00981 }
    00982
    00983
    00984 int KOpenSSLProxy::sk_push(STACK* s, char* d) {
    00985    if (K_sk_push) return (K_sk_push)(s,d);
    00986    else return -1;
    00987 }
    00988
    00989
    00990 char *KOpenSSLProxy::i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint) {
    00991    if (K_i2s_ASN1_INTEGER) return (K_i2s_ASN1_INTEGER)(meth, aint);
    00992    else return NULL;
    00993 }
    00994
    00995
    00996 ASN1_INTEGER *KOpenSSLProxy::X509_get_serialNumber(X509 *x) {
    00997    if (K_X509_get_serialNumber) return (K_X509_get_serialNumber)(x);
    00998    else return NULL;
    00999 }
    01000
    01001
    01002 EVP_PKEY *KOpenSSLProxy::X509_get_pubkey(X509 *x) {
    01003    if (K_X509_get_pubkey) return (K_X509_get_pubkey)(x);
    01004    else return NULL;
    01005 }
    01006
    01007
    01008 int KOpenSSLProxy::i2d_PublicKey(EVP_PKEY *a, unsigned char **pp) {
    01009    if (K_i2d_PublicKey) return (K_i2d_PublicKey)(a,pp);
    01010    else return 0;
    01011 }
    01012
    01013
    01014 int KOpenSSLProxy::X509_check_private_key(X509 *x, EVP_PKEY *p) {
    01015    if (K_X509_check_private_key) return (K_X509_check_private_key)(x,p);
    01016    return -1;
    01017 }
    01018
    01019
    01020 char *KOpenSSLProxy::BN_bn2hex(const BIGNUM *a) {
    01021    if (K_BN_bn2hex) return (K_BN_bn2hex)(a);
    01022    else return NULL;
    01023 }
    01024
    01025
    01026 int KOpenSSLProxy::X509_digest(const X509 *x,const EVP_MD *t, unsigned char *md, unsigned int *len) {
    01027    if (K_X509_digest) return (K_X509_digest)(x, t, md, len);
    01028    else return -1;
    01029 }
    01030
    01031
    01032 EVP_MD *KOpenSSLProxy::EVP_md5() {
    01033    if (K_EVP_md5) return (K_EVP_md5)();
    01034    return NULL;
    01035 }
    01036
    01037
    01038 void KOpenSSLProxy::ASN1_INTEGER_free(ASN1_INTEGER *a) {
    01039    if (K_ASN1_INTEGER_free) (K_ASN1_INTEGER_free)(a);
    01040 }
    01041
    01042
    01043 int KOpenSSLProxy::OBJ_obj2nid(ASN1_OBJECT *o) {
    01044    if (K_OBJ_obj2nid) return (K_OBJ_obj2nid)(o);
    01045    else return -1;
    01046 }
    01047
    01048
    01049 const char * KOpenSSLProxy::OBJ_nid2ln(int n) {
    01050    if (K_OBJ_nid2ln) return (K_OBJ_nid2ln)(n);
    01051    else return NULL;
    01052 }
    01053
    01054
    01055 int KOpenSSLProxy::X509_get_ext_count(X509 *x) {
    01056    if (K_X509_get_ext_count) return (K_X509_get_ext_count)(x);
    01057    else return -1;
    01058 }
    01059
    01060
    01061 int KOpenSSLProxy::X509_get_ext_by_NID(X509 *x, int nid, int lastpos) {
    01062    if (K_X509_get_ext_by_NID) return (K_X509_get_ext_by_NID)(x,nid,lastpos);
    01063    else return -1;
    01064 }
    01065
    01066
    01067 int KOpenSSLProxy::X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos) {
    01068    if (K_X509_get_ext_by_OBJ) return (K_X509_get_ext_by_OBJ)(x,obj,lastpos);
    01069    else return -1;
    01070 }
    01071
    01072
    01073 X509_EXTENSION *KOpenSSLProxy::X509_get_ext(X509 *x, int loc) {
    01074    if (K_X509_get_ext) return (K_X509_get_ext)(x,loc);
    01075    else return NULL;
    01076 }
    01077
    01078
    01079 X509_EXTENSION *KOpenSSLProxy::X509_delete_ext(X509 *x, int loc) {
    01080    if (K_X509_delete_ext) return (K_X509_delete_ext)(x,loc);
    01081    else return NULL;
    01082 }
    01083
    01084
    01085 int KOpenSSLProxy::X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) {
    01086    if (K_X509_add_ext) return (K_X509_add_ext)(x,ex,loc);
    01087    else return -1;
    01088 }
    01089
    01090
    01091 void *KOpenSSLProxy::X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx) {
    01092    if (K_X509_get_ext_d2i) return (K_X509_get_ext_d2i)(x,nid,crit,idx);
    01093    else return NULL;
    01094 }
    01095
    01096
    01097 char *KOpenSSLProxy::i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5) {
    01098    if (K_i2s_ASN1_OCTET_STRING) return (K_i2s_ASN1_OCTET_STRING)(method,ia5);
    01099    else return NULL;
    01100 }
    01101
    01102
    01103 int KOpenSSLProxy::ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n) {
    01104    if (K_ASN1_BIT_STRING_get_bit) return (K_ASN1_BIT_STRING_get_bit)(a,n);
    01105    else return -1;
    01106 }
    01107
    01108
    01109 PKCS7 *KOpenSSLProxy::PKCS7_new(void) {
    01110    if (K_PKCS7_new) return (K_PKCS7_new)();
    01111    else return NULL;
    01112 }
    01113
    01114
    01115 void KOpenSSLProxy::PKCS7_free(PKCS7 *a) {
    01116    if (K_PKCS7_free) (K_PKCS7_free)(a);
    01117 }
    01118
    01119
    01120 void KOpenSSLProxy::PKCS7_content_free(PKCS7 *a) {
    01121    if (K_PKCS7_content_free) (K_PKCS7_content_free)(a);
    01122 }
    01123
    01124
    01125 int KOpenSSLProxy::i2d_PKCS7(PKCS7 *a, unsigned char **pp) {
    01126    if (K_i2d_PKCS7) return (K_i2d_PKCS7)(a,pp);
    01127    else return -1;
    01128 }
    01129
    01130
    01131 PKCS7 *KOpenSSLProxy::d2i_PKCS7(PKCS7 **a, unsigned char **pp,long length) {
    01132    if (K_d2i_PKCS7) return (K_d2i_PKCS7)(a,pp,length);
    01133    else return NULL;
    01134 }
    01135
    01136
    01137 int KOpenSSLProxy::i2d_PKCS7_fp(FILE *fp,PKCS7 *p7) {
    01138    if (K_i2d_PKCS7_fp) return (K_i2d_PKCS7_fp)(fp,p7);
    01139    else return -1;
    01140 }
    01141
    01142
    01143 PKCS7 *KOpenSSLProxy::d2i_PKCS7_fp(FILE *fp,PKCS7 **p7) {
    01144    if (K_d2i_PKCS7_fp) return (K_d2i_PKCS7_fp)(fp,p7);
    01145    else return NULL;
    01146 }
    01147
    01148
    01149 PKCS7 *KOpenSSLProxy::PKCS7_dup(PKCS7 *p7) {
    01150    if (K_PKCS7_dup) return (K_PKCS7_dup)(p7);
    01151    else return NULL;
    01152 }
    01153
    01154
    01155 int KOpenSSLProxy::PKCS7_verify(PKCS7* p, STACK_OF(X509)* st, X509_STORE* s, BIO* in, BIO *out, int flags) {
    01156    if (K_PKCS7_verify) return (K_PKCS7_verify)(p,st,s,in,out,flags);
    01157    else return -1;
    01158 }
    01159
    01160
    01161 STACK_OF(X509_NAME) *KOpenSSLProxy::SSL_load_client_CA_file(const char *file) {
    01162    if (K_SSL_load_client_CA_file) return (K_SSL_load_client_CA_file)(file);
    01163    else return NULL;
    01164 }
    01165
    01166
    01167 STACK_OF(X509_INFO) *KOpenSSLProxy::PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) {
    01168    if (K_PEM_X509_INFO_read) return (K_PEM_X509_INFO_read)(fp,sk,cb,u);
    01169    else return NULL;
    01170 }
    01171
    01172
    01173 X509 *KOpenSSLProxy::X509_d2i_fp(FILE *out, X509** buf) {
    01174    if (K_ASN1_d2i_fp) return reinterpret_cast<X509 *>((K_ASN1_d2i_fp)(reinterpret_cast<char *(*)()>(K_X509_new), reinterpret_cast<char *(*)()>(K_d2i_X509), out, reinterpret_cast<unsigned char **>(buf)));
    01175    else return NULL;
    01176 }
    01177
    01178
    01179 int KOpenSSLProxy::SSL_peek(SSL *ssl,void *buf,int num) {
    01180    if (K_SSL_peek) return (K_SSL_peek)(ssl,buf,num);
    01181    else return -1;
    01182 }
    01183
    01184
    01185 const char *KOpenSSLProxy::RAND_file_name(char *buf, size_t num) {
    01186    if (K_RAND_file_name) return (K_RAND_file_name)(buf, num);
    01187    else return NULL;
    01188 }
    01189
    01190
    01191 int KOpenSSLProxy::RAND_load_file(const char *filename, long max_bytes) {
    01192    if (K_RAND_load_file) return (K_RAND_load_file)(filename, max_bytes);
    01193    else return -1;
    01194 }
    01195
    01196
    01197 int KOpenSSLProxy::RAND_write_file(const char *filename) {
    01198    if (K_RAND_write_file) return (K_RAND_write_file)(filename);
    01199    else return -1;
    01200 }
    01201
    01202
    01203 int KOpenSSLProxy::X509_PURPOSE_get_count() {
    01204    if (K_X509_PURPOSE_get_count) return (K_X509_PURPOSE_get_count)();
    01205    else return -1;
    01206 }
    01207
    01208
    01209 int KOpenSSLProxy::X509_PURPOSE_get_id(X509_PURPOSE *p) {
    01210    if (K_X509_PURPOSE_get_id) return (K_X509_PURPOSE_get_id)(p);
    01211    else return -1;
    01212 }
    01213
    01214
    01215 int KOpenSSLProxy::X509_check_purpose(X509 *x, int id, int ca) {
    01216    if (K_X509_check_purpose) return (K_X509_check_purpose)(x, id, ca);
    01217    else return -1;
    01218 }
    01219
    01220
    01221 X509_PURPOSE *KOpenSSLProxy::X509_PURPOSE_get0(int idx) {
    01222    if (K_X509_PURPOSE_get0) return (K_X509_PURPOSE_get0)(idx);
    01223    else return NULL;
    01224 }
    01225
    01226
    01227 int KOpenSSLProxy::EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key) {
    01228    if (K_EVP_PKEY_assign) return (K_EVP_PKEY_assign)(pkey, type, key);
    01229    else return -1;
    01230 }
    01231
    01232
    01233 int KOpenSSLProxy::X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) {
    01234    if (K_X509_REQ_set_pubkey) return (K_X509_REQ_set_pubkey)(x, pkey);
    01235    else return -1;
    01236 }
    01237
    01238
    01239 RSA* KOpenSSLProxy::RSA_generate_key(int bits, unsigned long e, void
    01240                         (*callback)(int,int,void *), void *cb_arg) {
    01241    if (K_RSA_generate_key) return (K_RSA_generate_key)(bits, e, callback, cb_arg);
    01242    else return NULL;
    01243 }
    01244
    01245
    01246 int KOpenSSLProxy::i2d_X509_REQ_fp(FILE *fp, X509_REQ *x) {
    01247    if (K_i2d_X509_REQ_fp) return (K_i2d_X509_REQ_fp)(fp,x);
    01248    else return -1;
    01249 }
    01250
    01251
    01252 void KOpenSSLProxy::ERR_clear_error() {
    01253    if (K_ERR_clear_error) (K_ERR_clear_error)();
    01254 }
    01255
    01256
    01257 void KOpenSSLProxy::ERR_print_errors_fp(FILE* fp) {
    01258    if (K_ERR_print_errors_fp) (K_ERR_print_errors_fp)(fp);
    01259 }
    01260
    01261
    01262
    01263 #endif
    01264

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:51 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001