diff options
author | Darren Tucker <dtucker@zip.com.au> | 2005-06-09 21:45:10 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2005-06-09 21:45:10 +1000 |
commit | a55ec7701336230c76b63ad426057146ae516a4f (patch) | |
tree | ce6f737b8fe815e6ce88e60a8cf9e5c610ff34e1 /openbsd-compat | |
parent | 431f022263a59595dd7894181515832828a950f9 (diff) |
- (dtucker) [cipher.c openbsd-compat/Makefile.in
openbsd-compat/openbsd-compat.{c,h} openbsd-compat/openssl-compat.h]
Move compatibility code for supporting older OpenSSL versions to the
compat layer. Suggested by and "no objection" djm@
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/Makefile.in | 4 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 5 | ||||
-rw-r--r-- | openbsd-compat/openssl-compat.c | 44 | ||||
-rw-r--r-- | openbsd-compat/openssl-compat.h | 65 |
4 files changed, 115 insertions, 3 deletions
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index 30d2410bc..c6e08867c 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.33 2005/06/01 11:39:34 dtucker Exp $ | 1 | # $Id: Makefile.in,v 1.34 2005/06/09 11:45:11 dtucker Exp $ |
2 | 2 | ||
3 | sysconfdir=@sysconfdir@ | 3 | sysconfdir=@sysconfdir@ |
4 | piddir=@piddir@ | 4 | piddir=@piddir@ |
@@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@ | |||
18 | 18 | ||
19 | OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o | 19 | OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o |
20 | 20 | ||
21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o xmmap.o xcrypt.o | 21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o |
22 | 22 | ||
23 | PORTS=port-irix.o port-aix.o | 23 | PORTS=port-irix.o port-aix.o |
24 | 24 | ||
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index a4cfa6c4d..f468d5aab 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.27 2005/05/26 10:48:25 djm Exp $ */ | 1 | /* $Id: openbsd-compat.h,v 1.28 2005/06/09 11:45:11 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
@@ -168,6 +168,9 @@ char *shadow_pw(struct passwd *pw); | |||
168 | /* rfc2553 socket API replacements */ | 168 | /* rfc2553 socket API replacements */ |
169 | #include "fake-rfc2553.h" | 169 | #include "fake-rfc2553.h" |
170 | 170 | ||
171 | /* compatibility with old or broken OpenSSL versions */ | ||
172 | #include "openssl-compat.h" | ||
173 | |||
171 | /* Routines for a single OS platform */ | 174 | /* Routines for a single OS platform */ |
172 | #include "bsd-cray.h" | 175 | #include "bsd-cray.h" |
173 | #include "bsd-cygwin_util.h" | 176 | #include "bsd-cygwin_util.h" |
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c new file mode 100644 index 000000000..10b4d1d74 --- /dev/null +++ b/openbsd-compat/openssl-compat.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* $Id: openssl-compat.c,v 1.1 2005/06/09 11:45:11 dtucker Exp $ */ | ||
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 | #define SSH_DONT_REDEF_EVP | ||
20 | #include "includes.h" | ||
21 | |||
22 | #ifdef SSH_OLD_EVP | ||
23 | int | ||
24 | ssh_EVP_CipherInit(EVP_CIPHER_CTX *evp, const EVP_CIPHER *type, | ||
25 | unsigned char *key, unsigned char *iv, int enc) | ||
26 | { | ||
27 | EVP_CipherInit(evp, type, key, iv, enc); | ||
28 | return 1; | ||
29 | } | ||
30 | |||
31 | int | ||
32 | ssh_EVP_Cipher(EVP_CIPHER_CTX *evp, char *dst, char *src, int len) | ||
33 | { | ||
34 | EVP_Cipher(evp, dst, src, len); | ||
35 | return 1; | ||
36 | } | ||
37 | |||
38 | int | ||
39 | ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *evp) | ||
40 | { | ||
41 | EVP_CIPHER_CTX_cleanup(evp); | ||
42 | return 1; | ||
43 | } | ||
44 | #endif | ||
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h new file mode 100644 index 000000000..d9b2fa55f --- /dev/null +++ b/openbsd-compat/openssl-compat.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* $Id: openssl-compat.h,v 1.1 2005/06/09 11:45:11 dtucker Exp $ */ | ||
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 | /* | ||
46 | * insert comment here | ||
47 | */ | ||
48 | #ifdef SSH_OLD_EVP | ||
49 | |||
50 | # ifndef SSH_DONT_REDEF_EVP | ||
51 | |||
52 | # ifdef EVP_Cipher | ||
53 | # undef EVP_Cipher | ||
54 | # endif | ||
55 | |||
56 | # define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e)) | ||
57 | # define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d)) | ||
58 | # define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a)) | ||
59 | # endif | ||
60 | |||
61 | int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, | ||
62 | unsigned char *, int); | ||
63 | int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); | ||
64 | int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *); | ||
65 | #endif | ||