mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-11-28 16:54:20 +00:00
Remove use of deprecated functions in OpenSSL 4.1
This commit is contained in:
1 parent
ac296864ac
commit
3178022887
2 files changed
+25
-4
No files matched your search
@@ -164,10 +164,11 @@ QSslKey
|
||||
IdentityManager::getSslKey()
|
||||
{
|
||||
if (m_CachedSslKey.isNull()) {
|
||||
// This seemingly useless const_cast is required for old OpenSSL headers
|
||||
// where BIO_new_mem_buf's parameter is not declared const like those on
|
||||
// the Steam Link hardware.
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
BIO* bio = BIO_new_mem_buf(const_cast<char*>(m_CachedPrivateKey.constData()), -1);
|
||||
#else
|
||||
BIO* bio = BIO_new_mem_buf(m_CachedPrivateKey.constData(), -1);
|
||||
#endif
|
||||
THROW_BAD_ALLOC_IF_NULL(bio);
|
||||
|
||||
EVP_PKEY* pk = PEM_read_bio_PrivateKey(bio, nullptr, nullptr, nullptr);
|
||||
|
||||
@@ -124,7 +124,11 @@ NvPairingManager::getSignatureFromCert(X509* cert)
|
||||
#else
|
||||
reinterpret_cast<const char*>(ASN1_STRING_get0_data(asnSignature)),
|
||||
#endif
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x40100000L)
|
||||
ASN1_STRING_length(asnSignature)
|
||||
#else
|
||||
ASN1_STRING_get_length(asnSignature)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
@@ -172,7 +176,11 @@ NvPairingManager::verifySignature(const QByteArray& data, const QByteArray& sign
|
||||
return false;
|
||||
}
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
|
||||
#else
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||
#endif
|
||||
THROW_BAD_ALLOC_IF_NULL(mdctx);
|
||||
|
||||
EVP_DigestVerifyInit(mdctx, nullptr, EVP_sha256(), nullptr, pubKey);
|
||||
@@ -180,7 +188,11 @@ NvPairingManager::verifySignature(const QByteArray& data, const QByteArray& sign
|
||||
int result = EVP_DigestVerifyFinal(mdctx, reinterpret_cast<unsigned char*>(const_cast<char*>(signature.data())), signature.length());
|
||||
|
||||
EVP_PKEY_free(pubKey);
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
#else
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
#endif
|
||||
X509_free(cert);
|
||||
|
||||
return result > 0;
|
||||
@@ -189,7 +201,11 @@ NvPairingManager::verifySignature(const QByteArray& data, const QByteArray& sign
|
||||
QByteArray
|
||||
NvPairingManager::signMessage(const QByteArray& message)
|
||||
{
|
||||
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
EVP_MD_CTX* ctx = EVP_MD_CTX_create();
|
||||
#else
|
||||
EVP_MD_CTX* ctx = EVP_MD_CTX_new();
|
||||
#endif
|
||||
THROW_BAD_ALLOC_IF_NULL(ctx);
|
||||
|
||||
EVP_DigestSignInit(ctx, NULL, EVP_sha256(), NULL, m_PrivateKey);
|
||||
@@ -201,7 +217,11 @@ NvPairingManager::signMessage(const QByteArray& message)
|
||||
QByteArray signature((int)signatureLength, 0);
|
||||
EVP_DigestSignFinal(ctx, reinterpret_cast<unsigned char*>(signature.data()), &signatureLength);
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
EVP_MD_CTX_destroy(ctx);
|
||||
#else
|
||||
EVP_MD_CTX_free(ctx);
|
||||
#endif
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user