2014-08-29 20:18:28 +02:00
|
|
|
/* $Id: openssl-compat.h,v 1.31 2014/08/29 18:18:29 djm Exp $ */
|
2005-06-09 13:45:10 +02: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 20:18:28 +02:00
|
|
|
#ifndef _OPENSSL_COMPAT_H
|
|
|
|
#define _OPENSSL_COMPAT_H
|
|
|
|
|
2005-06-09 13:45:10 +02:00
|
|
|
#include "includes.h"
|
2015-01-14 16:21:31 +01:00
|
|
|
#ifdef WITH_OPENSSL
|
|
|
|
|
2010-10-07 13:06:42 +02:00
|
|
|
#include <openssl/opensslv.h>
|
2005-06-09 13:45:10 +02:00
|
|
|
#include <openssl/evp.h>
|
2010-05-12 09:49:59 +02:00
|
|
|
#include <openssl/rsa.h>
|
|
|
|
#include <openssl/dsa.h>
|
|
|
|
|
2014-06-17 15:06:07 +02:00
|
|
|
int ssh_compatible_openssl(long, long);
|
|
|
|
|
2014-07-02 07:28:02 +02:00
|
|
|
#if (OPENSSL_VERSION_NUMBER <= 0x0090805fL)
|
2014-08-29 20:18:28 +02:00
|
|
|
# error OpenSSL 0.9.8f or greater is required
|
2007-06-14 15:21:32 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-20 12:31:29 +01:00
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10000001L
|
2010-10-07 13:06:42 +02:00
|
|
|
# define LIBCRYPTO_EVP_INL_TYPE unsigned int
|
|
|
|
#else
|
|
|
|
# define LIBCRYPTO_EVP_INL_TYPE size_t
|
|
|
|
#endif
|
|
|
|
|
2014-08-29 18:30:30 +02: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 18:24:59 +02:00
|
|
|
#ifndef OPENSSL_HAVE_EVPCTR
|
2014-08-29 20:18:28 +02: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 18:24:59 +02: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 06:42:47 +01: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-11 00:39:12 +01: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
|
|
|
|
|
2005-06-09 13:45:10 +02:00
|
|
|
/*
|
2005-11-20 04:09:59 +01:00
|
|
|
* We overload some of the OpenSSL crypto functions with ssh_* equivalents
|
2014-07-02 07:28:02 +02:00
|
|
|
* to automatically handle OpenSSL engine initialisation.
|
2005-11-20 04:09:59 +01: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 13:45:10 +02:00
|
|
|
*/
|
2006-02-20 10:17:35 +01:00
|
|
|
#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS
|
2005-06-09 13:45:10 +02:00
|
|
|
|
2006-02-21 14:00:27 +01:00
|
|
|
# ifdef USE_OPENSSL_ENGINE
|
2011-05-10 03:13:36 +02:00
|
|
|
# ifdef OpenSSL_add_all_algorithms
|
|
|
|
# undef OpenSSL_add_all_algorithms
|
2006-02-21 14:00:27 +01:00
|
|
|
# endif
|
2011-05-10 03:13:36 +02:00
|
|
|
# define OpenSSL_add_all_algorithms() ssh_OpenSSL_add_all_algorithms()
|
2008-02-28 09:13:52 +01:00
|
|
|
# endif
|
2005-06-09 13:45:10 +02:00
|
|
|
|
2011-05-10 03:13:36 +02:00
|
|
|
void ssh_OpenSSL_add_all_algorithms(void);
|
2012-01-17 04:03:34 +01:00
|
|
|
|
2006-02-20 10:17:35 +01:00
|
|
|
#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
|
2010-05-12 09:49:59 +02:00
|
|
|
|
2015-01-14 16:21:31 +01:00
|
|
|
#endif /* WITH_OPENSSL */
|
2014-08-29 20:18:28 +02:00
|
|
|
#endif /* _OPENSSL_COMPAT_H */
|