summaryrefslogtreecommitdiff
path: root/openbsd-compat/openssl-compat.h
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-02 15:28:02 +1000
committerDamien Miller <djm@mindrot.org>2014-07-02 15:28:02 +1000
commit8668706d0f52654fe64c0ca41a96113aeab8d2b8 (patch)
tree73e78e1ea3d39206e39870bbe0af17d6c430fb51 /openbsd-compat/openssl-compat.h
parent2cd7929250cf9e9f658d70dcd452f529ba08c942 (diff)
- djm@cvs.openbsd.org 2014/06/24 01:13:21
[Makefile.in auth-bsdauth.c auth-chall.c auth-options.c auth-rsa.c [auth2-none.c auth2-pubkey.c authfile.c authfile.h cipher-3des1.c [cipher-chachapoly.c cipher-chachapoly.h cipher.c cipher.h [digest-libc.c digest-openssl.c digest.h dns.c entropy.c hmac.h [hostfile.c key.c key.h krl.c monitor.c packet.c rsa.c rsa.h [ssh-add.c ssh-agent.c ssh-dss.c ssh-ecdsa.c ssh-ed25519.c [ssh-keygen.c ssh-pkcs11-client.c ssh-pkcs11-helper.c ssh-pkcs11.c [ssh-rsa.c sshbuf-misc.c sshbuf.h sshconnect.c sshconnect1.c [sshconnect2.c sshd.c sshkey.c sshkey.h [openbsd-compat/openssl-compat.c openbsd-compat/openssl-compat.h] New key API: refactor key-related functions to be more library-like, existing API is offered as a set of wrappers. with and ok markus@ Thanks also to Ben Hawkes, David Tomaschik, Ivan Fratric, Matthew Dempsky and Ron Bowes for a detailed review a few months ago. NB. This commit also removes portable OpenSSH support for OpenSSL <0.9.8e.
Diffstat (limited to 'openbsd-compat/openssl-compat.h')
-rw-r--r--openbsd-compat/openssl-compat.h118
1 files changed, 4 insertions, 114 deletions
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h
index 199dcc882..d088d2962 100644
--- a/openbsd-compat/openssl-compat.h
+++ b/openbsd-compat/openssl-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.h,v 1.27 2014/06/17 13:06:08 dtucker Exp $ */ 1/* $Id: openssl-compat.h,v 1.28 2014/07/02 05:28:07 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
@@ -24,22 +24,8 @@
24 24
25int ssh_compatible_openssl(long, long); 25int ssh_compatible_openssl(long, long);
26 26
27/* Only in 0.9.8 */ 27#if (OPENSSL_VERSION_NUMBER <= 0x0090805fL)
28#ifndef OPENSSL_DSA_MAX_MODULUS_BITS 28#error OpenSSL 0.9.8f or greater is required
29# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
30#endif
31#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
32# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
33#endif
34
35/* OPENSSL_free() is Free() in versions before OpenSSL 0.9.6 */
36#if !defined(OPENSSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x0090600f)
37# define OPENSSL_free(x) Free(x)
38#endif
39
40#if OPENSSL_VERSION_NUMBER < 0x00906000L
41# define SSH_OLD_EVP
42# define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
43#endif 29#endif
44 30
45#if OPENSSL_VERSION_NUMBER < 0x10000001L 31#if OPENSSL_VERSION_NUMBER < 0x10000001L
@@ -48,31 +34,6 @@ int ssh_compatible_openssl(long, long);
48# define LIBCRYPTO_EVP_INL_TYPE size_t 34# define LIBCRYPTO_EVP_INL_TYPE size_t
49#endif 35#endif
50 36
51#if (OPENSSL_VERSION_NUMBER < 0x00907000L) || defined(OPENSSL_LOBOTOMISED_AES)
52# define USE_BUILTIN_RIJNDAEL
53#endif
54
55#ifdef USE_BUILTIN_RIJNDAEL
56# include "rijndael.h"
57# define AES_KEY rijndael_ctx
58# define AES_BLOCK_SIZE 16
59# define AES_encrypt(a, b, c) rijndael_encrypt(c, a, b)
60# define AES_set_encrypt_key(a, b, c) rijndael_set_key(c, (char *)a, b, 1)
61# define EVP_aes_128_cbc evp_rijndael
62# define EVP_aes_192_cbc evp_rijndael
63# define EVP_aes_256_cbc evp_rijndael
64const EVP_CIPHER *evp_rijndael(void);
65void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
66#endif
67
68#ifndef OPENSSL_HAVE_EVPCTR
69#define EVP_aes_128_ctr evp_aes_128_ctr
70#define EVP_aes_192_ctr evp_aes_128_ctr
71#define EVP_aes_256_ctr evp_aes_128_ctr
72const EVP_CIPHER *evp_aes_128_ctr(void);
73void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t);
74#endif
75
76/* Avoid some #ifdef. Code that uses these is unreachable without GCM */ 37/* Avoid some #ifdef. Code that uses these is unreachable without GCM */
77#if !defined(OPENSSL_HAVE_EVPGCM) && !defined(EVP_CTRL_GCM_SET_IV_FIXED) 38#if !defined(OPENSSL_HAVE_EVPGCM) && !defined(EVP_CTRL_GCM_SET_IV_FIXED)
78# define EVP_CTRL_GCM_SET_IV_FIXED -1 39# define EVP_CTRL_GCM_SET_IV_FIXED -1
@@ -90,26 +51,9 @@ void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, size_t);
90# endif 51# endif
91#endif 52#endif
92 53
93#if OPENSSL_VERSION_NUMBER < 0x00907000L
94#define EVP_X_STATE(evp) &(evp).c
95#define EVP_X_STATE_LEN(evp) sizeof((evp).c)
96#else
97#define EVP_X_STATE(evp) (evp).cipher_data
98#define EVP_X_STATE_LEN(evp) (evp).cipher->ctx_size
99#endif
100
101/* OpenSSL 0.9.8e returns cipher key len not context key len */
102#if (OPENSSL_VERSION_NUMBER == 0x0090805fL)
103# define EVP_CIPHER_CTX_key_length(c) ((c)->key_len)
104#endif
105
106#ifndef HAVE_RSA_GET_DEFAULT_METHOD
107RSA_METHOD *RSA_get_default_method(void);
108#endif
109
110/* 54/*
111 * We overload some of the OpenSSL crypto functions with ssh_* equivalents 55 * We overload some of the OpenSSL crypto functions with ssh_* equivalents
112 * which cater for older and/or less featureful OpenSSL version. 56 * to automatically handle OpenSSL engine initialisation.
113 * 57 *
114 * In order for the compat library to call the real functions, it must 58 * In order for the compat library to call the real functions, it must
115 * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and 59 * define SSH_DONT_OVERLOAD_OPENSSL_FUNCS before including this file and
@@ -117,19 +61,6 @@ RSA_METHOD *RSA_get_default_method(void);
117 */ 61 */
118#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS 62#ifndef SSH_DONT_OVERLOAD_OPENSSL_FUNCS
119 63
120# ifdef SSH_OLD_EVP
121# ifdef EVP_Cipher
122# undef EVP_Cipher
123# endif
124# define EVP_CipherInit(a,b,c,d,e) ssh_EVP_CipherInit((a),(b),(c),(d),(e))
125# define EVP_Cipher(a,b,c,d) ssh_EVP_Cipher((a),(b),(c),(d))
126# define EVP_CIPHER_CTX_cleanup(a) ssh_EVP_CIPHER_CTX_cleanup((a))
127# endif /* SSH_OLD_EVP */
128
129# ifdef OPENSSL_EVP_DIGESTUPDATE_VOID
130# define EVP_DigestUpdate(a,b,c) ssh_EVP_DigestUpdate((a),(b),(c))
131# endif
132
133# ifdef USE_OPENSSL_ENGINE 64# ifdef USE_OPENSSL_ENGINE
134# ifdef OpenSSL_add_all_algorithms 65# ifdef OpenSSL_add_all_algorithms
135# undef OpenSSL_add_all_algorithms 66# undef OpenSSL_add_all_algorithms
@@ -137,48 +68,7 @@ RSA_METHOD *RSA_get_default_method(void);
137# define OpenSSL_add_all_algorithms() ssh_OpenSSL_add_all_algorithms() 68# define OpenSSL_add_all_algorithms() ssh_OpenSSL_add_all_algorithms()
138# endif 69# endif
139 70
140# ifndef HAVE_BN_IS_PRIME_EX
141int BN_is_prime_ex(const BIGNUM *, int, BN_CTX *, void *);
142# endif
143
144# ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
145int DSA_generate_parameters_ex(DSA *, int, const unsigned char *, int, int *,
146 unsigned long *, void *);
147# endif
148
149# ifndef HAVE_RSA_GENERATE_KEY_EX
150int RSA_generate_key_ex(RSA *, int, BIGNUM *, void *);
151# endif
152
153# ifndef HAVE_EVP_DIGESTINIT_EX
154int EVP_DigestInit_ex(EVP_MD_CTX *, const EVP_MD *, void *);
155# endif
156
157# ifndef HAVE_EVP_DISESTFINAL_EX
158int EVP_DigestFinal_ex(EVP_MD_CTX *, unsigned char *, unsigned int *);
159# endif
160
161# ifndef EVP_MD_CTX_COPY_EX
162int EVP_MD_CTX_copy_ex(EVP_MD_CTX *, const EVP_MD_CTX *);
163# endif
164
165int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
166 unsigned char *, int);
167int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);
168int ssh_EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
169void ssh_OpenSSL_add_all_algorithms(void); 71void ssh_OpenSSL_add_all_algorithms(void);
170 72
171# ifndef HAVE_HMAC_CTX_INIT
172# define HMAC_CTX_init(a)
173# endif
174
175# ifndef HAVE_EVP_MD_CTX_INIT
176# define EVP_MD_CTX_init(a)
177# endif
178
179# ifndef HAVE_EVP_MD_CTX_CLEANUP
180# define EVP_MD_CTX_cleanup(a)
181# endif
182
183#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */ 73#endif /* SSH_DONT_OVERLOAD_OPENSSL_FUNCS */
184 74