summaryrefslogtreecommitdiffstats
path: root/src/plugins/tls/openssl/qdtls_openssl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/tls/openssl/qdtls_openssl.cpp')
-rw-r--r--src/plugins/tls/openssl/qdtls_openssl.cpp62
1 files changed, 11 insertions, 51 deletions
diff --git a/src/plugins/tls/openssl/qdtls_openssl.cpp b/src/plugins/tls/openssl/qdtls_openssl.cpp
index a1f2c707f9..fc07a29ec8 100644
--- a/src/plugins/tls/openssl/qdtls_openssl.cpp
+++ b/src/plugins/tls/openssl/qdtls_openssl.cpp
@@ -1,47 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif // NOMINMAX
-
-#include <QtNetwork/private/qnativesocketengine_p.h>
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include <QtNetwork/private/qnativesocketengine_p_p.h>
#include "qsslsocket_openssl_symbols_p.h"
#include "qdtls_openssl_p.h"
@@ -218,7 +178,7 @@ extern "C" int q_generate_cookie_callback(SSL *ssl, unsigned char *dst,
QMessageAuthenticationCode hmac(dtls->hashAlgorithm, dtls->secret);
hmac.addData(peerData);
- const QByteArray cookie = hmac.result();
+ const QByteArrayView cookie = hmac.resultView();
Q_ASSERT(cookie.size() >= 0);
// DTLS1_COOKIE_LENGTH is erroneously 256 bytes long, must be 255 - RFC 6347, 4.2.1.
*cookieLength = qMin(DTLS1_COOKIE_LENGTH - 1, cookie.size());
@@ -241,7 +201,7 @@ extern "C" int q_verify_cookie_callback(SSL *ssl, const unsigned char *cookie,
return 0;
return newCookieLength == cookieLength
- && !std::memcmp(cookie, newCookie, cookieLength);
+ && !q_CRYPTO_memcmp(cookie, newCookie, size_t(cookieLength));
}
extern "C" int q_X509DtlsCallback(int ok, X509_STORE_CTX *ctx)
@@ -653,7 +613,7 @@ bool DtlsState::initTls(QDtlsBasePrivate *dtlsBase)
static QString msgFunctionFailed(const char *function)
{
//: %1: Some function
- return QDtls::tr("%1 failed").arg(QLatin1String(function));
+ return QDtls::tr("%1 failed").arg(QLatin1StringView(function));
}
bool DtlsState::initCtxAndConnection(QDtlsBasePrivate *dtlsBase)
@@ -1288,12 +1248,12 @@ unsigned QDtlsPrivateOpenSSL::pskClientCallback(const char *hint, char *identity
return 0;
// Copy data back into OpenSSL
- const int identityLength = qMin(pskAuthenticator.identity().length(),
+ const int identityLength = qMin(pskAuthenticator.identity().size(),
pskAuthenticator.maximumIdentityLength());
std::memcpy(identity, pskAuthenticator.identity().constData(), identityLength);
identity[identityLength] = 0;
- const int pskLength = qMin(pskAuthenticator.preSharedKey().length(),
+ const int pskLength = qMin(pskAuthenticator.preSharedKey().size(),
pskAuthenticator.maximumPreSharedKeyLength());
std::memcpy(psk, pskAuthenticator.preSharedKey().constData(), pskLength);
@@ -1319,7 +1279,7 @@ unsigned QDtlsPrivateOpenSSL::pskServerCallback(const char *identity, unsigned c
return 0;
// Copy data back into OpenSSL
- const int pskLength = qMin(pskAuthenticator.preSharedKey().length(),
+ const int pskLength = qMin(pskAuthenticator.preSharedKey().size(),
pskAuthenticator.maximumPreSharedKeyLength());
std::memcpy(psk, pskAuthenticator.preSharedKey().constData(), pskLength);
@@ -1364,7 +1324,7 @@ bool QDtlsPrivateOpenSSL::verifyPeer()
// Translate errors from the error list into QSslErrors
using CertClass = QTlsPrivate::X509CertificateOpenSSL;
errors.reserve(errors.size() + opensslErrors.size());
- for (const auto &error : qAsConst(opensslErrors)) {
+ for (const auto &error : std::as_const(opensslErrors)) {
const auto value = peerCertificateChain.value(error.depth);
errors << CertClass::openSSLErrorToQSslError(error.code, value);
}