ssl_toolkit_compat.h revision 842ae4bd224140319ae7feec1872b93dfd491143
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SSL_TOOLKIT_COMPAT_H
#define SSL_TOOLKIT_COMPAT_H
/**
* @file ssl_toolkit_compat.h
* @brief this header file provides a compatiblity layer
* between OpenSSL and RSA sslc
*
* @defgroup MOD_SSL_TOOLKIT Toolkit
* @ingroup MOD_SSL
* @{
*/
#ifdef HAVE_OPENSSL
/** OpenSSL headers */
/** Avoid tripping over an engine build installed globally and detected
* when the user points at an explicit non-engine flavor of OpenSSL
*/
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
#endif
/**
* rsa sslc uses incomplete types for most structures
* so we macroize for OpenSSL those which cannot be dereferenced
* using the same sames as the sslc functions
*/
#define SSL_CIPHER_get_name(s) (s->name)
#define SSL_CIPHER_get_valid(s) (s->valid)
#define SSL_SESSION_get_session_id(s) (s->session_id)
#define SSL_SESSION_get_session_id_length(s) (s->session_id_length)
/**
* Support for retrieving/overriding states
*/
#ifndef SSL_get_state
#endif
#define MODSSL_BIO_CB_ARG_TYPE const char
#define MODSSL_CRYPTO_CB_ARG_TYPE const char
#if (OPENSSL_VERSION_NUMBER < 0x00907000)
# define MODSSL_INFO_CB_ARG_TYPE SSL*
#else
# define MODSSL_INFO_CB_ARG_TYPE const SSL*
#endif
#define MODSSL_CLIENT_CERT_CB_ARG_TYPE X509
#define MODSSL_PCHAR_CAST
/** ...shifting sands of openssl... */
#if (OPENSSL_VERSION_NUMBER >= 0x0090707f)
# define MODSSL_D2I_SSL_SESSION_CONST const
#else
# define MODSSL_D2I_SSL_SESSION_CONST
#endif
#if (OPENSSL_VERSION_NUMBER >= 0x00908000)
# define MODSSL_D2I_PrivateKey_CONST const
# define MODSSL_D2I_X509_CONST const
#else
# define MODSSL_D2I_PrivateKey_CONST
# define MODSSL_D2I_X509_CONST
#endif
typedef int (modssl_read_bio_cb_fn)(char*,int,int,void*);
#if (OPENSSL_VERSION_NUMBER < 0x00904000)
#else
#endif
#define modssl_free OPENSSL_free
#define EVP_PKEY_reference_inc(pkey) \
#define X509_reference_inc(cert) \
#define HAVE_SSL_RAND_EGD /* since 9.5.1 */
#define HAVE_SSL_X509V3_EXT_d2i
#ifndef PEM_F_DEF_CALLBACK
#ifdef PEM_F_PEM_DEF_CALLBACK
/** In OpenSSL 0.9.8 PEM_F_DEF_CALLBACK was renamed */
#endif
#endif
#include <bio.h>
#include <ssl.h>
#include <err.h>
#include <x509.h>
#include <pem.h>
#include <evp.h>
#include <objects.h>
#include <sslc.h>
/** sslc does not support this function, OpenSSL has since 9.5.1 */
#define RAND_status() 1
/** sslc names this function a bit differently */
#define CRYPTO_num_locks() CRYPTO_get_num_locks()
#ifndef STACK_OF
#endif
#define MODSSL_BIO_CB_ARG_TYPE char
#define MODSSL_CRYPTO_CB_ARG_TYPE char
#define MODSSL_INFO_CB_ARG_TYPE SSL*
#define MODSSL_CLIENT_CERT_CB_ARG_TYPE void
#define MODSSL_PCHAR_CAST (char *)
#define MODSSL_D2I_SSL_SESSION_CONST
#define MODSSL_D2I_PrivateKey_CONST
#define MODSSL_D2I_X509_CONST
typedef int (modssl_read_bio_cb_fn)(char*,int,int);
PEM_read_bio_X509(b, x, cb)
PEM_X509_INFO_read_bio(b, x, cb)
PEM_read_bio_PrivateKey(b, k, cb)
#ifndef HAVE_SSL_SET_STATE
#endif
#define modssl_set_cipher_list(ssl, l) \
SSL_set_cipher_list(ssl, (char *)l)
#define modssl_free free
#ifndef PEM_F_DEF_CALLBACK
#define PEM_F_DEF_CALLBACK PEM_F_DEF_CB
#endif
#if SSLC_VERSION_NUMBER < 0x2000
#define X509_STORE_CTX_set_depth(st, d)
#else /** SSLC_VERSION_NUMBER >= 0x2000 */
#define CRYPTO_malloc_init R_malloc_init
#define EVP_cleanup()
#endif /** SSLC_VERSION_NUMBER >= 0x2000 */
typedef void (*modssl_popfree_fn)(char *data);
#define sk_SSL_CIPHER_dup sk_dup
#define sk_SSL_CIPHER_free sk_free
#define sk_SSL_CIPHER_num sk_num
#define sk_X509_num sk_num
#define sk_X509_push sk_push
#define sk_X509_INFO_free sk_free
#define sk_X509_INFO_num sk_num
#define sk_X509_INFO_new_null sk_new_null
#define sk_X509_NAME_free sk_free
#define sk_X509_NAME_new sk_new
#define sk_X509_NAME_num sk_num
#define sk_X509_NAME_ENTRY_num sk_num
#define sk_X509_REVOKED_num sk_num
#else /** ! HAVE_OPENSSL && ! HAVE_SSLC */
#error "Unrecognized SSL Toolkit!"
#endif /* ! HAVE_OPENSSL && ! HAVE_SSLC */
#ifndef modssl_set_verify
#endif
#ifndef SSL_SESS_CACHE_NO_INTERNAL
#endif
#endif /* SSL_TOOLKIT_COMPAT_H */
/** @} */