17 #ifndef _OPENSSL_COMPAT_H
18 #define _OPENSSL_COMPAT_H
23 #include <openssl/opensslv.h>
24 #include <openssl/crypto.h>
25 #include <openssl/evp.h>
26 #include <openssl/rsa.h>
27 #include <openssl/dsa.h>
28 #ifdef OPENSSL_HAS_ECC
29 #include <openssl/ecdsa.h>
31 #include <openssl/dh.h>
33 int ssh_compatible_openssl(
long,
long);
34 void ssh_libcrypto_init(
void);
36 #if (OPENSSL_VERSION_NUMBER < 0x1000100fL)
37 # error OpenSSL 1.0.1 or greater is required
40 #ifndef OPENSSL_VERSION
41 # define OPENSSL_VERSION SSLEAY_VERSION
44 #ifndef HAVE_OPENSSL_VERSION
45 # define OpenSSL_version(x) SSLeay_version(x)
48 #ifndef HAVE_OPENSSL_VERSION_NUM
49 # define OpenSSL_version_num SSLeay
52 #if OPENSSL_VERSION_NUMBER < 0x10000001L
53 # define LIBCRYPTO_EVP_INL_TYPE unsigned int
55 # define LIBCRYPTO_EVP_INL_TYPE size_t
58 #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
59 # define OPENSSL_RSA_MAX_MODULUS_BITS 16384
61 #ifndef OPENSSL_DSA_MAX_MODULUS_BITS
62 # define OPENSSL_DSA_MAX_MODULUS_BITS 10000
65 #ifdef LIBRESSL_VERSION_NUMBER
66 # if LIBRESSL_VERSION_NUMBER < 0x3010000fL
67 # define HAVE_BROKEN_CHACHA20
72 #ifndef HAVE_DSA_GET0_PQG
73 void DSA_get0_pqg(
const DSA *d,
const BIGNUM **p,
const BIGNUM **q,
77 #ifndef HAVE_DSA_SET0_PQG
78 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
81 #ifndef HAVE_DSA_GET0_KEY
82 void DSA_get0_key(
const DSA *d,
const BIGNUM **pub_key,
83 const BIGNUM **priv_key);
86 #ifndef HAVE_DSA_SET0_KEY
87 int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);
90 #ifndef HAVE_EVP_CIPHER_CTX_GET_IV
91 # ifdef HAVE_EVP_CIPHER_CTX_GET_UPDATED_IV
92 # define EVP_CIPHER_CTX_get_iv EVP_CIPHER_CTX_get_updated_iv
94 int EVP_CIPHER_CTX_get_iv(
const EVP_CIPHER_CTX *ctx,
95 unsigned char *iv,
size_t len);
99 #ifndef HAVE_EVP_CIPHER_CTX_SET_IV
100 int EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx,
101 const unsigned char *iv,
size_t len);
104 #ifndef HAVE_RSA_GET0_KEY
105 void RSA_get0_key(
const RSA *r,
const BIGNUM **n,
const BIGNUM **e,
109 #ifndef HAVE_RSA_SET0_KEY
110 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
113 #ifndef HAVE_RSA_GET0_CRT_PARAMS
114 void RSA_get0_crt_params(
const RSA *r,
const BIGNUM **dmp1,
const BIGNUM **dmq1,
115 const BIGNUM **iqmp);
118 #ifndef HAVE_RSA_SET0_CRT_PARAMS
119 int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
122 #ifndef HAVE_RSA_GET0_FACTORS
123 void RSA_get0_factors(
const RSA *r,
const BIGNUM **p,
const BIGNUM **q);
126 #ifndef HAVE_RSA_SET0_FACTORS
127 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
131 void DSA_SIG_get0(
const DSA_SIG *sig,
const BIGNUM **pr,
const BIGNUM **ps);
135 int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
138 #ifdef OPENSSL_HAS_ECC
139 #ifndef HAVE_ECDSA_SIG_GET0
140 void ECDSA_SIG_get0(
const ECDSA_SIG *sig,
const BIGNUM **pr,
const BIGNUM **ps);
143 #ifndef HAVE_ECDSA_SIG_SET0
144 int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
148 #ifndef HAVE_DH_GET0_PQG
149 void DH_get0_pqg(
const DH *dh,
const BIGNUM **p,
const BIGNUM **q,
153 #ifndef HAVE_DH_SET0_PQG
154 int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
157 #ifndef HAVE_DH_GET0_KEY
158 void DH_get0_key(
const DH *dh,
const BIGNUM **pub_key,
const BIGNUM **priv_key);
161 #ifndef HAVE_DH_SET0_KEY
162 int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
165 #ifndef HAVE_DH_SET_LENGTH
166 int DH_set_length(DH *dh,
long length);
169 #ifndef HAVE_RSA_METH_FREE
170 void RSA_meth_free(RSA_METHOD *meth);
173 #ifndef HAVE_RSA_METH_DUP
174 RSA_METHOD *RSA_meth_dup(
const RSA_METHOD *meth);
177 #ifndef HAVE_RSA_METH_SET1_NAME
178 int RSA_meth_set1_name(RSA_METHOD *meth,
const char *name);
181 #ifndef HAVE_RSA_METH_GET_FINISH
182 int (*RSA_meth_get_finish(
const RSA_METHOD *meth))(RSA *rsa);
185 #ifndef HAVE_RSA_METH_SET_PRIV_ENC
186 int RSA_meth_set_priv_enc(RSA_METHOD *meth,
int (*priv_enc)(
int flen,
187 const unsigned char *from,
unsigned char *to, RSA *rsa,
int padding));
190 #ifndef HAVE_RSA_METH_SET_PRIV_DEC
191 int RSA_meth_set_priv_dec(RSA_METHOD *meth,
int (*priv_dec)(
int flen,
192 const unsigned char *from,
unsigned char *to, RSA *rsa,
int padding));
195 #ifndef HAVE_RSA_METH_SET_FINISH
196 int RSA_meth_set_finish(RSA_METHOD *meth,
int (*finish)(RSA *rsa));
199 #ifndef HAVE_EVP_PKEY_GET0_RSA
200 RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
203 #ifndef HAVE_EVP_MD_CTX_new
204 EVP_MD_CTX *EVP_MD_CTX_new(
void);
207 #ifndef HAVE_EVP_MD_CTX_free
208 void EVP_MD_CTX_free(EVP_MD_CTX *ctx);