diff options
Diffstat (limited to 'tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp')
-rw-r--r-- | tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index ac42704b30..12f29bf107 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -156,6 +156,7 @@ bool tst_QSslKey::fileContainsUnsupportedEllipticCurve(const QString &fileName) bool tst_QSslKey::algorithmsSupported(const QString &fileName) const { +#if QT_CONFIG(ssl) if (isSchannel && fileName.contains("RC2-64")) // Schannel treats RC2 as 128 bit return false; @@ -164,10 +165,9 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const return !(fileName.contains(QRegularExpression("-aes\\d\\d\\d-")) || fileName.contains("pkcs8-pkcs12")); } -#if OPENSSL_VERSION_MAJOR < 3 - // If it's not built with OpenSSL or it's OpenSSL v < 3. - return true; -#else + if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3) + return true; + // OpenSSL v3 first introduced the notion of 'providers'. Many algorithms // were moved into the 'legacy' provider. While they are still supported in theory, // the 'legacy' provider is NOT loaded by default and we are not loading it either. @@ -178,7 +178,10 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const return false; return !name.contains("-rc2-") && !name.contains("-rc4-"); -#endif +#else + Q_UNUSED(fileName); + return false; +#endif // QT_CONFIG(ssl) } @@ -312,7 +315,7 @@ void tst_QSslKey::constructorHandle() passphrase = "1234"; BIO* bio = q_BIO_new(q_BIO_s_mem()); - q_BIO_write(bio, pem.constData(), pem.length()); + q_BIO_write(bio, pem.constData(), pem.size()); EVP_PKEY *origin = func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data())); Q_ASSERT(origin); q_EVP_PKEY_up_ref(origin); @@ -545,12 +548,12 @@ void tst_QSslKey::passphraseChecks_data() const QByteArray pass("123"); const QByteArray aesPass("1234"); -#if OPENSSL_VERSION_MAJOR < 3 - // DES and RC2 are not provided by default in OpenSSL v3. - // This part is for either non-OpenSSL build, or OpenSSL v < 3.x. - QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; - QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; -#endif // OPENSSL_VERSION_MAJOR + if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3) { + // DES and RC2 are not provided by default in OpenSSL v3. + // This part is for either non-OpenSSL build, or OpenSSL v < 3.x. + QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; + QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; + } QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass; |