Use QList instead of QVector in network

Task-number: QTBUG-84469
Change-Id: I7827da68e73ca8ff1e599c836f2157894c452b63
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Jarek Kobus 2020-06-22 12:25:41 +02:00
parent db61e43c81
commit 0e6f6507d5
32 changed files with 127 additions and 135 deletions

View File

@ -40,7 +40,6 @@
#include "qhsts_p.h"
#include "QtCore/private/qipaddress_p.h"
#include "QtCore/qvector.h"
#include "QtCore/qlist.h"
#if QT_CONFIG(settings)
@ -93,7 +92,7 @@ void QHstsCache::updateFromHeaders(const QList<QPair<QByteArray, QByteArray>> &h
}
}
void QHstsCache::updateFromPolicies(const QVector<QHstsPolicy> &policies)
void QHstsCache::updateFromPolicies(const QList<QHstsPolicy> &policies)
{
for (const auto &policy : policies)
updateKnownHost(policy.host(), policy.expiry(), policy.includesSubDomains());
@ -227,9 +226,9 @@ void QHstsCache::clear()
knownHosts.clear();
}
QVector<QHstsPolicy> QHstsCache::policies() const
QList<QHstsPolicy> QHstsCache::policies() const
{
QVector<QHstsPolicy> values;
QList<QHstsPolicy> values;
values.reserve(int(knownHosts.size()));
for (const auto &host : knownHosts)
values << host.second;
@ -250,7 +249,7 @@ void QHstsCache::setStore(QHstsStore *store)
// (and thus the cached policy takes priority over whatever policy we
// had in the store for the same host, if any).
if (knownHosts.size()) {
const QVector<QHstsPolicy> observed(policies());
const QList<QHstsPolicy> observed(policies());
for (const auto &policy : observed)
hstsStore->addToObserved(policy);
hstsStore->synchronize();
@ -260,7 +259,7 @@ void QHstsCache::setStore(QHstsStore *store)
// the store knows about (well, it can happen we synchronize again as a
// result if some policies managed to expire or if we add a new one
// from the store to cache):
const QVector<QHstsPolicy> restored(store->readPolicies());
const QList<QHstsPolicy> restored(store->readPolicies());
updateFromPolicies(restored);
}
}

View File

@ -73,13 +73,13 @@ public:
void updateFromHeaders(const QList<QPair<QByteArray, QByteArray>> &headers,
const QUrl &url);
void updateFromPolicies(const QVector<QHstsPolicy> &hosts);
void updateFromPolicies(const QList<QHstsPolicy> &hosts);
void updateKnownHost(const QUrl &url, const QDateTime &expires,
bool includeSubDomains);
bool isKnownHost(const QUrl &url) const;
void clear();
QVector<QHstsPolicy> policies() const;
QList<QHstsPolicy> policies() const;
#if QT_CONFIG(settings)
void setStore(class QHstsStore *store);

View File

@ -76,13 +76,13 @@ QHstsStore::~QHstsStore()
synchronize();
}
QVector<QHstsPolicy> QHstsStore::readPolicies()
QList<QHstsPolicy> QHstsStore::readPolicies()
{
// This function only attempts to read policies, making no decision about
// expired policies. It's up to a user (QHstsCache) to mark these policies
// for deletion and sync the store later. But we immediately remove keys/values
// (if the store isWritable) for the policies that we fail to read.
QVector<QHstsPolicy> policies;
QList<QHstsPolicy> policies;
beginHstsGroups();

View File

@ -55,8 +55,8 @@
QT_REQUIRE_CONFIG(settings);
#include <QtCore/qlist.h>
#include <QtCore/qsettings.h>
#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE
@ -70,7 +70,7 @@ public:
explicit QHstsStore(const QString &dirName);
~QHstsStore();
QVector<QHstsPolicy> readPolicies();
QList<QHstsPolicy> readPolicies();
void addToObserved(const QHstsPolicy &policy);
void synchronize();
@ -84,7 +84,7 @@ private:
void evictPolicy(const QString &key);
void endHstsGroups();
QVector<QHstsPolicy> observedPolicies;
QList<QHstsPolicy> observedPolicies;
QSettings store;
Q_DISABLE_COPY_MOVE(QHstsStore)

View File

@ -42,8 +42,8 @@
#include "qnetworkaccessmanager_p.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qlist.h"
#include "QtCore/qurl.h"
#include "QtCore/qvector.h"
#include "QtCore/QMutexLocker"
#include "QtNetwork/qauthenticator.h"
@ -51,11 +51,8 @@
QT_BEGIN_NAMESPACE
class QNetworkAuthenticationCache: private QVector<QNetworkAuthenticationCredential>,
public QNetworkAccessCache::CacheableObject
class QNetworkAuthenticationCache : private QList<QNetworkAuthenticationCredential>,
public QNetworkAccessCache::CacheableObject
{
public:
QNetworkAuthenticationCache()
@ -89,9 +86,9 @@ public:
newCredential.password = password;
if (closestMatch)
QVector<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
QList<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
else
QVector<QNetworkAuthenticationCredential>::insert(end(), newCredential);
QList<QNetworkAuthenticationCredential>::insert(end(), newCredential);
}
}

View File

@ -64,8 +64,8 @@
#include "qnetworkreplyfileimpl_p.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qlist.h"
#include "QtCore/qurl.h"
#include "QtCore/qvector.h"
#include "QtNetwork/private/qauthenticator_p.h"
#include "QtNetwork/qsslconfiguration.h"
#include "QtNetwork/private/http2protocol_p.h"
@ -740,7 +740,7 @@ bool QNetworkAccessManager::isStrictTransportSecurityStoreEnabled() const
\sa addStrictTransportSecurityHosts(), enableStrictTransportSecurityStore(), QHstsPolicy
*/
void QNetworkAccessManager::addStrictTransportSecurityHosts(const QVector<QHstsPolicy> &knownHosts)
void QNetworkAccessManager::addStrictTransportSecurityHosts(const QList<QHstsPolicy> &knownHosts)
{
Q_D(QNetworkAccessManager);
d->stsCache.updateFromPolicies(knownHosts);
@ -755,7 +755,7 @@ void QNetworkAccessManager::addStrictTransportSecurityHosts(const QVector<QHstsP
\sa addStrictTransportSecurityHosts(), QHstsPolicy
*/
QVector<QHstsPolicy> QNetworkAccessManager::strictTransportSecurityHosts() const
QList<QHstsPolicy> QNetworkAccessManager::strictTransportSecurityHosts() const
{
Q_D(const QNetworkAccessManager);
return d->stsCache.policies();

View File

@ -43,7 +43,7 @@
#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtCore/QString>
#include <QtCore/QVector>
#include <QtCore/QList>
#include <QtCore/QObject>
#ifndef QT_NO_SSL
#include <QtNetwork/QSslConfiguration>
@ -112,8 +112,8 @@ public:
bool isStrictTransportSecurityEnabled() const;
void enableStrictTransportSecurityStore(bool enabled, const QString &storeDir = QString());
bool isStrictTransportSecurityStoreEnabled() const;
void addStrictTransportSecurityHosts(const QVector<QHstsPolicy> &knownHosts);
QVector<QHstsPolicy> strictTransportSecurityHosts() const;
void addStrictTransportSecurityHosts(const QList<QHstsPolicy> &knownHosts);
QList<QHstsPolicy> strictTransportSecurityHosts() const;
QNetworkReply *head(const QNetworkRequest &request);
QNetworkReply *get(const QNetworkRequest &request);

View File

@ -416,8 +416,8 @@ public:
}
private:
QVector<HANDLE> m_watchEvents;
QVector<HKEY> m_registryHandles;
QList<HANDLE> m_watchEvents;
QList<HKEY> m_registryHandles;
};
} // namespace

View File

@ -47,8 +47,8 @@
#include "qurl.h"
#include "private/qurltlds_p.h"
#include "private/qtldurl_p.h"
#include "QtCore/qlist.h"
#include "QtCore/qstring.h"
#include "QtCore/qvector.h"
QT_BEGIN_NAMESPACE

View File

@ -54,7 +54,7 @@
#include <QtNetwork/qsctpsocket.h>
#include <private/qtcpsocket_p.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
#include <private/qnetworkdatagram_p.h>
#include <deque>
@ -77,8 +77,8 @@ public:
int maximumChannelCount;
typedef std::deque<QIpPacketHeader> IpHeaderList;
QVector<IpHeaderList> readHeaders;
QVector<IpHeaderList> writeHeaders;
QList<IpHeaderList> readHeaders;
QList<IpHeaderList> writeHeaders;
void configureCreatedSocket() override;
};

View File

@ -42,7 +42,7 @@
#include <QtCore/qdatastream.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
#include <QDebug>
#include <limits>
@ -182,12 +182,12 @@ QAsn1Element QAsn1Element::fromInteger(unsigned int val)
return elem;
}
QAsn1Element QAsn1Element::fromVector(const QVector<QAsn1Element> &items)
QAsn1Element QAsn1Element::fromVector(const QList<QAsn1Element> &items)
{
QAsn1Element seq;
seq.mType = SequenceType;
QDataStream stream(&seq.mValue, QIODevice::WriteOnly);
for (QVector<QAsn1Element>::const_iterator it = items.cbegin(), end = items.cend(); it != end; ++it)
for (auto it = items.cbegin(), end = items.cend(); it != end; ++it)
it->write(stream);
return seq;
}
@ -300,7 +300,7 @@ QMultiMap<QByteArray, QString> QAsn1Element::toInfo() const
QAsn1Element issuerElem;
QDataStream setStream(elem.mValue);
if (issuerElem.read(setStream) && issuerElem.mType == QAsn1Element::SequenceType) {
QVector<QAsn1Element> elems = issuerElem.toVector();
const auto elems = issuerElem.toList();
if (elems.size() == 2) {
const QByteArray key = elems.front().toObjectName();
if (!key.isEmpty())
@ -335,9 +335,9 @@ qint64 QAsn1Element::toInteger(bool *ok) const
return value;
}
QVector<QAsn1Element> QAsn1Element::toVector() const
QList<QAsn1Element> QAsn1Element::toList() const
{
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
if (mType == SequenceType) {
QAsn1Element elem;
QDataStream stream(mValue);

View File

@ -153,14 +153,14 @@ public:
static QAsn1Element fromBool(bool val);
static QAsn1Element fromInteger(unsigned int val);
static QAsn1Element fromVector(const QVector<QAsn1Element> &items);
static QAsn1Element fromVector(const QList<QAsn1Element> &items);
static QAsn1Element fromObjectId(const QByteArray &id);
bool toBool(bool *ok = nullptr) const;
QDateTime toDateTime() const;
QMultiMap<QByteArray, QString> toInfo() const;
qint64 toInteger(bool *ok = nullptr) const;
QVector<QAsn1Element> toVector() const;
QList<QAsn1Element> toList() const;
QByteArray toObjectId() const;
QByteArray toObjectName() const;
QString toString() const;

View File

@ -1127,7 +1127,7 @@ QString QDtls::dtlsErrorString() const
If you want to continue connecting despite the errors that have occurred,
you must call ignoreVerificationErrors().
*/
QVector<QSslError> QDtls::peerVerificationErrors() const
QList<QSslError> QDtls::peerVerificationErrors() const
{
Q_D(const QDtls);
@ -1152,7 +1152,7 @@ QVector<QSslError> QDtls::peerVerificationErrors() const
\sa doHandshake(), resumeHandshake(), QSslError
*/
void QDtls::ignoreVerificationErrors(const QVector<QSslError> &errorsToIgnore)
void QDtls::ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore)
{
Q_D(QDtls);

View File

@ -168,8 +168,8 @@ public:
QDtlsError dtlsError() const;
QString dtlsErrorString() const;
QVector<QSslError> peerVerificationErrors() const;
void ignoreVerificationErrors(const QVector<QSslError> &errorsToIgnore);
QList<QSslError> peerVerificationErrors() const;
void ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore);
Q_SIGNALS:

View File

@ -1281,7 +1281,7 @@ QSslError _q_OpenSSL_to_QSslError(int errorCode, const QSslCertificate &cert);
bool QDtlsPrivateOpenSSL::verifyPeer()
{
// DTLSTODO: Windows-specific code for CA fetcher is not here yet.
QVector<QSslError> errors;
QList<QSslError> errors;
// Check the whole chain for blacklisting (including root, as we check for
// subjectInfo and issuer)
@ -1344,7 +1344,7 @@ bool QDtlsPrivateOpenSSL::tlsErrorsWereIgnored() const
{
// check whether the errors we got are all in the list of expected errors
// (applies only if the method QDtlsConnection::ignoreTlsErrors(const
// QVector<QSslError> &errors) was called)
// QList<QSslError> &errors) was called)
for (const QSslError &error : tlsErrors) {
if (!tlsErrorsToIgnore.contains(error))
return false;

View File

@ -54,10 +54,10 @@
#include <QtNetwork/qsslpresharedkeyauthenticator.h>
#include <QtNetwork/qhostaddress.h>
#include <QtCore/qcryptographichash.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qvector.h>
#include <QtCore/qcryptographichash.h>
#include <QtCore/qlist.h>
#include <QtCore/qsharedpointer.h>
//
// W A R N I N G
@ -100,7 +100,7 @@ public:
QHostAddress remoteAddress;
quint16 remotePort = 0;
QVector<QSslErrorEntry> x509Errors;
QList<QSslErrorEntry> x509Errors;
long peeking = false;
QUdpSocket *udpSocket = nullptr;
@ -173,7 +173,7 @@ private:
void reportTimeout();
void resetDtls();
QVector<QSslErrorEntry> opensslErrors;
QList<QSslErrorEntry> opensslErrors;
dtlsopenssl::DtlsState dtls;
// We have to externally handle timeouts since we have non-blocking

View File

@ -144,8 +144,8 @@ public:
QDtls::HandshakeState handshakeState = QDtls::HandshakeNotStarted;
QVector<QSslError> tlsErrors;
QVector<QSslError> tlsErrorsToIgnore;
QList<QSslError> tlsErrors;
QList<QSslError> tlsErrorsToIgnore;
bool connectionEncrypted = false;
};

View File

@ -484,9 +484,9 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
return false;
QVariantMap result;
const auto elems = val.toVector();
const auto elems = val.toList();
for (const QAsn1Element &el : elems) {
QVector<QAsn1Element> items = el.toVector();
const auto items = el.toList();
if (items.size() != 2)
return false;
const QString key = QString::fromLatin1(items.at(0).toObjectName());
@ -510,7 +510,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
return false;
QVariantMap result;
QVector<QAsn1Element> items = val.toVector();
const auto items = val.toList();
if (items.size() > 0) {
result[QStringLiteral("ca")] = items.at(0).toBool(&ok);
if (!ok)
@ -529,7 +529,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
return false;
QVariantMap result;
const auto elems = val.toVector();
const auto elems = val.toList();
for (const QAsn1Element &el : elems) {
if (el.type() == 0x80) {
const QString key = QStringLiteral("keyid");

View File

@ -858,7 +858,7 @@ QSslKey QSslConfiguration::ephemeralServerKey() const
\sa setEllipticCurves
*/
QVector<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
QList<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
{
return d->ellipticCurves;
}
@ -875,7 +875,7 @@ QVector<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
\sa ellipticCurves
*/
void QSslConfiguration::setEllipticCurves(const QVector<QSslEllipticCurve> &curves)
void QSslConfiguration::setEllipticCurves(const QList<QSslEllipticCurve> &curves)
{
d->ellipticCurves = curves;
}
@ -889,7 +889,7 @@ void QSslConfiguration::setEllipticCurves(const QVector<QSslEllipticCurve> &curv
\sa ellipticCurves(), setEllipticCurves()
*/
QVector<QSslEllipticCurve> QSslConfiguration::supportedEllipticCurves()
QList<QSslEllipticCurve> QSslConfiguration::supportedEllipticCurves()
{
return QSslSocketPrivate::supportedEllipticCurves();
}

View File

@ -148,9 +148,9 @@ public:
QSslKey ephemeralServerKey() const;
// EC settings
QVector<QSslEllipticCurve> ellipticCurves() const;
void setEllipticCurves(const QVector<QSslEllipticCurve> &curves);
static QVector<QSslEllipticCurve> supportedEllipticCurves();
QList<QSslEllipticCurve> ellipticCurves() const;
void setEllipticCurves(const QList<QSslEllipticCurve> &curves);
static QList<QSslEllipticCurve> supportedEllipticCurves();
QByteArray preSharedKeyIdentityHint() const;
void setPreSharedKeyIdentityHint(const QByteArray &hint);

View File

@ -120,7 +120,7 @@ public:
Q_AUTOTEST_EXPORT static const QSsl::SslOptions defaultSslOptions;
QVector<QSslEllipticCurve> ellipticCurves;
QList<QSslEllipticCurve> ellipticCurves;
QSslDiffieHellmanParameters dhParams;

View File

@ -658,7 +658,7 @@ init_context:
q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
#endif // !OPENSSL_NO_PSK
const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
const auto qcurves = sslContext->sslConfiguration.ellipticCurves();
if (!qcurves.isEmpty()) {
#ifdef OPENSSL_NO_EC
sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version with disabled elliptic curves"));

View File

@ -271,27 +271,23 @@ QByteArray QSslKeyPrivate::derFromPem(const QByteArray &pem, QMap<QByteArray, QB
bool QSslKeyPrivate::isEncryptedPkcs8(const QByteArray &der) const
{
static const QVector<QByteArray> pbes1OIds {
static const QList<QByteArray> pbes1OIds {
// PKCS5
{PKCS5_MD2_DES_CBC_OID},
{PKCS5_MD2_RC2_CBC_OID},
{PKCS5_MD5_DES_CBC_OID},
{PKCS5_MD5_RC2_CBC_OID},
{PKCS5_SHA1_DES_CBC_OID},
{PKCS5_SHA1_RC2_CBC_OID},
{ PKCS5_MD2_DES_CBC_OID }, { PKCS5_MD2_RC2_CBC_OID }, { PKCS5_MD5_DES_CBC_OID },
{ PKCS5_MD5_RC2_CBC_OID }, { PKCS5_SHA1_DES_CBC_OID }, { PKCS5_SHA1_RC2_CBC_OID },
};
QAsn1Element elem;
if (!elem.read(der) || elem.type() != QAsn1Element::SequenceType)
return false;
const QVector<QAsn1Element> items = elem.toVector();
const auto items = elem.toList();
if (items.size() != 2
|| items[0].type() != QAsn1Element::SequenceType
|| items[1].type() != QAsn1Element::OctetStringType) {
return false;
}
const QVector<QAsn1Element> encryptionSchemeContainer = items[0].toVector();
const auto encryptionSchemeContainer = items[0].toList();
if (encryptionSchemeContainer.size() != 2
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
|| encryptionSchemeContainer[1].type() != QAsn1Element::SequenceType) {

View File

@ -195,7 +195,8 @@ void QSslKeyPrivate::clear(bool deep)
keyLength = -1;
}
static int extractPkcs8KeyLength(const QVector<QAsn1Element> &items, QSslKeyPrivate *that) {
static int extractPkcs8KeyLength(const QList<QAsn1Element> &items, QSslKeyPrivate *that)
{
Q_ASSERT(items.size() == 3);
int keyLength;
@ -210,7 +211,7 @@ static int extractPkcs8KeyLength(const QVector<QAsn1Element> &items, QSslKeyPriv
Q_UNREACHABLE();
};
const QVector<QAsn1Element> pkcs8Info = items[1].toVector();
const auto pkcs8Info = items[1].toList();
if (pkcs8Info.size() != 2 || pkcs8Info[0].type() != QAsn1Element::ObjectIdentifierType)
return -1;
const QByteArray value = pkcs8Info[0].toObjectId();
@ -252,7 +253,7 @@ static int extractPkcs8KeyLength(const QVector<QAsn1Element> &items, QSslKeyPriv
// https://www.cryptsoft.com/pkcs11doc/STANDARD/v201-95.pdf in section 11.9.
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
return -1;
const QVector<QAsn1Element> dsaInfo = pkcs8Info[1].toVector();
const auto dsaInfo = pkcs8Info[1].toList();
if (dsaInfo.size() != 3 || dsaInfo[0].type() != QAsn1Element::IntegerType)
return -1;
keyLength = numberOfBits(dsaInfo[0].value());
@ -267,7 +268,7 @@ static int extractPkcs8KeyLength(const QVector<QAsn1Element> &items, QSslKeyPriv
// https://www.cryptsoft.com/pkcs11doc/STANDARD/v201-95.pdf in section 11.9.
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
return -1;
const QVector<QAsn1Element> dhInfo = pkcs8Info[1].toVector();
const auto dhInfo = pkcs8Info[1].toList();
if (dhInfo.size() < 2 || dhInfo.size() > 3 || dhInfo[0].type() != QAsn1Element::IntegerType)
return -1;
keyLength = numberOfBits(dhInfo[0].value());
@ -298,7 +299,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
QDataStream keyStream(elem.value());
if (!elem.read(keyStream) || elem.type() != QAsn1Element::SequenceType)
return;
const QVector<QAsn1Element> infoItems = elem.toVector();
const auto infoItems = elem.toList();
if (infoItems.size() < 2 || infoItems[0].type() != QAsn1Element::ObjectIdentifierType)
return;
if (algorithm == QSsl::Rsa) {
@ -318,7 +319,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
if (infoItems[1].type() != QAsn1Element::SequenceType)
return;
// key params
const QVector<QAsn1Element> params = infoItems[1].toVector();
const auto params = infoItems[1].toList();
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
return;
keyLength = numberOfBits(params[0].value());
@ -328,7 +329,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
if (infoItems[1].type() != QAsn1Element::SequenceType)
return;
// key params
const QVector<QAsn1Element> params = infoItems[1].toVector();
const auto params = infoItems[1].toList();
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
return;
keyLength = numberOfBits(params[0].value());
@ -341,7 +342,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
}
} else {
const QVector<QAsn1Element> items = elem.toVector();
const auto items = elem.toList();
if (items.isEmpty())
return;
@ -497,7 +498,7 @@ struct EncryptionData
QByteArray iv;
};
static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByteArray &passPhrase)
static EncryptionData readPbes2(const QList<QAsn1Element> &element, const QByteArray &passPhrase)
{
// RFC 8018: https://tools.ietf.org/html/rfc8018#section-6.2
/*** Scheme: ***
@ -534,7 +535,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
// @todo: AES(, rc5?)
};
const QVector<QAsn1Element> keyDerivationContainer = element[0].toVector();
const QList<QAsn1Element> keyDerivationContainer = element[0].toList();
if (keyDerivationContainer.size() != 2
|| keyDerivationContainer[0].type() != QAsn1Element::ObjectIdentifierType
|| keyDerivationContainer[1].type() != QAsn1Element::SequenceType) {
@ -542,9 +543,9 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
}
const QByteArray keyDerivationAlgorithm = keyDerivationContainer[0].toObjectId();
const QVector<QAsn1Element> keyDerivationParams = keyDerivationContainer[1].toVector();
const auto keyDerivationParams = keyDerivationContainer[1].toList();
const QVector<QAsn1Element> encryptionAlgorithmContainer = element[1].toVector();
const auto encryptionAlgorithmContainer = element[1].toList();
if (encryptionAlgorithmContainer.size() != 2
|| encryptionAlgorithmContainer[0].type() != QAsn1Element::ObjectIdentifierType) {
return {};
@ -588,7 +589,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
*/
if (encryptionAlgorithmContainer[1].type() != QAsn1Element::SequenceType)
return {};
const QVector<QAsn1Element> rc2ParametersContainer = encryptionAlgorithmContainer[1].toVector();
const auto rc2ParametersContainer = encryptionAlgorithmContainer[1].toList();
if ((rc2ParametersContainer.size() != 1 && rc2ParametersContainer.size() != 2)
|| rc2ParametersContainer.back().type() != QAsn1Element::OctetStringType) {
return {};
@ -636,7 +637,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
QCryptographicHash::Algorithm hashAlgorithm = QCryptographicHash::Sha1;
if (keyDerivationParams.size() > vectorPos
&& keyDerivationParams[vectorPos].type() == QAsn1Element::SequenceType) {
QVector<QAsn1Element> hashAlgorithmContainer = keyDerivationParams[vectorPos].toVector();
const auto hashAlgorithmContainer = keyDerivationParams[vectorPos].toList();
hashAlgorithm = pbes2OidHashFunctionMap[hashAlgorithmContainer.front().toObjectId()];
Q_ASSERT(hashAlgorithmContainer[1].type() == QAsn1Element::NullType);
++vectorPos;
@ -675,8 +676,8 @@ static const QMap<QByteArray, QCryptographicHash::Algorithm> pbes1OidHashFunctio
// {PKCS12_SHA1_RC2_40_CBC_OID, QCryptographicHash::Sha1}
};
static EncryptionData readPbes1(const QVector<QAsn1Element> &element, const QByteArray &encryptionScheme, const QByteArray &passPhrase)
static EncryptionData readPbes1(const QList<QAsn1Element> &element,
const QByteArray &encryptionScheme, const QByteArray &passPhrase)
{
// RFC 8018: https://tools.ietf.org/html/rfc8018#section-6.1
// Steps refer to this section: https://tools.ietf.org/html/rfc8018#section-6.1.2
@ -733,14 +734,14 @@ QByteArray QSslKeyPrivate::decryptPkcs8(const QByteArray &encrypted, const QByte
if (!elem.read(encrypted) || elem.type() != QAsn1Element::SequenceType)
return encrypted;
const QVector<QAsn1Element> items = elem.toVector();
const auto items = elem.toList();
if (items.size() != 2
|| items[0].type() != QAsn1Element::SequenceType
|| items[1].type() != QAsn1Element::OctetStringType) {
return encrypted;
}
const QVector<QAsn1Element> encryptionSchemeContainer = items[0].toVector();
const auto encryptionSchemeContainer = items[0].toList();
if (encryptionSchemeContainer.size() != 2
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
@ -749,7 +750,7 @@ QByteArray QSslKeyPrivate::decryptPkcs8(const QByteArray &encrypted, const QByte
}
const QByteArray encryptionScheme = encryptionSchemeContainer[0].toObjectId();
const QVector<QAsn1Element> schemeParameterContainer = encryptionSchemeContainer[1].toVector();
const auto schemeParameterContainer = encryptionSchemeContainer[1].toList();
if (schemeParameterContainer.size() != 2
&& schemeParameterContainer[0].type() != QAsn1Element::SequenceType

View File

@ -488,7 +488,7 @@ public:
QMutex mutex;
QList<QSslCipher> supportedCiphers;
QVector<QSslEllipticCurve> supportedEllipticCurves;
QList<QSslEllipticCurve> supportedEllipticCurves;
QExplicitlySharedDataPointer<QSslConfigurationPrivate> config;
QExplicitlySharedDataPointer<QSslConfigurationPrivate> dtlsConfig;
};
@ -1296,12 +1296,12 @@ QSsl::SslProtocol QSslSocket::sessionProtocol() const
\since 5.13
This function returns Online Certificate Status Protocol responses that
a server may send during a TLS handshake using OCSP stapling. The vector
a server may send during a TLS handshake using OCSP stapling. The list
is empty if no definitive response or no response at all was received.
\sa QSslConfiguration::setOcspStaplingEnabled()
*/
QVector<QOcspResponse> QSslSocket::ocspResponses() const
QList<QOcspResponse> QSslSocket::ocspResponses() const
{
Q_D(const QSslSocket);
return d->ocspResponses;
@ -2061,7 +2061,7 @@ QList<QSslCipher> q_getDefaultDtlsCiphers()
/*!
\internal
*/
QVector<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
QList<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
{
QSslSocketPrivate::ensureInitialized();
const QMutexLocker locker(&globalData()->mutex);
@ -2071,7 +2071,7 @@ QVector<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
/*!
\internal
*/
void QSslSocketPrivate::setDefaultSupportedEllipticCurves(const QVector<QSslEllipticCurve> &curves)
void QSslSocketPrivate::setDefaultSupportedEllipticCurves(const QList<QSslEllipticCurve> &curves)
{
const QMutexLocker locker(&globalData()->mutex);
globalData()->config.detach();

View File

@ -43,7 +43,6 @@
#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qvector.h>
#ifndef QT_NO_SSL
# include <QtNetwork/qtcpsocket.h>
# include <QtNetwork/qsslerror.h>
@ -187,7 +186,7 @@ public:
QList<QSslCertificate> peerCertificateChain() const;
QSslCipher sessionCipher() const;
QSsl::SslProtocol sessionProtocol() const;
QVector<QOcspResponse> ocspResponses() const;
QList<QOcspResponse> ocspResponses() const;
// Private keys, for server sockets.
void setPrivateKey(const QSslKey &key);

View File

@ -53,7 +53,7 @@
#include <QtCore/qsystemdetection.h>
#include <QtCore/qdatastream.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
#include <QtCore/qmutex.h>
#include <QtCore/qdebug.h>
#include <QtCore/quuid.h>
@ -332,7 +332,7 @@ void QSslSocketPrivate::ensureInitialized()
size_t numCiphers = 0;
// Fails only if any of parameters is null.
SSLGetNumberSupportedCiphers(context, &numCiphers);
QVector<SSLCipherSuite> cfCiphers(numCiphers);
QList<SSLCipherSuite> cfCiphers(numCiphers);
// Fails only if any of parameter is null or number of ciphers is wrong.
SSLGetSupportedCiphers(context, cfCiphers.data(), &numCiphers);
@ -425,7 +425,7 @@ void QSslSocketBackendPrivate::continueHandshake()
const OSStatus result = SSLCopyALPNProtocols(context, &cfArray);
if (result == errSecSuccess && cfArray && CFArrayGetCount(cfArray)) {
const int size = CFArrayGetCount(cfArray);
QVector<QString> peerProtocols(size);
QList<QString> peerProtocols(size);
for (int i = 0; i < size; ++i)
peerProtocols[i] = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(cfArray, i));

View File

@ -136,7 +136,7 @@ QAlertType tlsAlertType(int value)
#ifdef Q_OS_WIN
QSslCertificate findCertificateToFetch(const QVector<QSslError> &tlsErrors, bool checkAIA)
QSslCertificate findCertificateToFetch(const QList<QSslError> &tlsErrors, bool checkAIA)
{
QSslCertificate certToFetch;
@ -577,7 +577,7 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
if (!ok) {
// Store the error and at which depth the error was detected.
using ErrorListPtr = QVector<QSslErrorEntry>*;
using ErrorListPtr = QList<QSslErrorEntry> *;
ErrorListPtr errors = nullptr;
// Error list is attached to either 'SSL' or 'X509_STORE'.
@ -962,7 +962,7 @@ void QSslSocketPrivate::resetDefaultCiphers()
void QSslSocketPrivate::resetDefaultEllipticCurves()
{
QVector<QSslEllipticCurve> curves;
QList<QSslEllipticCurve> curves;
#ifndef OPENSSL_NO_EC
const size_t curveCount = q_EC_get_builtin_curves(nullptr, 0);
@ -1391,7 +1391,7 @@ bool QSslSocketBackendPrivate::startHandshake()
pendingFatalAlert = false;
errorsReportedFromCallback = false;
QVector<QSslErrorEntry> lastErrors;
QList<QSslErrorEntry> lastErrors;
q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + errorOffsetInExData, &lastErrors);
// SSL_set_ex_data can fail, but see the callback's code - we handle this there.
@ -2018,7 +2018,7 @@ int QSslSocketBackendPrivate::emitErrorFromCallback(X509_STORE_CTX *ctx)
// wants to check errors (ignored or not):
const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData
+ QSslSocketBackendPrivate::errorOffsetInExData;
if (auto errorList = static_cast<QVector<QSslErrorEntry>*>(q_SSL_get_ex_data(ssl, offset)))
if (auto errorList = static_cast<QList<QSslErrorEntry> *>(q_SSL_get_ex_data(ssl, offset)))
errorList->append(errorAndDepth);
// An application is expected to ignore this error (by calling ignoreSslErrors)
@ -2336,7 +2336,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
}
}
QVector<QSslErrorEntry> lastErrors;
QList<QSslErrorEntry> lastErrors;
if (!q_X509_STORE_set_ex_data(certStore, 0, &lastErrors)) {
qCWarning(lcSsl) << "Unable to attach external data (error list) to a store";
errors << QSslError(QSslError::UnspecifiedError);

View File

@ -69,7 +69,7 @@
#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslsocket_p.h"
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
#ifdef Q_OS_WIN
@ -129,7 +129,7 @@ public:
BIO *readBio;
BIO *writeBio;
SSL_SESSION *session;
QVector<QSslErrorEntry> errorList;
QList<QSslErrorEntry> errorList;
static int s_indexForSSLExtraData; // index used in SSL_get_ex_data to get the matching QSslSocketBackendPrivate
enum ExDataOffset {
errorOffsetInExData = 1,
@ -174,7 +174,7 @@ public:
// This decription will go to setErrorAndEmit(SslHandshakeError, ocspErrorDescription)
QString ocspErrorDescription;
// These will go to sslErrors()
QVector<QSslError> ocspErrors;
QList<QSslError> ocspErrors;
QByteArray ocspResponseDer;
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);

View File

@ -554,8 +554,8 @@ struct LibGreaterThan
typedef bool result_type;
result_type operator()(QStringView lhs, QStringView rhs) const
{
const QVector<QStringView> lhsparts = lhs.split(QLatin1Char('.'));
const QVector<QStringView> rhsparts = rhs.split(QLatin1Char('.'));
const auto lhsparts = lhs.split(QLatin1Char('.'));
const auto rhsparts = rhs.split(QLatin1Char('.'));
Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
// note: checking rhs < lhs, the same as lhs > rhs

View File

@ -65,8 +65,8 @@
class QSslContext;
#endif
#include <QtCore/qlist.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qvector.h>
#include <private/qringbuffer_p.h>
#if defined(Q_OS_MAC)
@ -146,8 +146,8 @@ public:
static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers);
static void resetDefaultCiphers();
static QVector<QSslEllipticCurve> supportedEllipticCurves();
static void setDefaultSupportedEllipticCurves(const QVector<QSslEllipticCurve> &curves);
static QList<QSslEllipticCurve> supportedEllipticCurves();
static void setDefaultSupportedEllipticCurves(const QList<QSslEllipticCurve> &curves);
static void resetDefaultEllipticCurves();
static QList<QSslCertificate> defaultCaCertificates();
@ -219,7 +219,7 @@ protected:
bool paused;
bool flushTriggered;
bool systemOrSslErrorDetected = false;
QVector<QOcspResponse> ocspResponses;
QList<QOcspResponse> ocspResponses;
bool handshakeInterrupted = false;
bool fetchAuthorityInformation = false;
};

View File

@ -61,7 +61,7 @@ static QAsn1Element wrap(quint8 type, const QAsn1Element &child)
static QAsn1Element _q_PKCS7_data(const QByteArray &data)
{
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
items << QAsn1Element::fromObjectId("1.2.840.113549.1.7.1");
items << wrap(QAsn1Element::Context0Type,
QAsn1Element(QAsn1Element::OctetStringType, data));
@ -145,11 +145,11 @@ static QByteArray _q_PKCS12_salt()
static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
{
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.3");
// certificate
QVector<QAsn1Element> certItems;
QList<QAsn1Element> certItems;
certItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.22.1");
certItems << wrap(QAsn1Element::Context0Type,
QAsn1Element(QAsn1Element::OctetStringType, cert.toDer()));
@ -158,7 +158,7 @@ static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
// local key id
const QByteArray localKeyId = cert.digest(QCryptographicHash::Sha1);
QVector<QAsn1Element> idItems;
QList<QAsn1Element> idItems;
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
idItems << wrap(QAsn1Element::SetType,
QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
@ -176,9 +176,9 @@ static QAsn1Element _q_PKCS12_key(const QSslKey &key)
{
Q_ASSERT(key.algorithm() == QSsl::Rsa || key.algorithm() == QSsl::Dsa);
QVector<QAsn1Element> keyItems;
QList<QAsn1Element> keyItems;
keyItems << QAsn1Element::fromInteger(0);
QVector<QAsn1Element> algoItems;
QList<QAsn1Element> algoItems;
if (key.algorithm() == QSsl::Rsa)
algoItems << QAsn1Element::fromObjectId(RSA_ENCRYPTION_OID);
else if (key.algorithm() == QSsl::Dsa)
@ -203,14 +203,14 @@ static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &pa
QByteArray crypted = QSslKeyPrivate::encrypt(QSslKeyPrivate::DesEde3Cbc,
plain, cKey, cIv);
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2");
// key
QVector<QAsn1Element> keyItems;
QVector<QAsn1Element> algoItems;
QList<QAsn1Element> keyItems;
QList<QAsn1Element> algoItems;
algoItems << QAsn1Element::fromObjectId("1.2.840.113549.1.12.1.3");
QVector<QAsn1Element> paramItems;
QList<QAsn1Element> paramItems;
paramItems << QAsn1Element(QAsn1Element::OctetStringType, salt);
paramItems << QAsn1Element::fromInteger(iterations);
algoItems << QAsn1Element::fromVector(paramItems);
@ -220,7 +220,7 @@ static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &pa
QAsn1Element::fromVector(keyItems));
// local key id
QVector<QAsn1Element> idItems;
QList<QAsn1Element> idItems;
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
idItems << wrap(QAsn1Element::SetType,
QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
@ -237,7 +237,7 @@ static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &pa
static QByteArray _q_PKCS12_bag(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
{
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
// certs
for (int i = 0; i < certs.size(); ++i)
@ -269,15 +269,15 @@ static QAsn1Element _q_PKCS12_mac(const QByteArray &data, const QString &passPhr
QMessageAuthenticationCode hmac(QCryptographicHash::Sha1, key);
hmac.addData(data);
QVector<QAsn1Element> algoItems;
QList<QAsn1Element> algoItems;
algoItems << QAsn1Element::fromObjectId("1.3.14.3.2.26");
algoItems << QAsn1Element(QAsn1Element::NullType);
QVector<QAsn1Element> digestItems;
QList<QAsn1Element> digestItems;
digestItems << QAsn1Element::fromVector(algoItems);
digestItems << QAsn1Element(QAsn1Element::OctetStringType, hmac.result());
QVector<QAsn1Element> macItems;
QList<QAsn1Element> macItems;
macItems << QAsn1Element::fromVector(digestItems);
macItems << QAsn1Element(QAsn1Element::OctetStringType, macSalt);
macItems << QAsn1Element::fromInteger(iterations);
@ -286,7 +286,7 @@ static QAsn1Element _q_PKCS12_mac(const QByteArray &data, const QString &passPhr
QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
{
QVector<QAsn1Element> items;
QList<QAsn1Element> items;
// version
items << QAsn1Element::fromInteger(3);