1 /*
2  * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _OPENSSL_COMPAT_H
18 #define _OPENSSL_COMPAT_H
19 
20 #include "includes.h"
21 #ifdef WITH_OPENSSL
22 
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 #include <openssl/ecdsa.h>
29 #include <openssl/dh.h>
30 
31 int ssh_compatible_openssl(long, long);
32 void ssh_libcrypto_init(void);
33 
34 #if (OPENSSL_VERSION_NUMBER < 0x1000100fL)
35 # error OpenSSL 1.0.1 or greater is required
36 #endif
37 
38 #ifndef OPENSSL_VERSION
39 # define OPENSSL_VERSION	SSLEAY_VERSION
40 #endif
41 
42 #if OPENSSL_VERSION_NUMBER < 0x10000001L
43 # define LIBCRYPTO_EVP_INL_TYPE unsigned int
44 #else
45 # define LIBCRYPTO_EVP_INL_TYPE size_t
46 #endif
47 
48 #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
49 # define OPENSSL_RSA_MAX_MODULUS_BITS	16384
50 #endif
51 #ifndef OPENSSL_DSA_MAX_MODULUS_BITS
52 # define OPENSSL_DSA_MAX_MODULUS_BITS	10000
53 #endif
54 
55 #if defined(HAVE_EVP_RIPEMD160)
56 # if defined(OPENSSL_NO_RIPEMD) || defined(OPENSSL_NO_RMD160)
57 #  undef HAVE_EVP_RIPEMD160
58 # endif
59 #endif
60 
61 /* LibreSSL/OpenSSL 1.1x API compat */
62 #if 0
63 /* wrong checks? */
64 #ifndef DSA_SIG_GET0
65 void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
66 #endif /* DSA_SIG_GET0 */
67 
68 #ifndef DSA_SIG_SET0
69 int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
70 #endif /* DSA_SIG_SET0 */
71 
72 #ifndef HAVE_EVP_MD_CTX_new
73 EVP_MD_CTX *EVP_MD_CTX_new(void);
74 #endif /* HAVE_EVP_MD_CTX_new */
75 
76 #ifndef HAVE_EVP_MD_CTX_free
77 void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
78 #endif /* HAVE_EVP_MD_CTX_free */
79 #endif
80 
81 #endif /* WITH_OPENSSL */
82 #endif /* _OPENSSL_COMPAT_H */
83