Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Hot Topic Of The Week
  4. Quantum Ready. Probably.
Qt 6.12 LTS is out! See what's new in the release blog

Quantum Ready. Probably.

Scheduled Pinned Locked Moved Unsolved Hot Topic Of The Week
2 Posts 2 Posters 71 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Axel SpoerlA Offline
    Axel SpoerlA Offline
    Axel Spoerl
    Moderators
    wrote last edited by Axel Spoerl
    #1

    A few days ago, an important security body from a country currently best known for having an entertaining president reminded everyone that the time to start deploying post-quantum cryptography is now. Yesterday, actually. Bad guys have already tapped your wire.

    As software engineers, our response to such developments is traditionally to write a command-line tool. This does not mean we have solved post-quantum cryptography, understand the migration path for products expected to remain in service until 2040, or even agree on what the most important questions are. But we deeply believe, that every sufficiently complex problem can somehow be mitigated by adding one more executable.

    After all, ten minutes into any discussion involving NIST standards, OpenSSL 3.5, hybrid key exchange, compliance requirements, migration strategies, and long-term support commitments, somebody eventually asks the only question that really matters:
    => Am I screwed?
    That's surprisingly difficult to answer.

    A blunt "yes" lacks nuance. A simple "no" is usually wrong and can get you into legal trouble. "It depends" is technically correct, albeit professionally useless.
    (And, as we know, the real answer is 42. Unfortunately it takes rather a long journey through the universe to get there.)

    So I wrote a small Qt application.
    It checks whether TLS is available, which backend is active, which OpenSSL version is being used, whether the environment is theoretically capable of supporting the standardized PQC algorithms shipping with OpenSSL 3.5, and whether it can establish a TLS connection to a real server.

    Then it prints a verdict: RESULT: PQC READY
    People love verdicts. Being handed a concise PQC READY is generally preferred over a 70-page migration strategy, even if the accompanying PowerPoint deck explains in a comprehensive multi-level bullet hierarchy why the answer really lands somewhere between "yes", "no", and "it depends".

    One thing I discovered almost immediately is that the seemingly innocent question
    => Did this connection actually use post-quantum cryptography?
    ...is way harder to answer than expected.

    Modern TLS intentionally hides many of the details engineers are interested in. Qt currently does not expose the negotiated key exchange group through its public APIs, which means determining whether a connection negotiated an ML-KEM-based key exchange requires going deeper into OpenSSL.

    Which means that a utility originally intended to answer a simple yes-or-no question is already showing strong tendencies towards becoming a research project. This, admittedly, is another long-standing engineering tradition.

    Another observation is that engineers and customers tend to ask different questions.

    • Engineers ask: Does it support X25519MLKEM768?
    • Customers ask: We have products deployed until 2040. What should we do?

    The first question is about algorithms. The second is about migration, compatibility, deployment, support commitments, operational risk, and occasionally existential philosophy. I wish I had that kind of foresight, to predict today what your cryptography strategy should be in 2040. I'd open a fortune-teller booth at the Vienna Prater and retire comfortably.

    The algorithms are arriving. The difficult part starts when they have to coexist with existing deployments, old devices, compatibility requirements, support commitments, and customers who are understandably reluctant to rebuild half their infrastructure because mathematicians had a breakthrough.

    For now, the tool distinguishes between three states:

    • NOT PQC READY: Bad. You're screwed.
    • PQC READY, CONNECTIVITY ISSUE: Less bad. At best, you're temporarily screwed. Check your LAN cable.
    • PQC READY: Good enough to continue the conversation.

    Naturally I pointed it at www.qt.io. If you're writing a Qt utility, who better to talk to than Qt?
    The test succeeded. TLS worked. A modern cipher suite was negotiated. OpenSSL behaved. The internet did not end.
    Which is approximately the best outcome one should expect when experimenting with cryptography before lunch.
    The real takeaway is not that a hundred-line utility solves post-quantum cryptography. It doesn't.
    But there is value in a tiny tool that answers a practical question:
    => Given this machine, right now, am I at least moving in the right direction?

    Needless to say that this is no more than my personal take on the matter. But running the tool on my computer lets me depart into the weekend with the warm comfortable feeling, that I'm not screwed. For now.
    Because sometimes a hundred lines of code are worth more than 70 pages of strategy. Even in cryptography. Especially in cryptography.

    #include <QCoreApplication>
    #include <QEventLoop>
    #include <QRegularExpression>
    #include <QSslCipher>
    #include <QSslSocket>
    #include <QTimer>
    
    static bool isOpenSsl35OrNewer(const QString &versionString)
    {
        static QRegularExpression re(R"(OpenSSL\s+(\d+)\.(\d+))");
        const auto match = re.match(versionString);
    
        if (!match.hasMatch())
            return false;
    
        const int major = match.captured(1).toInt();
        const int minor = match.captured(2).toInt();
    
        return major > 3 || (major == 3 && minor >= 5);
    }
    
    static QString protocolName(QSsl::SslProtocol protocol)
    {
        switch (protocol) {
        case QSsl::TlsV1_3:
            return QStringLiteral("TLS 1.3");
        case QSsl::TlsV1_2:
            return QStringLiteral("TLS 1.2");
        default:
            return QStringLiteral("Other");
        }
    }
    
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        const bool sslSupported = QSslSocket::supportsSsl();
        const QString backend = QSslSocket::activeBackend();
        const QString buildSsl = QSslSocket::sslLibraryBuildVersionString();
        const QString runtimeSsl = QSslSocket::sslLibraryVersionString();
    
        const bool opensslBackend =
            backend.compare(QStringLiteral("openssl"), Qt::CaseInsensitive) == 0;
    
        const bool openssl35 = isOpenSsl35OrNewer(runtimeSsl);
    
        const bool pqcReady = sslSupported && opensslBackend && openssl35;
    
        bool tlsConnected = false;
        QString cipherName;
        QString tlsProtocol;
        QString errorString;
    
        QSslSocket socket;
        QEventLoop loop;
    
        QObject::connect(&socket, &QSslSocket::encrypted, &socket, [&] {
            tlsConnected = true;
            cipherName = socket.sessionCipher().name();
            tlsProtocol = protocolName(socket.sessionProtocol());
            loop.quit();
        });
    
        QObject::connect(&socket,
                         &QSslSocket::errorOccurred,&socket,
                         [&](QAbstractSocket::SocketError) {
            errorString = socket.errorString();
            loop.quit();
        });
    
        QTimer timeout;
        timeout.setSingleShot(true);
    
        QObject::connect(&timeout, &QTimer::timeout, &socket, [&] {
            errorString = QStringLiteral("Connection timeout");
            loop.quit();
        });
    
        timeout.start(10000);
        socket.connectToHostEncrypted(QStringLiteral("www.qt.io"), 443);
        loop.exec();
    
        qInfo().noquote() << "========================================";
        qInfo().noquote() << "Qt PQC Readiness Check";
        qInfo().noquote() << "========================================";
        qInfo().noquote() << "Qt Version:      " << qVersion();
        qInfo().noquote() << "TLS Backend:     " << backend;
        qInfo().noquote() << "Build OpenSSL:   " << buildSsl;
        qInfo().noquote() << "Runtime OpenSSL: " << runtimeSsl;
    
        qInfo().noquote() << (sslSupported ? "[PASS] TLS support available"
                                           : "[FAIL] TLS support unavailable");
        qInfo().noquote() << (opensslBackend ? "[PASS] OpenSSL backend active"
                                             : "[FAIL] OpenSSL backend not active");
        qInfo().noquote() << (openssl35 ? "[PASS] OpenSSL 3.5+ detected"
                                        : "[FAIL] OpenSSL 3.5+ required");
    
        qInfo().noquote() << (pqcReady ? "Environment: PQC-CAPABLE"
                                       : "Environment: NOT PQC-CAPABLE");
    
        if (tlsConnected) {
            qInfo().noquote() << "[PASS] Connected to www.qt.io";
            qInfo().noquote() << "Protocol: " << tlsProtocol;
            qInfo().noquote() << "Cipher:   " << cipherName;
        } else {
            qInfo().noquote() << "[FAIL] Connection failed";
            qInfo().noquote() << "Reason:   " << errorString;
        }
    
        qInfo().noquote() << (pqcReady && tlsConnected
                                  ? "RESULT: PQC READY"
                                  : pqcReady
                                        ? "RESULT: PQC READY, CONNECTIVITY ISSUE"
                                        : "RESULT: NOT PQC READY");
    
        return pqcReady ? 0 : 1;
    }
    

    Software Engineer
    The Qt Company, Oslo

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      What about ENOPROTOOPT rather than 1 ?

      (Nice idea BTW)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved