From efe8bf60ec56565b96a26b041a965c925bc58c3b Mon Sep 17 00:00:00 2001 From: Cyp Date: Fri, 2 Sep 2016 11:47:15 +0200 Subject: [PATCH] Improve compilability with OpenSSL 1.1.0+ even more. See d29cacac856882b153fa206c49091188af5d95aa. Really fixes ticket:4493. --- lib/framework/crc.cpp | 6 ++++-- src/main.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/framework/crc.cpp b/lib/framework/crc.cpp index cf23c6e6398..32486ee9ee0 100644 --- a/lib/framework/crc.cpp +++ b/lib/framework/crc.cpp @@ -23,6 +23,8 @@ #include #include +#include + #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDSA) # define MATH_IS_ALCHEMY #endif @@ -331,7 +333,7 @@ bool EcKey::verify(Sig const &sig, void const *data, size_t dataLen) const EcKey::Key EcKey::toBytes(Privacy privacy) const { - decltype(i2o_ECPublicKey) *toBytesFunc = nullptr; // int (EC_KEY const *key, unsigned char **out), "const" only in OpenSSL 1.1.0+ + std::function toBytesFunc = nullptr; // int (EC_KEY const? *key, unsigned char **out), "const" only on i2o_ECPublicKey in OpenSSL 1.1.0+ switch (privacy) { case Private: toBytesFunc = i2d_ECPrivateKey; break; // Note that the format for private keys is somewhat bloated, and even contains the public key which could be (efficiently) computed from the private key. @@ -358,7 +360,7 @@ EcKey::Key EcKey::toBytes(Privacy privacy) const void EcKey::fromBytes(EcKey::Key const &key, EcKey::Privacy privacy) { - decltype(o2i_ECPublicKey) *fromBytesFunc = nullptr; // EC_KEY *(EC_KEY **key, unsigned char const **in, long len) + std::function fromBytesFunc = nullptr; // EC_KEY *(EC_KEY **key, unsigned char const **in, long len) switch (privacy) { case Private: fromBytesFunc = d2i_ECPrivateKey; break; diff --git a/src/main.cpp b/src/main.cpp index b17aeb6ba49..55842be5b1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1060,10 +1060,16 @@ int realmain(int argc, char *argv[]) const char **utfargv = (const char **)argv; wzMain(argc, argv); // init Qt integration first +#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L // The libcrypto startup stuff... May or may not actually be needed for anything at all. ERR_load_crypto_strings(); // This is needed for descriptive error messages. OpenSSL_add_all_algorithms(); // Don't actually use the EVP functions, so probably not needed. OPENSSL_config(nullptr); // What does this actually do? +#else + // The libcrypto startup stuff... May or may not actually be needed for anything at all. + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS | OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS | OPENSSL_INIT_LOAD_CONFIG, nullptr); +#endif + #ifdef WZ_OS_WIN RAND_screen(); // Uses a screenshot as a random seed, on systems lacking /dev/random. #endif