21#ifndef _PAM_PKCS11_OSSL_COMPAT_H 
   22#define _PAM_PKCS11_OSSL_COMPAT_H 
   29#include <openssl/opensslv.h> 
   30#include <openssl/opensslconf.h> 
   50#if OPENSSL_VERSION_NUMBER  <= 0x009070dfL 
   54#define EVP_CIPHER_CTX_new() ({ \ 
   55        EVP_CIPHER_CTX * tmp = NULL; \ 
   56        tmp = OPENSSL_malloc(sizeof(struct evp_cipher_ctx_st)); \ 
   58        EVP_CIPHER_CTX_init(tmp); \ 
   63#define EVP_CIPHER_CTX_free(x) ({ \ 
   65                EVP_CIPHER_CTX_cleanup(x); \ 
   79#if OPENSSL_VERSION_NUMBER < 0x10001000L 
   80#define EVP_PKEY_base_id(x)             (x->type) 
   83#if OPENSSL_VERSION_NUMBER < 0x10100000L 
   84#define RSA_PKCS1_OpenSSL               RSA_PKCS1_SSLeay 
   85#define OPENSSL_malloc_init             CRYPTO_malloc_init 
   87#define EVP_PKEY_get0_RSA(x)            (x->pkey.rsa) 
   88#define EVP_PKEY_get0_DSA(x)            (x->pkey.dsa) 
   89#define X509_get_extension_flags(x)     (x->ex_flags) 
   90#define X509_get_key_usage(x)           (x->ex_kusage) 
   91#define X509_get_extended_key_usage(x)  (x->ex_xkusage) 
   92#define EVP_MD_CTX_new                  EVP_MD_CTX_create 
   93#define EVP_MD_CTX_free                 EVP_MD_CTX_destroy 
   94#define EVP_PKEY_up_ref(user_key)       CRYPTO_add(&user_key->references, 1, CRYPTO_LOCK_EVP_PKEY) 
   95#define X509_up_ref(cert)               CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509) 
   96#define X509_get0_tbs_sigalg(x)         (x->cert_info->key->algor) 
   97#define X509_OBJECT_get0_X509(x)        (x->data.x509) 
   98#define X509_OBJECT_get0_X509_CRL(x)    (x->data.crl) 
   99#define RSA_get0_e(x) (x->e) 
  100#define RSA_get0_n(x) (x->n) 
  101#define ECDSA_SIG_get0_r(x) (x->r) 
  102#define ECDSA_SIG_get0_s(x) (x->s) 
  104#define X509_OBJECT_free(x) ({ \ 
  106                X509_OBJECT_free_contents(x); \ 
  120#if OPENSSL_VERSION_NUMBER < 0x10100000L 
  123# if !defined(inline) && !defined(__cplusplus) 
  124#  if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 
  126#   define pam_pkcs11_ossl_inline inline 
  127#  elif defined(__GNUC__) && __GNUC__>=2 
  128#   define pam_pkcs11_ossl_inline __inline__ 
  129#  elif defined(_MSC_VER) 
  130#   define pam_pkcs11_ossl_inline __inline 
  132#   define pam_pkcs11_ossl_inline 
  135#  define pam_pkcs11_ossl_inline inline 
  139#if OPENSSL_VERSION_NUMBER < 0x10100000L 
  141#define RSA_bits(R) (BN_num_bits(R->n)) 
  143#include <openssl/bn.h> 
  144#ifndef OPENSSL_NO_RSA 
  145#include <openssl/rsa.h> 
  147#ifndef OPENSSL_NO_DSA 
  148#include <openssl/dsa.h> 
  152#ifndef OPENSSL_NO_RSA 
  156    if (n == NULL || e == NULL)
 
  171    if (p == NULL || q == NULL)
 
  184    if (dmp1 == NULL || dmq1 == NULL || iqmp == NULL)
 
  216                         const BIGNUM **dmp1, 
const BIGNUM **dmq1, 
const BIGNUM **iqmp)
 
  228#ifndef OPENSSL_NO_DSA 
  242        *pub_key = d->pub_key;
 
  243    if (priv_key != NULL)
 
  244        *priv_key = d->priv_key;
 
  252#define RSA_set0_key(R, N, E, D) \ 
  255                if (!(N) || !(E)) { \ 
  269#define RSA_set0_factors(R, P, Q) \ 
  284#define RSA_set0_crt_params(R, DMP1, DMQ1, IQMP) \ 
  287                if (!DMP1 || !DMQ1 || !IQMP) { \ 
  301#define RSA_get0_key(R, N, E, D) { \ 
  305        if (n) *(n) = R->n; \ 
  306        if (e) *(e) = R->e; \ 
  307        if (d) *(d) = R->d; \ 
  310#define RSA_get0_factors(R, P, Q) {\ 
  313        if (p) *(p) = R->p; \ 
  314        if (q) *(q) = R->q; \ 
  317#define RSA_get0_crt_params(R, DMP1, DMQ1, IQMP) { \ 
  318        BIGNUM **dmp1 = DMP1; \ 
  319        BIGNUM **dmq1 = DMQ1; \ 
  320        BIGNUM **iqmp = IQMP; \ 
  321        if (dmp1) *(dmp1) = R->dmp1; \ 
  322        if (dmq1) *(dmq1) = R->dmq1; \ 
  323        if (iqmp) *(iqmp) = R->iqmp; \ 
  326#define DSA_get0_key(D, PUB, PRIV) { \ 
  327        BIGNUM **pub = PUB; \ 
  328        BIGNUM **priv = PRIV; \ 
  329        if (pub) *(pub) = D->pub_key; \ 
  330        if (priv) *(priv) = D->priv_key; \ 
  333#define DSA_get0_pqg(D, P, Q, G) { \ 
  337        if (p) *(p) = D->p; \ 
  338        if (q) *(q) = D->q; \ 
  339        if (g) *(g) = D->g; \ 
static pam_pkcs11_ossl_inline void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key)
static pam_pkcs11_ossl_inline int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)
static pam_pkcs11_ossl_inline int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
#define pam_pkcs11_ossl_inline
static pam_pkcs11_ossl_inline int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
static pam_pkcs11_ossl_inline void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp)
static pam_pkcs11_ossl_inline void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
static pam_pkcs11_ossl_inline void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
static pam_pkcs11_ossl_inline void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)