2005-06-09 11:45:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2014-08-29 18:18:28 +00:00
|
|
|
#ifndef _OPENSSL_COMPAT_H
|
|
|
|
#define _OPENSSL_COMPAT_H
|
|
|
|
|
2005-06-09 11:45:10 +00:00
|
|
|
#include "includes.h"
|
2015-01-14 15:21:31 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
|
|
|
|
2010-10-07 11:06:42 +00:00
|
|
|
#include <openssl/opensslv.h>
|
2005-06-09 11:45:10 +00:00
|
|
|
#include <openssl/evp.h>
|
2010-05-12 07:49:59 +00:00
|
|
|
#include <openssl/rsa.h>
|
|
|
|
#include <openssl/dsa.h>
|
|
|
|
|
2014-06-17 13:06:07 +00:00
|
|
|
int ssh_compatible_openssl(long, long);
|
|
|
|
|
2014-07-02 05:28:02 +00:00
|
|
|
#if (OPENSSL_VERSION_NUMBER <= 0x0090805fL)
|
2014-08-29 18:18:28 +00:00
|
|
|
# error OpenSSL 0.9.8f or greater is required
|
2007-06-14 13:21:32 +00:00
|
|
|
#endif
|
|
|
|
|
2013-01-20 11:31:29 +00:00
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10000001L
|
2010-10-07 11:06:42 +00:00
|
|
|
# define LIBCRYPTO_EVP_INL_TYPE unsigned int
|
|
|
|
#else
|
|
|
|
# define LIBCRYPTO_EVP_INL_TYPE size_t
|
|
|
|
#endif
|
|
|
|
|
2014-08-29 16:30:30 +00:00
|
|
|
#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
|
|
|
|
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
|
|
|
|
#endif
|
|
|
|
#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
|
|
|
|
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
|
|
|
#endif
|
|
|
|
|
2014-07-20 16:24:59 +00:00
|
|
|
#ifndef OPENSSL_HAVE_EVPCTR
|
2014-08-29 18:18:28 +00:00
|
|
|
# define EVP_aes_128_ctr evp_aes_128_ctr
|
|
|
|
# define EVP_aes_192_ctr evp_aes_128_ctr
|
|
|
|
# define EVP_aes_256_ctr evp_aes_128_ctr
|
2014-07-20 16:24:59 +00:00
|
|
|
const EVP_CIPHER *evp_aes_128_ctr(void);
|
|
|
|
void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t);
|
|
|
|
#endif
|
|
|
|
|
2013-01-09 05:42:47 +00:00
|
|
|
/* Avoid some #ifdef. Code that uses these is unreachable without GCM */
|
|
|
|
#if !defined(OPENSSL_HAVE_EVPGCM) && !defined(EVP_CTRL_GCM_SET_IV_FIXED)
|
|
|
|
# define EVP_CTRL_GCM_SET_IV_FIXED -1
|
|
|
|
# define EVP_CTRL_GCM_IV_GEN -1
|
|
|
|
# define EVP_CTRL_GCM_SET_TAG -1
|
|
|
|
# define EVP_CTRL_GCM_GET_TAG -1
|
|
|
|
#endif
|
|
|
|
|
2013-02-10 23:39:12 +00:00
|
|
|
/* Replace missing EVP_CIPHER_CTX_ctrl() with something that returns failure */
|
|
|
|
#ifndef HAVE_EVP_CIPHER_CTX_CTRL
|
|
|
|
# ifdef OPENSSL_HAVE_EVPGCM
|
|
|
|
# error AES-GCM enabled without EVP_CIPHER_CTX_ctrl /* shouldn't happen */
|
|
|
|
# else
|
|
|
|
# define EVP_CIPHER_CTX_ctrl(a,b,c,d) (0)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2016-10-28 03:26:58 +00:00
|
|
|
#if defined(HAVE_EVP_RIPEMD160)
|
|
|
|
# if defined(OPENSSL_NO_RIPEMD) || defined(OPENSSL_NO_RMD160)
|
|
|
|
# undef HAVE_EVP_RIPEMD160
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-06-09 11:45:10 +00:00
|
|
|
/*
|
2005-11-20 03:09:59 +00:00
|
|
|
* We overload some of the OpenSSL crypto functions with ssh_* equivalents
|
2014-07-02 05:28:02 +00:00
|
|
|
* to automatically handle OpenSSL engine initialisation.
|
2005-11-20 03:09:59 +00:00
|
|
|
*
|
|
|
|
* In order for the compat library to call the real functions, it must
|
|
|
|
* define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and
|
|
|
|
* implement the ssh_* equivalents.
|
2005-06-09 11:45:10 +00:00
|
|
|
*/
|
2006-02-20 09:17:35 +00:00
|
|
|
#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS
|
2005-06-09 11:45:10 +00:00
|
|
|
|
2006-02-21 13:00:27 +00:00
|
|
|
# ifdef USE_OPENSSL_ENGINE
|
2011-05-10 01:13:36 +00:00
|
|
|
# ifdef OpenSSL_add_all_algorithms
|
|
|
|
# undef OpenSSL_add_all_algorithms
|
2006-02-21 13:00:27 +00:00
|
|
|
# endif
|
2011-05-10 01:13:36 +00:00
|
|
|
# define OpenSSL_add_all_algorithms() ssh_OpenSSL_add_all_algorithms()
|
2008-02-28 08:13:52 +00:00
|
|
|
# endif
|
2005-06-09 11:45:10 +00:00
|
|
|
|
2011-05-10 01:13:36 +00:00
|
|
|
void ssh_OpenSSL_add_all_algorithms(void);
|
2012-01-17 03:03:34 +00:00
|
|
|
|
2006-02-20 09:17:35 +00:00
|
|
|
#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
|
2010-05-12 07:49:59 +00:00
|
|
|
|
2015-01-14 15:21:31 +00:00
|
|
|
#endif /* WITH_OPENSSL */
|
2014-08-29 18:18:28 +00:00
|
|
|
#endif /* _OPENSSL_COMPAT_H */
|