Skip to content

Commit b4d497e

Browse files
committed
Simplify OpenSSL init
- Remove openvpn/openssl/util/init.hpp and instead add the opensslv.h include wherever needed. - Remove openvpn/init/cryptoinit.hpp because it was only required for OpenSSL < 1.1. Jira: OVPN3-1198 Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
1 parent 08743c4 commit b4d497e

File tree

17 files changed

+27
-75
lines changed

17 files changed

+27
-75
lines changed

openvpn/init/cryptoinit.hpp

Lines changed: 0 additions & 36 deletions
This file was deleted.

openvpn/init/initprocess.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <openvpn/common/base64.hpp>
2121
#include <openvpn/time/time.hpp>
2222
#include <openvpn/compress/compress.hpp>
23-
#include <openvpn/init/cryptoinit.hpp>
2423
#include <openvpn/init/engineinit.hpp>
2524

2625
namespace openvpn::InitProcess {
@@ -48,10 +47,6 @@ class Init
4847
{
4948
base64_uninit_static();
5049
}
51-
52-
private:
53-
// SSL library init happens when instantiated
54-
crypto_init crypto_init_;
5550
};
5651

5752
// process-wide singular instance

openvpn/openssl/compat.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#pragma once
1414

15+
#include <openssl/opensslv.h>
16+
1517
#if OPENSSL_VERSION_NUMBER < 0x30000000L
1618
#include <cassert>
1719
#include <cstring>
@@ -120,4 +122,4 @@ SSL_get0_group_name(SSL *s)
120122
int nid = static_cast<int>(SSL_get_negotiated_group(s));
121123
return SSL_group_to_name(s, nid);
122124
}
123-
#endif
125+
#endif

openvpn/openssl/crypto/cipher.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
#include <string>
1919

20-
#include <openssl/objects.h>
2120
#include <openssl/evp.h>
21+
#include <openssl/objects.h>
22+
#include <openssl/opensslv.h>
2223

2324
#include <openvpn/common/size.hpp>
2425
#include <openvpn/common/exception.hpp>

openvpn/openssl/crypto/cipheraead.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
#include <string>
1717

18-
#include <openssl/objects.h>
1918
#include <openssl/evp.h>
19+
#include <openssl/objects.h>
20+
#include <openssl/opensslv.h>
2021

2122
#include <openvpn/common/size.hpp>
2223
#include <openvpn/common/exception.hpp>

openvpn/openssl/crypto/digest.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <string>
1919

20+
#include <openssl/opensslv.h>
2021
#include <openssl/objects.h>
2122
#include <openssl/evp.h>
2223
#include <openssl/md4.h>

openvpn/openssl/crypto/mac.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <string>
1818

19+
#include <openssl/opensslv.h>
1920
/* The HMAC_* methods are deprecated in OpenSSL 3.0 and the EVP_MAC methods
2021
* do no exist in OpenSSL 1.1 yet. So use two distinct implementations */
2122
#if OPENSSL_VERSION_NUMBER < 0x30000000L
@@ -162,4 +163,4 @@ class HMACContext
162163
};
163164
} // namespace openvpn::OpenSSLCrypto
164165

165-
#endif
166+
#endif

openvpn/openssl/crypto/tls1prf.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
//
1111

1212
#pragma once
13+
14+
#include <openssl/opensslv.h>
1315
#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
1416
#include <openssl/core_names.h>
1517
#include <openssl/params.h>
1618
#endif
1719

1820
#include <openssl/kdf.h>
1921

20-
21-
2222
#include <openvpn/common/numeric_util.hpp>
2323

2424
namespace openvpn::OpenSSLCrypto {

openvpn/openssl/pki/dh-compat.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
#include <openvpn/common/exception.hpp>
2424
#include <openvpn/openssl/util/error.hpp>
2525

26-
// workaround for bug in DHparams_dup macro on OpenSSL 0.9.8 and lower
27-
#if SSLEAY_VERSION_NUMBER <= 0x00908000L
28-
#undef CHECKED_PTR_OF
29-
#define CHECKED_PTR_OF(type, p) ((char *)(1 ? p : (type *)0))
30-
#endif
31-
3226
namespace openvpn::OpenSSLPKI {
3327

3428
namespace DH_private {

openvpn/openssl/pki/dh.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <string>
1717

18+
#include <openssl/opensslv.h>
1819

1920
#include <openvpn/common/size.hpp>
2021
#include <openvpn/common/numeric_cast.hpp>
@@ -158,4 +159,4 @@ class DH
158159
::EVP_PKEY *dh_;
159160
};
160161
} // namespace openvpn::OpenSSLPKI
161-
#endif
162+
#endif

0 commit comments

Comments
 (0)