diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp index 77acbaa8..96549250 100644 --- a/plugins/qca-ossl/qca-ossl.cpp +++ b/plugins/qca-ossl/qca-ossl.cpp @@ -22,7 +22,6 @@ #include <QDebug> #include <QElapsedTimer> -#include <QScopedPointer> #include <QtCrypto> #include <QtPlugin> #include <qcaprovider.h> @@ -1606,32 +1605,28 @@ public: #ifndef OPENSSL_FIPS namespace { -struct DsaDeleter -{ - static inline void cleanup(void *pointer) - { - if (pointer) - DSA_free((DSA *)pointer); - } +static const auto DsaDeleter = [](DSA *pointer) { + if (pointer) + DSA_free((DSA *)pointer); }; } // end of anonymous namespace static bool make_dlgroup(const QByteArray &seed, int bits, int counter, DLParams *params) { int ret_counter; - QScopedPointer<DSA, DsaDeleter> dsa(DSA_new()); + std::unique_ptr<DSA, decltype(DsaDeleter)> dsa(DSA_new(), DsaDeleter); if (!dsa) return false; if (DSA_generate_parameters_ex( - dsa.data(), bits, (const unsigned char *)seed.data(), seed.size(), &ret_counter, nullptr, nullptr) != 1) + dsa.get(), bits, (const unsigned char *)seed.data(), seed.size(), &ret_counter, nullptr, nullptr) != 1) return false; if (ret_counter != counter) return false; const BIGNUM *bnp, *bnq, *bng; - DSA_get0_pqg(dsa.data(), &bnp, &bnq, &bng); + DSA_get0_pqg(dsa.get(), &bnp, &bnq, &bng); params->p = bn2bi(bnp); params->q = bn2bi(bnq); params->g = bn2bi(bng); @@ -1804,22 +1799,14 @@ private Q_SLOTS: // RSAKey //---------------------------------------------------------------------------- namespace { -struct RsaDeleter -{ - static inline void cleanup(void *pointer) - { - if (pointer) - RSA_free((RSA *)pointer); - } +static const auto RsaDeleter = [](RSA *pointer) { + if (pointer) + RSA_free((RSA *)pointer); }; -struct BnDeleter -{ - static inline void cleanup(void *pointer) - { - if (pointer) - BN_free((BIGNUM *)pointer); - } +static const auto BnDeleter = [](BIGNUM *pointer) { + if (pointer) + BN_free((BIGNUM *)pointer); }; } // end of anonymous namespace @@ -1847,22 +1834,22 @@ public: void run() override { - QScopedPointer<RSA, RsaDeleter> rsa(RSA_new()); + std::unique_ptr<RSA, decltype(RsaDeleter)> rsa(RSA_new(), RsaDeleter); if (!rsa) return; - QScopedPointer<BIGNUM, BnDeleter> e(BN_new()); + std::unique_ptr<BIGNUM, decltype(BnDeleter)> e(BN_new(), BnDeleter); if (!e) return; - BN_clear(e.data()); - if (BN_set_word(e.data(), exp) != 1) + BN_clear(e.get()); + if (BN_set_word(e.get(), exp) != 1) return; - if (RSA_generate_key_ex(rsa.data(), bits, e.data(), nullptr) == 0) + if (RSA_generate_key_ex(rsa.get(), bits, e.get(), nullptr) == 0) return; - result = rsa.take(); + result = rsa.release(); } RSA *takeResult() diff --git a/unittest/keybundle/keybundle.cpp b/unittest/keybundle/keybundle.cpp index 77c8075e..f624a36d 100644 --- a/unittest/keybundle/keybundle.cpp +++ b/unittest/keybundle/keybundle.cpp @@ -140,7 +140,7 @@ void KeyBundleTest::privKey() } void KeyBundleTest::createBundle() { - QScopedPointer<QCA::KeyBundle> newBundle(new QCA::KeyBundle); + std::unique_ptr<QCA::KeyBundle> newBundle(new QCA::KeyBundle); QVERIFY(newBundle->isNull()); diff --git a/unittest/pipeunittest/pipeunittest.cpp b/unittest/pipeunittest/pipeunittest.cpp index a5e30992..278931a9 100644 --- a/unittest/pipeunittest/pipeunittest.cpp +++ b/unittest/pipeunittest/pipeunittest.cpp @@ -167,7 +167,7 @@ void PipeUnitTest::readWriteSecure() void PipeUnitTest::signalTests() { - QScopedPointer<QCA::QPipe> pipe(new QCA::QPipe); + std::unique_ptr<QCA::QPipe> pipe(new QCA::QPipe); pipe->create(); QVERIFY(pipe->writeEnd().isValid()); @@ -214,7 +214,7 @@ void PipeUnitTest::signalTests() void PipeUnitTest::signalTestsSecure() { - QScopedPointer<QCA::QPipe> pipe(new QCA::QPipe); + std::unique_ptr<QCA::QPipe> pipe(new QCA::QPipe); pipe->create(true); QVERIFY(pipe->writeEnd().isValid()); diff --git a/unittest/tls/tlsunittest.cpp b/unittest/tls/tlsunittest.cpp index a00f5642..e7bbd06c 100644 --- a/unittest/tls/tlsunittest.cpp +++ b/unittest/tls/tlsunittest.cpp @@ -58,8 +58,8 @@ void TLSUnitTest::testCipherList() if (!QCA::isSupported("tls", QStringLiteral("qca-ossl"))) QWARN("TLS not supported for qca-ossl"); else { - QScopedPointer<QCA::TLS> tls(new QCA::TLS(QCA::TLS::Stream, nullptr, QStringLiteral("qca-ossl"))); - QStringList cipherList = tls->supportedCipherSuites(QCA::TLS::TLS_v1); + std::unique_ptr<QCA::TLS> tls(new QCA::TLS(QCA::TLS::Stream, nullptr, QStringLiteral("qca-ossl"))); + QStringList cipherList = tls->supportedCipherSuites(QCA::TLS::TLS_v1); QVERIFY(cipherList.contains(QStringLiteral("TLS_DHE_RSA_WITH_AES_256_CBC_SHA"))); QVERIFY(cipherList.contains(QStringLiteral("TLS_RSA_WITH_AES_256_CBC_SHA"))); QVERIFY(cipherList.contains(QStringLiteral("TLS_DHE_RSA_WITH_AES_128_CBC_SHA")));