Darren Tucker | 4123636 | 2005-11-20 14:09:59 +1100 | [diff] [blame^] | 1 | /* $Id: openssl-compat.h,v 1.2 2005/11/20 03:10:00 dtucker Exp $ */ |
Darren Tucker | a55ec77 | 2005-06-09 21:45:10 +1000 | [diff] [blame] | 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 | |
| 27 | #if OPENSSL_VERSION_NUMBER < 0x00907000L |
| 28 | # define EVP_aes_128_cbc evp_rijndael |
| 29 | # define EVP_aes_192_cbc evp_rijndael |
| 30 | # define EVP_aes_256_cbc evp_rijndael |
| 31 | extern const EVP_CIPHER *evp_rijndael(void); |
| 32 | extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); |
| 33 | #endif |
| 34 | |
| 35 | #if !defined(EVP_CTRL_SET_ACSS_MODE) |
| 36 | # if (OPENSSL_VERSION_NUMBER >= 0x00907000L) |
| 37 | # define USE_CIPHER_ACSS 1 |
| 38 | extern const EVP_CIPHER *evp_acss(void); |
| 39 | # define EVP_acss evp_acss |
| 40 | # else |
| 41 | # define EVP_acss NULL |
| 42 | # endif |
| 43 | #endif |
| 44 | |
| 45 | /* |
Darren Tucker | 4123636 | 2005-11-20 14:09:59 +1100 | [diff] [blame^] | 46 | * We overload some of the OpenSSL crypto functions with ssh_* equivalents |
| 47 | * which cater for older and/or less featureful OpenSSL version. |
| 48 | * |
| 49 | * In order for the compat library to call the real functions, it must |
| 50 | * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and |
| 51 | * implement the ssh_* equivalents. |
Darren Tucker | a55ec77 | 2005-06-09 21:45:10 +1000 | [diff] [blame] | 52 | */ |
| 53 | #ifdef SSH_OLD_EVP |
| 54 | |
| 55 | # ifndef SSH_DONT_REDEF_EVP |
| 56 | |
| 57 | # ifdef EVP_Cipher |
| 58 | # undef EVP_Cipher |
| 59 | # endif |
| 60 | |
| 61 | # define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e)) |
| 62 | # define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d)) |
| 63 | # define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a)) |
| 64 | # endif |
| 65 | |
| 66 | int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, |
| 67 | unsigned char *, int); |
| 68 | int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); |
| 69 | int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); |
| 70 | #endif |