diff options
author | Chris Wilson <qris@users.noreply.github.com> | 2018-01-02 21:13:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-02 21:13:55 +0000 |
commit | 6d7e9562e8485591a4888f1fc2d3c6c657dc7a01 (patch) | |
tree | 237b161707ed2b45b07a455f0089f23c6ecc1dd3 /lib/crypto/CipherContext.h | |
parent | a0fa0c4f5f338335034f172af290025d48d5a1d5 (diff) | |
parent | 85e7efc3fa0477f60318d2cd2144503a9ea8feb9 (diff) |
Merge pull request #22 from boxbackup/openssl_1_1
Fix compatibility with OpenSSL 1.1
Diffstat (limited to 'lib/crypto/CipherContext.h')
-rw-r--r-- | lib/crypto/CipherContext.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/crypto/CipherContext.h b/lib/crypto/CipherContext.h index 93c889d6..b6e97b4e 100644 --- a/lib/crypto/CipherContext.h +++ b/lib/crypto/CipherContext.h @@ -19,6 +19,22 @@ class CipherDescription; #define CIPHERCONTEXT_MAX_GENERATED_IV_LENGTH 32 +// Macros to allow compatibility with OpenSSL 1.0 and 1.1 APIs. See +// https://github.com/charybdis-ircd/charybdis/blob/release/3.5/libratbox/src/openssl_ratbox.h +// for the gory details. +#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER >= 0x10100000L) // OpenSSL >= 1.1 +# define BOX_OPENSSL_INIT_CTX(ctx) ctx = EVP_CIPHER_CTX_new(); +# define BOX_OPENSSL_CTX(ctx) ctx +# define BOX_OPENSSL_CLEANUP_CTX(ctx) EVP_CIPHER_CTX_free(ctx) +typedef EVP_CIPHER_CTX* BOX_EVP_CIPHER_CTX; +#else // OpenSSL < 1.1 +# define BOX_OPENSSL_INIT_CTX(ctx) EVP_CIPHER_CTX_init(&ctx); // no error return code, even though the docs says it does +# define BOX_OPENSSL_CTX(ctx) &ctx +# define BOX_OPENSSL_CLEANUP_CTX(ctx) EVP_CIPHER_CTX_cleanup(&ctx) +typedef EVP_CIPHER_CTX BOX_EVP_CIPHER_CTX; +#endif + + // -------------------------------------------------------------------------- // // Class @@ -74,16 +90,14 @@ public: #endif private: - EVP_CIPHER_CTX ctx; + BOX_EVP_CIPHER_CTX ctx; bool mInitialised; bool mWithinTransform; bool mPaddingOn; - uint8_t mGeneratedIV[CIPHERCONTEXT_MAX_GENERATED_IV_LENGTH]; CipherFunction mFunction; std::string mCipherName; -#ifdef HAVE_OLD_SSL - CipherDescription *mpDescription; -#endif + const CipherDescription *mpDescription; + std::string mIV; }; |