]>
Commit | Line | Data |
---|---|---|
34fee935 | 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 | ||
e00da40d | 27 | #if (OPENSSL_VERSION_NUMBER < 0x00907000L) || defined(OPENSSL_LOBOTOMISED_AES) |
28 | # define USE_BUILTIN_RIJNDAEL | |
29 | #endif | |
30 | ||
31 | #ifdef USE_BUILTIN_RIJNDAEL | |
34fee935 | 32 | # define EVP_aes_128_cbc evp_rijndael |
33 | # define EVP_aes_192_cbc evp_rijndael | |
34 | # define EVP_aes_256_cbc evp_rijndael | |
35 | extern const EVP_CIPHER *evp_rijndael(void); | |
36 | extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); | |
37 | #endif | |
38 | ||
39 | #if !defined(EVP_CTRL_SET_ACSS_MODE) | |
40 | # if (OPENSSL_VERSION_NUMBER >= 0x00907000L) | |
41 | # define USE_CIPHER_ACSS 1 | |
42 | extern const EVP_CIPHER *evp_acss(void); | |
43 | # define EVP_acss evp_acss | |
44 | # else | |
45 | # define EVP_acss NULL | |
46 | # endif | |
47 | #endif | |
48 | ||
49 | /* | |
e00da40d | 50 | * We overload some of the OpenSSL crypto functions with ssh_* equivalents |
51 | * which cater for older and/or less featureful OpenSSL version. | |
52 | * | |
53 | * In order for the compat library to call the real functions, it must | |
54 | * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and | |
55 | * implement the ssh_* equivalents. | |
34fee935 | 56 | */ |
2e437378 | 57 | #ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS |
34fee935 | 58 | |
2e437378 | 59 | # ifdef SSH_OLD_EVP |
34fee935 | 60 | # ifdef EVP_Cipher |
61 | # undef EVP_Cipher | |
62 | # endif | |
34fee935 | 63 | # define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e)) |
64 | # define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d)) | |
65 | # define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a)) | |
2e437378 | 66 | # endif /* SSH_OLD_EVP */ |
67 | ||
68 | # ifdef USE_OPENSSL_ENGINE | |
69 | # ifdef SSLeay_add_all_algorithms | |
70 | # undef SSLeay_add_all_algorithms | |
71 | # endif | |
72 | # define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms() | |
73 | #endif | |
34fee935 | 74 | |
75 | int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, | |
76 | unsigned char *, int); | |
77 | int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); | |
78 | int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); | |
2e437378 | 79 | void ssh_SSLeay_add_all_algorithms(void); |
80 | #endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */ |