freebsd-dev/crypto/openssh/openbsd-compat/openssl-compat.h

97 lines
3.0 KiB
C
Raw Normal View History

2015-01-05 16:09:55 +00:00
/* $Id: openssl-compat.h,v 1.31 2014/08/29 18:18:29 djm Exp $ */
2005-09-03 06:59:33 +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.
*/
2015-01-05 16:09:55 +00:00
#ifndef _OPENSSL_COMPAT_H
#define _OPENSSL_COMPAT_H
2005-09-03 06:59:33 +00:00
#include "includes.h"
2015-07-02 13:15:34 +00:00
#ifdef WITH_OPENSSL
2011-02-17 11:47:40 +00:00
#include <openssl/opensslv.h>
2005-09-03 06:59:33 +00:00
#include <openssl/evp.h>
2010-11-08 10:45:44 +00:00
#include <openssl/rsa.h>
#include <openssl/dsa.h>
2015-01-05 16:09:55 +00:00
int ssh_compatible_openssl(long, long);
2015-01-05 16:09:55 +00:00
#if (OPENSSL_VERSION_NUMBER <= 0x0090805fL)
# error OpenSSL 0.9.8f or greater is required
2005-09-03 06:59:33 +00:00
#endif
2013-03-22 11:19:48 +00:00
#if OPENSSL_VERSION_NUMBER < 0x10000001L
2011-02-17 11:47:40 +00:00
# define LIBCRYPTO_EVP_INL_TYPE unsigned int
#else
# define LIBCRYPTO_EVP_INL_TYPE size_t
#endif
2015-01-05 16:09:55 +00:00
#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
2006-03-22 19:46:12 +00:00
#endif
2015-01-05 16:09:55 +00:00
#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
2005-09-03 06:59:33 +00:00
#endif
2013-03-22 11:19:48 +00:00
#ifndef OPENSSL_HAVE_EVPCTR
2015-01-05 16:09:55 +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
2013-03-22 11:19:48 +00:00
const EVP_CIPHER *evp_aes_128_ctr(void);
void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t);
#endif
/* 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
/* 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 */
2005-09-03 06:59:33 +00:00
# else
2013-03-22 11:19:48 +00:00
# define EVP_CIPHER_CTX_ctrl(a,b,c,d) (0)
2005-09-03 06:59:33 +00:00
# endif
#endif
/*
2006-03-22 19:46:12 +00:00
* We overload some of the OpenSSL crypto functions with ssh_* equivalents
2015-01-05 16:09:55 +00:00
* to automatically handle OpenSSL engine initialisation.
2006-03-22 19:46:12 +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-09-03 06:59:33 +00:00
*/
2006-09-30 13:29:51 +00:00
#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS
2005-09-03 06:59:33 +00:00
2006-09-30 13:29:51 +00:00
# ifdef USE_OPENSSL_ENGINE
2011-09-28 08:14:41 +00:00
# ifdef OpenSSL_add_all_algorithms
# undef OpenSSL_add_all_algorithms
2006-09-30 13:29:51 +00:00
# endif
2011-09-28 08:14:41 +00:00
# define OpenSSL_add_all_algorithms() ssh_OpenSSL_add_all_algorithms()
# endif
2005-09-03 06:59:33 +00:00
2011-09-28 08:14:41 +00:00
void ssh_OpenSSL_add_all_algorithms(void);
2012-08-29 15:46:01 +00:00
2006-09-30 13:29:51 +00:00
#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
2010-11-08 10:45:44 +00:00
2015-07-02 13:15:34 +00:00
#endif /* WITH_OPENSSL */
2015-01-05 16:09:55 +00:00
#endif /* _OPENSSL_COMPAT_H */