diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-06-17 15:37:47 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-06-17 15:37:47 +0200 |
| commit | 758580c0760c799f2b870d2a898120eb6065dc42 (patch) | |
| tree | d42b82a190828f5ff85577c43c3c107758c35ba4 /src/common/Cryptography/RSA.h | |
| parent | 5859510b54580b6ff3ca2858d3bdbafae780972d (diff) | |
Core/Crypto: Fixed openssl 3.0 compatibility for custom hmac_sha256 digest for RSA
Diffstat (limited to 'src/common/Cryptography/RSA.h')
| -rw-r--r-- | src/common/Cryptography/RSA.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/common/Cryptography/RSA.h b/src/common/Cryptography/RSA.h index 18771f14926..63f6b7b393c 100644 --- a/src/common/Cryptography/RSA.h +++ b/src/common/Cryptography/RSA.h @@ -21,6 +21,7 @@ #include "Define.h" #include <openssl/evp.h> #include <array> +#include <memory> #include <string> #include <vector> @@ -34,16 +35,33 @@ public: class TC_COMMON_API DigestGenerator { public: + struct EVP_MD_Deleter + { + void operator()(EVP_MD* md) const; + }; + virtual ~DigestGenerator() = default; - virtual EVP_MD const* GetGenerator() const = 0; + virtual std::unique_ptr<EVP_MD, EVP_MD_Deleter> GetGenerator() const = 0; + +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + virtual OSSL_LIB_CTX* GetLib() const = 0; + virtual std::unique_ptr<OSSL_PARAM[]> GetParams() const = 0; +#else virtual void PostInitCustomizeContext(EVP_MD_CTX* ctx) = 0; +#endif }; class TC_COMMON_API SHA256 : public DigestGenerator { public: - EVP_MD const* GetGenerator() const override; + std::unique_ptr<EVP_MD, EVP_MD_Deleter> GetGenerator() const override; + +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + OSSL_LIB_CTX* GetLib() const override; + std::unique_ptr<OSSL_PARAM[]> GetParams() const override; +#else void PostInitCustomizeContext(EVP_MD_CTX* ctx) override; +#endif }; class TC_COMMON_API HMAC_SHA256 : public DigestGenerator @@ -51,8 +69,14 @@ public: public: explicit HMAC_SHA256(uint8 const* key, size_t keyLength) : _key(key), _keyLength(keyLength) { } - EVP_MD const* GetGenerator() const override; + std::unique_ptr<EVP_MD, EVP_MD_Deleter> GetGenerator() const override; + +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + OSSL_LIB_CTX* GetLib() const override; + std::unique_ptr<OSSL_PARAM[]> GetParams() const override; +#else void PostInitCustomizeContext(EVP_MD_CTX* ctx) override; +#endif private: uint8 const* _key; |
