kio Library: kopenssl.cc Source File (kio Library)

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

# kopenssl.cc

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

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:02 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003