]> andersk Git - gssapi-openssh.git/blame - openssh/openbsd-compat/openssl-compat.h
Import of OpenSSH 4.7p1
[gssapi-openssh.git] / openssh / openbsd-compat / openssl-compat.h
CommitLineData
665a873d 1/* $Id$ */
2
3/*
4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include "includes.h"
20#include <openssl/evp.h>
21
22#if OPENSSL_VERSION_NUMBER < 0x00906000L
23# define SSH_OLD_EVP
24# define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
25#endif
26
2c06c99b 27#if (OPENSSL_VERSION_NUMBER < 0x00907000L) || defined(OPENSSL_LOBOTOMISED_AES)
28# define USE_BUILTIN_RIJNDAEL
29#endif
30
31#ifdef USE_BUILTIN_RIJNDAEL
d4487008 32# include "rijndael.h"
33# define AES_KEY rijndael_ctx
34# define AES_BLOCK_SIZE 16
35# define AES_encrypt(a, b, c) rijndael_encrypt(c, a, b)
36# define AES_set_encrypt_key(a, b, c) rijndael_set_key(c, (char *)a, b, 1)
665a873d 37# define EVP_aes_128_cbc evp_rijndael
38# define EVP_aes_192_cbc evp_rijndael
39# define EVP_aes_256_cbc evp_rijndael
40extern const EVP_CIPHER *evp_rijndael(void);
41extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
42#endif
43
44#if !defined(EVP_CTRL_SET_ACSS_MODE)
45# if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
46# define USE_CIPHER_ACSS 1
47extern const EVP_CIPHER *evp_acss(void);
48# define EVP_acss evp_acss
49# else
50# define EVP_acss NULL
51# endif
52#endif
53
799ae497 54/* OpenSSL 0.9.8e returns cipher key len not context key len */
55#if (OPENSSL_VERSION_NUMBER == 0x0090805fL)
56# define EVP_CIPHER_CTX_key_length(c) ((c)->key_len)
57#endif
58
665a873d 59/*
2c06c99b 60 * We overload some of the OpenSSL crypto functions with ssh_* equivalents
61 * which cater for older and/or less featureful OpenSSL version.
62 *
63 * In order for the compat library to call the real functions, it must
64 * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and
65 * implement the ssh_* equivalents.
665a873d 66 */
9108f8d9 67#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS
665a873d 68
9108f8d9 69# ifdef SSH_OLD_EVP
665a873d 70# ifdef EVP_Cipher
71# undef EVP_Cipher
72# endif
665a873d 73# define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e))
74# define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d))
75# define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a))
9108f8d9 76# endif /* SSH_OLD_EVP */
77
78# ifdef USE_OPENSSL_ENGINE
79# ifdef SSLeay_add_all_algorithms
80# undef SSLeay_add_all_algorithms
81# endif
82# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms()
83#endif
665a873d 84
85int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
86 unsigned char *, int);
87int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
88int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
9108f8d9 89void ssh_SSLeay_add_all_algorithms(void);
90#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
This page took 0.120191 seconds and 5 git commands to generate.