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:
parent
db61e43c81
commit
0e6f6507d5
@ -40,7 +40,6 @@
|
|||||||
#include "qhsts_p.h"
|
#include "qhsts_p.h"
|
||||||
|
|
||||||
#include "QtCore/private/qipaddress_p.h"
|
#include "QtCore/private/qipaddress_p.h"
|
||||||
#include "QtCore/qvector.h"
|
|
||||||
#include "QtCore/qlist.h"
|
#include "QtCore/qlist.h"
|
||||||
|
|
||||||
#if QT_CONFIG(settings)
|
#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)
|
for (const auto &policy : policies)
|
||||||
updateKnownHost(policy.host(), policy.expiry(), policy.includesSubDomains());
|
updateKnownHost(policy.host(), policy.expiry(), policy.includesSubDomains());
|
||||||
@ -227,9 +226,9 @@ void QHstsCache::clear()
|
|||||||
knownHosts.clear();
|
knownHosts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QHstsPolicy> QHstsCache::policies() const
|
QList<QHstsPolicy> QHstsCache::policies() const
|
||||||
{
|
{
|
||||||
QVector<QHstsPolicy> values;
|
QList<QHstsPolicy> values;
|
||||||
values.reserve(int(knownHosts.size()));
|
values.reserve(int(knownHosts.size()));
|
||||||
for (const auto &host : knownHosts)
|
for (const auto &host : knownHosts)
|
||||||
values << host.second;
|
values << host.second;
|
||||||
@ -250,7 +249,7 @@ void QHstsCache::setStore(QHstsStore *store)
|
|||||||
// (and thus the cached policy takes priority over whatever policy we
|
// (and thus the cached policy takes priority over whatever policy we
|
||||||
// had in the store for the same host, if any).
|
// had in the store for the same host, if any).
|
||||||
if (knownHosts.size()) {
|
if (knownHosts.size()) {
|
||||||
const QVector<QHstsPolicy> observed(policies());
|
const QList<QHstsPolicy> observed(policies());
|
||||||
for (const auto &policy : observed)
|
for (const auto &policy : observed)
|
||||||
hstsStore->addToObserved(policy);
|
hstsStore->addToObserved(policy);
|
||||||
hstsStore->synchronize();
|
hstsStore->synchronize();
|
||||||
@ -260,7 +259,7 @@ void QHstsCache::setStore(QHstsStore *store)
|
|||||||
// the store knows about (well, it can happen we synchronize again as a
|
// 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
|
// result if some policies managed to expire or if we add a new one
|
||||||
// from the store to cache):
|
// from the store to cache):
|
||||||
const QVector<QHstsPolicy> restored(store->readPolicies());
|
const QList<QHstsPolicy> restored(store->readPolicies());
|
||||||
updateFromPolicies(restored);
|
updateFromPolicies(restored);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,13 @@ public:
|
|||||||
|
|
||||||
void updateFromHeaders(const QList<QPair<QByteArray, QByteArray>> &headers,
|
void updateFromHeaders(const QList<QPair<QByteArray, QByteArray>> &headers,
|
||||||
const QUrl &url);
|
const QUrl &url);
|
||||||
void updateFromPolicies(const QVector<QHstsPolicy> &hosts);
|
void updateFromPolicies(const QList<QHstsPolicy> &hosts);
|
||||||
void updateKnownHost(const QUrl &url, const QDateTime &expires,
|
void updateKnownHost(const QUrl &url, const QDateTime &expires,
|
||||||
bool includeSubDomains);
|
bool includeSubDomains);
|
||||||
bool isKnownHost(const QUrl &url) const;
|
bool isKnownHost(const QUrl &url) const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
QVector<QHstsPolicy> policies() const;
|
QList<QHstsPolicy> policies() const;
|
||||||
|
|
||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
void setStore(class QHstsStore *store);
|
void setStore(class QHstsStore *store);
|
||||||
|
@ -76,13 +76,13 @@ QHstsStore::~QHstsStore()
|
|||||||
synchronize();
|
synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QHstsPolicy> QHstsStore::readPolicies()
|
QList<QHstsPolicy> QHstsStore::readPolicies()
|
||||||
{
|
{
|
||||||
// This function only attempts to read policies, making no decision about
|
// This function only attempts to read policies, making no decision about
|
||||||
// expired policies. It's up to a user (QHstsCache) to mark these policies
|
// 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
|
// 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.
|
// (if the store isWritable) for the policies that we fail to read.
|
||||||
QVector<QHstsPolicy> policies;
|
QList<QHstsPolicy> policies;
|
||||||
|
|
||||||
beginHstsGroups();
|
beginHstsGroups();
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
QT_REQUIRE_CONFIG(settings);
|
QT_REQUIRE_CONFIG(settings);
|
||||||
|
|
||||||
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qsettings.h>
|
#include <QtCore/qsettings.h>
|
||||||
#include <QtCore/qvector.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
explicit QHstsStore(const QString &dirName);
|
explicit QHstsStore(const QString &dirName);
|
||||||
~QHstsStore();
|
~QHstsStore();
|
||||||
|
|
||||||
QVector<QHstsPolicy> readPolicies();
|
QList<QHstsPolicy> readPolicies();
|
||||||
void addToObserved(const QHstsPolicy &policy);
|
void addToObserved(const QHstsPolicy &policy);
|
||||||
void synchronize();
|
void synchronize();
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ private:
|
|||||||
void evictPolicy(const QString &key);
|
void evictPolicy(const QString &key);
|
||||||
void endHstsGroups();
|
void endHstsGroups();
|
||||||
|
|
||||||
QVector<QHstsPolicy> observedPolicies;
|
QList<QHstsPolicy> observedPolicies;
|
||||||
QSettings store;
|
QSettings store;
|
||||||
|
|
||||||
Q_DISABLE_COPY_MOVE(QHstsStore)
|
Q_DISABLE_COPY_MOVE(QHstsStore)
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
#include "qnetworkaccessmanager_p.h"
|
#include "qnetworkaccessmanager_p.h"
|
||||||
|
|
||||||
#include "QtCore/qbuffer.h"
|
#include "QtCore/qbuffer.h"
|
||||||
|
#include "QtCore/qlist.h"
|
||||||
#include "QtCore/qurl.h"
|
#include "QtCore/qurl.h"
|
||||||
#include "QtCore/qvector.h"
|
|
||||||
#include "QtCore/QMutexLocker"
|
#include "QtCore/QMutexLocker"
|
||||||
#include "QtNetwork/qauthenticator.h"
|
#include "QtNetwork/qauthenticator.h"
|
||||||
|
|
||||||
@ -51,11 +51,8 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QNetworkAuthenticationCache : private QList<QNetworkAuthenticationCredential>,
|
||||||
|
public QNetworkAccessCache::CacheableObject
|
||||||
|
|
||||||
class QNetworkAuthenticationCache: private QVector<QNetworkAuthenticationCredential>,
|
|
||||||
public QNetworkAccessCache::CacheableObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QNetworkAuthenticationCache()
|
QNetworkAuthenticationCache()
|
||||||
@ -89,9 +86,9 @@ public:
|
|||||||
newCredential.password = password;
|
newCredential.password = password;
|
||||||
|
|
||||||
if (closestMatch)
|
if (closestMatch)
|
||||||
QVector<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
|
QList<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
|
||||||
else
|
else
|
||||||
QVector<QNetworkAuthenticationCredential>::insert(end(), newCredential);
|
QList<QNetworkAuthenticationCredential>::insert(end(), newCredential);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@
|
|||||||
#include "qnetworkreplyfileimpl_p.h"
|
#include "qnetworkreplyfileimpl_p.h"
|
||||||
|
|
||||||
#include "QtCore/qbuffer.h"
|
#include "QtCore/qbuffer.h"
|
||||||
|
#include "QtCore/qlist.h"
|
||||||
#include "QtCore/qurl.h"
|
#include "QtCore/qurl.h"
|
||||||
#include "QtCore/qvector.h"
|
|
||||||
#include "QtNetwork/private/qauthenticator_p.h"
|
#include "QtNetwork/private/qauthenticator_p.h"
|
||||||
#include "QtNetwork/qsslconfiguration.h"
|
#include "QtNetwork/qsslconfiguration.h"
|
||||||
#include "QtNetwork/private/http2protocol_p.h"
|
#include "QtNetwork/private/http2protocol_p.h"
|
||||||
@ -740,7 +740,7 @@ bool QNetworkAccessManager::isStrictTransportSecurityStoreEnabled() const
|
|||||||
\sa addStrictTransportSecurityHosts(), enableStrictTransportSecurityStore(), QHstsPolicy
|
\sa addStrictTransportSecurityHosts(), enableStrictTransportSecurityStore(), QHstsPolicy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void QNetworkAccessManager::addStrictTransportSecurityHosts(const QVector<QHstsPolicy> &knownHosts)
|
void QNetworkAccessManager::addStrictTransportSecurityHosts(const QList<QHstsPolicy> &knownHosts)
|
||||||
{
|
{
|
||||||
Q_D(QNetworkAccessManager);
|
Q_D(QNetworkAccessManager);
|
||||||
d->stsCache.updateFromPolicies(knownHosts);
|
d->stsCache.updateFromPolicies(knownHosts);
|
||||||
@ -755,7 +755,7 @@ void QNetworkAccessManager::addStrictTransportSecurityHosts(const QVector<QHstsP
|
|||||||
|
|
||||||
\sa addStrictTransportSecurityHosts(), QHstsPolicy
|
\sa addStrictTransportSecurityHosts(), QHstsPolicy
|
||||||
*/
|
*/
|
||||||
QVector<QHstsPolicy> QNetworkAccessManager::strictTransportSecurityHosts() const
|
QList<QHstsPolicy> QNetworkAccessManager::strictTransportSecurityHosts() const
|
||||||
{
|
{
|
||||||
Q_D(const QNetworkAccessManager);
|
Q_D(const QNetworkAccessManager);
|
||||||
return d->stsCache.policies();
|
return d->stsCache.policies();
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include <QtNetwork/qtnetworkglobal.h>
|
#include <QtNetwork/qtnetworkglobal.h>
|
||||||
#include <QtNetwork/qnetworkrequest.h>
|
#include <QtNetwork/qnetworkrequest.h>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
#include <QtNetwork/QSslConfiguration>
|
#include <QtNetwork/QSslConfiguration>
|
||||||
@ -112,8 +112,8 @@ public:
|
|||||||
bool isStrictTransportSecurityEnabled() const;
|
bool isStrictTransportSecurityEnabled() const;
|
||||||
void enableStrictTransportSecurityStore(bool enabled, const QString &storeDir = QString());
|
void enableStrictTransportSecurityStore(bool enabled, const QString &storeDir = QString());
|
||||||
bool isStrictTransportSecurityStoreEnabled() const;
|
bool isStrictTransportSecurityStoreEnabled() const;
|
||||||
void addStrictTransportSecurityHosts(const QVector<QHstsPolicy> &knownHosts);
|
void addStrictTransportSecurityHosts(const QList<QHstsPolicy> &knownHosts);
|
||||||
QVector<QHstsPolicy> strictTransportSecurityHosts() const;
|
QList<QHstsPolicy> strictTransportSecurityHosts() const;
|
||||||
|
|
||||||
QNetworkReply *head(const QNetworkRequest &request);
|
QNetworkReply *head(const QNetworkRequest &request);
|
||||||
QNetworkReply *get(const QNetworkRequest &request);
|
QNetworkReply *get(const QNetworkRequest &request);
|
||||||
|
@ -416,8 +416,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<HANDLE> m_watchEvents;
|
QList<HANDLE> m_watchEvents;
|
||||||
QVector<HKEY> m_registryHandles;
|
QList<HKEY> m_registryHandles;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
#include "qurl.h"
|
#include "qurl.h"
|
||||||
#include "private/qurltlds_p.h"
|
#include "private/qurltlds_p.h"
|
||||||
#include "private/qtldurl_p.h"
|
#include "private/qtldurl_p.h"
|
||||||
|
#include "QtCore/qlist.h"
|
||||||
#include "QtCore/qstring.h"
|
#include "QtCore/qstring.h"
|
||||||
#include "QtCore/qvector.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
#include <QtNetwork/qsctpsocket.h>
|
#include <QtNetwork/qsctpsocket.h>
|
||||||
#include <private/qtcpsocket_p.h>
|
#include <private/qtcpsocket_p.h>
|
||||||
#include <QtCore/qbytearray.h>
|
#include <QtCore/qbytearray.h>
|
||||||
#include <QtCore/qvector.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <private/qnetworkdatagram_p.h>
|
#include <private/qnetworkdatagram_p.h>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
@ -77,8 +77,8 @@ public:
|
|||||||
int maximumChannelCount;
|
int maximumChannelCount;
|
||||||
|
|
||||||
typedef std::deque<QIpPacketHeader> IpHeaderList;
|
typedef std::deque<QIpPacketHeader> IpHeaderList;
|
||||||
QVector<IpHeaderList> readHeaders;
|
QList<IpHeaderList> readHeaders;
|
||||||
QVector<IpHeaderList> writeHeaders;
|
QList<IpHeaderList> writeHeaders;
|
||||||
|
|
||||||
void configureCreatedSocket() override;
|
void configureCreatedSocket() override;
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qdatastream.h>
|
#include <QtCore/qdatastream.h>
|
||||||
#include <QtCore/qdatetime.h>
|
#include <QtCore/qdatetime.h>
|
||||||
#include <QtCore/qvector.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -182,12 +182,12 @@ QAsn1Element QAsn1Element::fromInteger(unsigned int val)
|
|||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAsn1Element QAsn1Element::fromVector(const QVector<QAsn1Element> &items)
|
QAsn1Element QAsn1Element::fromVector(const QList<QAsn1Element> &items)
|
||||||
{
|
{
|
||||||
QAsn1Element seq;
|
QAsn1Element seq;
|
||||||
seq.mType = SequenceType;
|
seq.mType = SequenceType;
|
||||||
QDataStream stream(&seq.mValue, QIODevice::WriteOnly);
|
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);
|
it->write(stream);
|
||||||
return seq;
|
return seq;
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ QMultiMap<QByteArray, QString> QAsn1Element::toInfo() const
|
|||||||
QAsn1Element issuerElem;
|
QAsn1Element issuerElem;
|
||||||
QDataStream setStream(elem.mValue);
|
QDataStream setStream(elem.mValue);
|
||||||
if (issuerElem.read(setStream) && issuerElem.mType == QAsn1Element::SequenceType) {
|
if (issuerElem.read(setStream) && issuerElem.mType == QAsn1Element::SequenceType) {
|
||||||
QVector<QAsn1Element> elems = issuerElem.toVector();
|
const auto elems = issuerElem.toList();
|
||||||
if (elems.size() == 2) {
|
if (elems.size() == 2) {
|
||||||
const QByteArray key = elems.front().toObjectName();
|
const QByteArray key = elems.front().toObjectName();
|
||||||
if (!key.isEmpty())
|
if (!key.isEmpty())
|
||||||
@ -335,9 +335,9 @@ qint64 QAsn1Element::toInteger(bool *ok) const
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QAsn1Element> QAsn1Element::toVector() const
|
QList<QAsn1Element> QAsn1Element::toList() const
|
||||||
{
|
{
|
||||||
QVector<QAsn1Element> items;
|
QList<QAsn1Element> items;
|
||||||
if (mType == SequenceType) {
|
if (mType == SequenceType) {
|
||||||
QAsn1Element elem;
|
QAsn1Element elem;
|
||||||
QDataStream stream(mValue);
|
QDataStream stream(mValue);
|
||||||
|
@ -153,14 +153,14 @@ public:
|
|||||||
|
|
||||||
static QAsn1Element fromBool(bool val);
|
static QAsn1Element fromBool(bool val);
|
||||||
static QAsn1Element fromInteger(unsigned int 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);
|
static QAsn1Element fromObjectId(const QByteArray &id);
|
||||||
|
|
||||||
bool toBool(bool *ok = nullptr) const;
|
bool toBool(bool *ok = nullptr) const;
|
||||||
QDateTime toDateTime() const;
|
QDateTime toDateTime() const;
|
||||||
QMultiMap<QByteArray, QString> toInfo() const;
|
QMultiMap<QByteArray, QString> toInfo() const;
|
||||||
qint64 toInteger(bool *ok = nullptr) const;
|
qint64 toInteger(bool *ok = nullptr) const;
|
||||||
QVector<QAsn1Element> toVector() const;
|
QList<QAsn1Element> toList() const;
|
||||||
QByteArray toObjectId() const;
|
QByteArray toObjectId() const;
|
||||||
QByteArray toObjectName() const;
|
QByteArray toObjectName() const;
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
@ -1127,7 +1127,7 @@ QString QDtls::dtlsErrorString() const
|
|||||||
If you want to continue connecting despite the errors that have occurred,
|
If you want to continue connecting despite the errors that have occurred,
|
||||||
you must call ignoreVerificationErrors().
|
you must call ignoreVerificationErrors().
|
||||||
*/
|
*/
|
||||||
QVector<QSslError> QDtls::peerVerificationErrors() const
|
QList<QSslError> QDtls::peerVerificationErrors() const
|
||||||
{
|
{
|
||||||
Q_D(const QDtls);
|
Q_D(const QDtls);
|
||||||
|
|
||||||
@ -1152,7 +1152,7 @@ QVector<QSslError> QDtls::peerVerificationErrors() const
|
|||||||
|
|
||||||
\sa doHandshake(), resumeHandshake(), QSslError
|
\sa doHandshake(), resumeHandshake(), QSslError
|
||||||
*/
|
*/
|
||||||
void QDtls::ignoreVerificationErrors(const QVector<QSslError> &errorsToIgnore)
|
void QDtls::ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore)
|
||||||
{
|
{
|
||||||
Q_D(QDtls);
|
Q_D(QDtls);
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ public:
|
|||||||
QDtlsError dtlsError() const;
|
QDtlsError dtlsError() const;
|
||||||
QString dtlsErrorString() const;
|
QString dtlsErrorString() const;
|
||||||
|
|
||||||
QVector<QSslError> peerVerificationErrors() const;
|
QList<QSslError> peerVerificationErrors() const;
|
||||||
void ignoreVerificationErrors(const QVector<QSslError> &errorsToIgnore);
|
void ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ QSslError _q_OpenSSL_to_QSslError(int errorCode, const QSslCertificate &cert);
|
|||||||
bool QDtlsPrivateOpenSSL::verifyPeer()
|
bool QDtlsPrivateOpenSSL::verifyPeer()
|
||||||
{
|
{
|
||||||
// DTLSTODO: Windows-specific code for CA fetcher is not here yet.
|
// 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
|
// Check the whole chain for blacklisting (including root, as we check for
|
||||||
// subjectInfo and issuer)
|
// 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
|
// check whether the errors we got are all in the list of expected errors
|
||||||
// (applies only if the method QDtlsConnection::ignoreTlsErrors(const
|
// (applies only if the method QDtlsConnection::ignoreTlsErrors(const
|
||||||
// QVector<QSslError> &errors) was called)
|
// QList<QSslError> &errors) was called)
|
||||||
for (const QSslError &error : tlsErrors) {
|
for (const QSslError &error : tlsErrors) {
|
||||||
if (!tlsErrorsToIgnore.contains(error))
|
if (!tlsErrorsToIgnore.contains(error))
|
||||||
return false;
|
return false;
|
||||||
|
@ -54,10 +54,10 @@
|
|||||||
#include <QtNetwork/qsslpresharedkeyauthenticator.h>
|
#include <QtNetwork/qsslpresharedkeyauthenticator.h>
|
||||||
#include <QtNetwork/qhostaddress.h>
|
#include <QtNetwork/qhostaddress.h>
|
||||||
|
|
||||||
#include <QtCore/qcryptographichash.h>
|
|
||||||
#include <QtCore/qsharedpointer.h>
|
|
||||||
#include <QtCore/qbytearray.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
|
// W A R N I N G
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
QHostAddress remoteAddress;
|
QHostAddress remoteAddress;
|
||||||
quint16 remotePort = 0;
|
quint16 remotePort = 0;
|
||||||
|
|
||||||
QVector<QSslErrorEntry> x509Errors;
|
QList<QSslErrorEntry> x509Errors;
|
||||||
|
|
||||||
long peeking = false;
|
long peeking = false;
|
||||||
QUdpSocket *udpSocket = nullptr;
|
QUdpSocket *udpSocket = nullptr;
|
||||||
@ -173,7 +173,7 @@ private:
|
|||||||
void reportTimeout();
|
void reportTimeout();
|
||||||
void resetDtls();
|
void resetDtls();
|
||||||
|
|
||||||
QVector<QSslErrorEntry> opensslErrors;
|
QList<QSslErrorEntry> opensslErrors;
|
||||||
dtlsopenssl::DtlsState dtls;
|
dtlsopenssl::DtlsState dtls;
|
||||||
|
|
||||||
// We have to externally handle timeouts since we have non-blocking
|
// We have to externally handle timeouts since we have non-blocking
|
||||||
|
@ -144,8 +144,8 @@ public:
|
|||||||
|
|
||||||
QDtls::HandshakeState handshakeState = QDtls::HandshakeNotStarted;
|
QDtls::HandshakeState handshakeState = QDtls::HandshakeNotStarted;
|
||||||
|
|
||||||
QVector<QSslError> tlsErrors;
|
QList<QSslError> tlsErrors;
|
||||||
QVector<QSslError> tlsErrorsToIgnore;
|
QList<QSslError> tlsErrorsToIgnore;
|
||||||
|
|
||||||
bool connectionEncrypted = false;
|
bool connectionEncrypted = false;
|
||||||
};
|
};
|
||||||
|
@ -484,9 +484,9 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
|
|||||||
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
|
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
|
||||||
return false;
|
return false;
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
const auto elems = val.toVector();
|
const auto elems = val.toList();
|
||||||
for (const QAsn1Element &el : elems) {
|
for (const QAsn1Element &el : elems) {
|
||||||
QVector<QAsn1Element> items = el.toVector();
|
const auto items = el.toList();
|
||||||
if (items.size() != 2)
|
if (items.size() != 2)
|
||||||
return false;
|
return false;
|
||||||
const QString key = QString::fromLatin1(items.at(0).toObjectName());
|
const QString key = QString::fromLatin1(items.at(0).toObjectName());
|
||||||
@ -510,7 +510,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
QVector<QAsn1Element> items = val.toVector();
|
const auto items = val.toList();
|
||||||
if (items.size() > 0) {
|
if (items.size() > 0) {
|
||||||
result[QStringLiteral("ca")] = items.at(0).toBool(&ok);
|
result[QStringLiteral("ca")] = items.at(0).toBool(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
@ -529,7 +529,7 @@ bool QSslCertificatePrivate::parseExtension(const QByteArray &data, QSslCertific
|
|||||||
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
|
if (!val.read(valElem.value()) || val.type() != QAsn1Element::SequenceType)
|
||||||
return false;
|
return false;
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
const auto elems = val.toVector();
|
const auto elems = val.toList();
|
||||||
for (const QAsn1Element &el : elems) {
|
for (const QAsn1Element &el : elems) {
|
||||||
if (el.type() == 0x80) {
|
if (el.type() == 0x80) {
|
||||||
const QString key = QStringLiteral("keyid");
|
const QString key = QStringLiteral("keyid");
|
||||||
|
@ -858,7 +858,7 @@ QSslKey QSslConfiguration::ephemeralServerKey() const
|
|||||||
|
|
||||||
\sa setEllipticCurves
|
\sa setEllipticCurves
|
||||||
*/
|
*/
|
||||||
QVector<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
|
QList<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
|
||||||
{
|
{
|
||||||
return d->ellipticCurves;
|
return d->ellipticCurves;
|
||||||
}
|
}
|
||||||
@ -875,7 +875,7 @@ QVector<QSslEllipticCurve> QSslConfiguration::ellipticCurves() const
|
|||||||
|
|
||||||
\sa ellipticCurves
|
\sa ellipticCurves
|
||||||
*/
|
*/
|
||||||
void QSslConfiguration::setEllipticCurves(const QVector<QSslEllipticCurve> &curves)
|
void QSslConfiguration::setEllipticCurves(const QList<QSslEllipticCurve> &curves)
|
||||||
{
|
{
|
||||||
d->ellipticCurves = curves;
|
d->ellipticCurves = curves;
|
||||||
}
|
}
|
||||||
@ -889,7 +889,7 @@ void QSslConfiguration::setEllipticCurves(const QVector<QSslEllipticCurve> &curv
|
|||||||
|
|
||||||
\sa ellipticCurves(), setEllipticCurves()
|
\sa ellipticCurves(), setEllipticCurves()
|
||||||
*/
|
*/
|
||||||
QVector<QSslEllipticCurve> QSslConfiguration::supportedEllipticCurves()
|
QList<QSslEllipticCurve> QSslConfiguration::supportedEllipticCurves()
|
||||||
{
|
{
|
||||||
return QSslSocketPrivate::supportedEllipticCurves();
|
return QSslSocketPrivate::supportedEllipticCurves();
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,9 @@ public:
|
|||||||
QSslKey ephemeralServerKey() const;
|
QSslKey ephemeralServerKey() const;
|
||||||
|
|
||||||
// EC settings
|
// EC settings
|
||||||
QVector<QSslEllipticCurve> ellipticCurves() const;
|
QList<QSslEllipticCurve> ellipticCurves() const;
|
||||||
void setEllipticCurves(const QVector<QSslEllipticCurve> &curves);
|
void setEllipticCurves(const QList<QSslEllipticCurve> &curves);
|
||||||
static QVector<QSslEllipticCurve> supportedEllipticCurves();
|
static QList<QSslEllipticCurve> supportedEllipticCurves();
|
||||||
|
|
||||||
QByteArray preSharedKeyIdentityHint() const;
|
QByteArray preSharedKeyIdentityHint() const;
|
||||||
void setPreSharedKeyIdentityHint(const QByteArray &hint);
|
void setPreSharedKeyIdentityHint(const QByteArray &hint);
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
Q_AUTOTEST_EXPORT static const QSsl::SslOptions defaultSslOptions;
|
Q_AUTOTEST_EXPORT static const QSsl::SslOptions defaultSslOptions;
|
||||||
|
|
||||||
QVector<QSslEllipticCurve> ellipticCurves;
|
QList<QSslEllipticCurve> ellipticCurves;
|
||||||
|
|
||||||
QSslDiffieHellmanParameters dhParams;
|
QSslDiffieHellmanParameters dhParams;
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ init_context:
|
|||||||
q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
|
q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
|
||||||
#endif // !OPENSSL_NO_PSK
|
#endif // !OPENSSL_NO_PSK
|
||||||
|
|
||||||
const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
|
const auto qcurves = sslContext->sslConfiguration.ellipticCurves();
|
||||||
if (!qcurves.isEmpty()) {
|
if (!qcurves.isEmpty()) {
|
||||||
#ifdef OPENSSL_NO_EC
|
#ifdef OPENSSL_NO_EC
|
||||||
sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version with disabled elliptic curves"));
|
sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version with disabled elliptic curves"));
|
||||||
|
@ -271,27 +271,23 @@ QByteArray QSslKeyPrivate::derFromPem(const QByteArray &pem, QMap<QByteArray, QB
|
|||||||
|
|
||||||
bool QSslKeyPrivate::isEncryptedPkcs8(const QByteArray &der) const
|
bool QSslKeyPrivate::isEncryptedPkcs8(const QByteArray &der) const
|
||||||
{
|
{
|
||||||
static const QVector<QByteArray> pbes1OIds {
|
static const QList<QByteArray> pbes1OIds {
|
||||||
// PKCS5
|
// PKCS5
|
||||||
{PKCS5_MD2_DES_CBC_OID},
|
{ PKCS5_MD2_DES_CBC_OID }, { PKCS5_MD2_RC2_CBC_OID }, { PKCS5_MD5_DES_CBC_OID },
|
||||||
{PKCS5_MD2_RC2_CBC_OID},
|
{ PKCS5_MD5_RC2_CBC_OID }, { PKCS5_SHA1_DES_CBC_OID }, { PKCS5_SHA1_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;
|
QAsn1Element elem;
|
||||||
if (!elem.read(der) || elem.type() != QAsn1Element::SequenceType)
|
if (!elem.read(der) || elem.type() != QAsn1Element::SequenceType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QVector<QAsn1Element> items = elem.toVector();
|
const auto items = elem.toList();
|
||||||
if (items.size() != 2
|
if (items.size() != 2
|
||||||
|| items[0].type() != QAsn1Element::SequenceType
|
|| items[0].type() != QAsn1Element::SequenceType
|
||||||
|| items[1].type() != QAsn1Element::OctetStringType) {
|
|| items[1].type() != QAsn1Element::OctetStringType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<QAsn1Element> encryptionSchemeContainer = items[0].toVector();
|
const auto encryptionSchemeContainer = items[0].toList();
|
||||||
if (encryptionSchemeContainer.size() != 2
|
if (encryptionSchemeContainer.size() != 2
|
||||||
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
||||||
|| encryptionSchemeContainer[1].type() != QAsn1Element::SequenceType) {
|
|| encryptionSchemeContainer[1].type() != QAsn1Element::SequenceType) {
|
||||||
|
@ -195,7 +195,8 @@ void QSslKeyPrivate::clear(bool deep)
|
|||||||
keyLength = -1;
|
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);
|
Q_ASSERT(items.size() == 3);
|
||||||
int keyLength;
|
int keyLength;
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ static int extractPkcs8KeyLength(const QVector<QAsn1Element> &items, QSslKeyPriv
|
|||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
const QVector<QAsn1Element> pkcs8Info = items[1].toVector();
|
const auto pkcs8Info = items[1].toList();
|
||||||
if (pkcs8Info.size() != 2 || pkcs8Info[0].type() != QAsn1Element::ObjectIdentifierType)
|
if (pkcs8Info.size() != 2 || pkcs8Info[0].type() != QAsn1Element::ObjectIdentifierType)
|
||||||
return -1;
|
return -1;
|
||||||
const QByteArray value = pkcs8Info[0].toObjectId();
|
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.
|
// https://www.cryptsoft.com/pkcs11doc/STANDARD/v201-95.pdf in section 11.9.
|
||||||
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
|
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
|
||||||
return -1;
|
return -1;
|
||||||
const QVector<QAsn1Element> dsaInfo = pkcs8Info[1].toVector();
|
const auto dsaInfo = pkcs8Info[1].toList();
|
||||||
if (dsaInfo.size() != 3 || dsaInfo[0].type() != QAsn1Element::IntegerType)
|
if (dsaInfo.size() != 3 || dsaInfo[0].type() != QAsn1Element::IntegerType)
|
||||||
return -1;
|
return -1;
|
||||||
keyLength = numberOfBits(dsaInfo[0].value());
|
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.
|
// https://www.cryptsoft.com/pkcs11doc/STANDARD/v201-95.pdf in section 11.9.
|
||||||
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
|
if (pkcs8Info[1].type() != QAsn1Element::SequenceType)
|
||||||
return -1;
|
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)
|
if (dhInfo.size() < 2 || dhInfo.size() > 3 || dhInfo[0].type() != QAsn1Element::IntegerType)
|
||||||
return -1;
|
return -1;
|
||||||
keyLength = numberOfBits(dhInfo[0].value());
|
keyLength = numberOfBits(dhInfo[0].value());
|
||||||
@ -298,7 +299,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
|
|||||||
QDataStream keyStream(elem.value());
|
QDataStream keyStream(elem.value());
|
||||||
if (!elem.read(keyStream) || elem.type() != QAsn1Element::SequenceType)
|
if (!elem.read(keyStream) || elem.type() != QAsn1Element::SequenceType)
|
||||||
return;
|
return;
|
||||||
const QVector<QAsn1Element> infoItems = elem.toVector();
|
const auto infoItems = elem.toList();
|
||||||
if (infoItems.size() < 2 || infoItems[0].type() != QAsn1Element::ObjectIdentifierType)
|
if (infoItems.size() < 2 || infoItems[0].type() != QAsn1Element::ObjectIdentifierType)
|
||||||
return;
|
return;
|
||||||
if (algorithm == QSsl::Rsa) {
|
if (algorithm == QSsl::Rsa) {
|
||||||
@ -318,7 +319,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
|
|||||||
if (infoItems[1].type() != QAsn1Element::SequenceType)
|
if (infoItems[1].type() != QAsn1Element::SequenceType)
|
||||||
return;
|
return;
|
||||||
// key params
|
// key params
|
||||||
const QVector<QAsn1Element> params = infoItems[1].toVector();
|
const auto params = infoItems[1].toList();
|
||||||
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
|
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
|
||||||
return;
|
return;
|
||||||
keyLength = numberOfBits(params[0].value());
|
keyLength = numberOfBits(params[0].value());
|
||||||
@ -328,7 +329,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
|
|||||||
if (infoItems[1].type() != QAsn1Element::SequenceType)
|
if (infoItems[1].type() != QAsn1Element::SequenceType)
|
||||||
return;
|
return;
|
||||||
// key params
|
// key params
|
||||||
const QVector<QAsn1Element> params = infoItems[1].toVector();
|
const auto params = infoItems[1].toList();
|
||||||
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
|
if (params.isEmpty() || params[0].type() != QAsn1Element::IntegerType)
|
||||||
return;
|
return;
|
||||||
keyLength = numberOfBits(params[0].value());
|
keyLength = numberOfBits(params[0].value());
|
||||||
@ -341,7 +342,7 @@ void QSslKeyPrivate::decodeDer(const QByteArray &der, const QByteArray &passPhra
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const QVector<QAsn1Element> items = elem.toVector();
|
const auto items = elem.toList();
|
||||||
if (items.isEmpty())
|
if (items.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -497,7 +498,7 @@ struct EncryptionData
|
|||||||
QByteArray iv;
|
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
|
// RFC 8018: https://tools.ietf.org/html/rfc8018#section-6.2
|
||||||
/*** Scheme: ***
|
/*** Scheme: ***
|
||||||
@ -534,7 +535,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
|
|||||||
// @todo: AES(, rc5?)
|
// @todo: AES(, rc5?)
|
||||||
};
|
};
|
||||||
|
|
||||||
const QVector<QAsn1Element> keyDerivationContainer = element[0].toVector();
|
const QList<QAsn1Element> keyDerivationContainer = element[0].toList();
|
||||||
if (keyDerivationContainer.size() != 2
|
if (keyDerivationContainer.size() != 2
|
||||||
|| keyDerivationContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
|| keyDerivationContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
||||||
|| keyDerivationContainer[1].type() != QAsn1Element::SequenceType) {
|
|| 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 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
|
if (encryptionAlgorithmContainer.size() != 2
|
||||||
|| encryptionAlgorithmContainer[0].type() != QAsn1Element::ObjectIdentifierType) {
|
|| encryptionAlgorithmContainer[0].type() != QAsn1Element::ObjectIdentifierType) {
|
||||||
return {};
|
return {};
|
||||||
@ -588,7 +589,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
|
|||||||
*/
|
*/
|
||||||
if (encryptionAlgorithmContainer[1].type() != QAsn1Element::SequenceType)
|
if (encryptionAlgorithmContainer[1].type() != QAsn1Element::SequenceType)
|
||||||
return {};
|
return {};
|
||||||
const QVector<QAsn1Element> rc2ParametersContainer = encryptionAlgorithmContainer[1].toVector();
|
const auto rc2ParametersContainer = encryptionAlgorithmContainer[1].toList();
|
||||||
if ((rc2ParametersContainer.size() != 1 && rc2ParametersContainer.size() != 2)
|
if ((rc2ParametersContainer.size() != 1 && rc2ParametersContainer.size() != 2)
|
||||||
|| rc2ParametersContainer.back().type() != QAsn1Element::OctetStringType) {
|
|| rc2ParametersContainer.back().type() != QAsn1Element::OctetStringType) {
|
||||||
return {};
|
return {};
|
||||||
@ -636,7 +637,7 @@ static EncryptionData readPbes2(const QVector<QAsn1Element> &element, const QByt
|
|||||||
QCryptographicHash::Algorithm hashAlgorithm = QCryptographicHash::Sha1;
|
QCryptographicHash::Algorithm hashAlgorithm = QCryptographicHash::Sha1;
|
||||||
if (keyDerivationParams.size() > vectorPos
|
if (keyDerivationParams.size() > vectorPos
|
||||||
&& keyDerivationParams[vectorPos].type() == QAsn1Element::SequenceType) {
|
&& keyDerivationParams[vectorPos].type() == QAsn1Element::SequenceType) {
|
||||||
QVector<QAsn1Element> hashAlgorithmContainer = keyDerivationParams[vectorPos].toVector();
|
const auto hashAlgorithmContainer = keyDerivationParams[vectorPos].toList();
|
||||||
hashAlgorithm = pbes2OidHashFunctionMap[hashAlgorithmContainer.front().toObjectId()];
|
hashAlgorithm = pbes2OidHashFunctionMap[hashAlgorithmContainer.front().toObjectId()];
|
||||||
Q_ASSERT(hashAlgorithmContainer[1].type() == QAsn1Element::NullType);
|
Q_ASSERT(hashAlgorithmContainer[1].type() == QAsn1Element::NullType);
|
||||||
++vectorPos;
|
++vectorPos;
|
||||||
@ -675,8 +676,8 @@ static const QMap<QByteArray, QCryptographicHash::Algorithm> pbes1OidHashFunctio
|
|||||||
// {PKCS12_SHA1_RC2_40_CBC_OID, QCryptographicHash::Sha1}
|
// {PKCS12_SHA1_RC2_40_CBC_OID, QCryptographicHash::Sha1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static EncryptionData readPbes1(const QList<QAsn1Element> &element,
|
||||||
static EncryptionData readPbes1(const QVector<QAsn1Element> &element, const QByteArray &encryptionScheme, const QByteArray &passPhrase)
|
const QByteArray &encryptionScheme, const QByteArray &passPhrase)
|
||||||
{
|
{
|
||||||
// RFC 8018: https://tools.ietf.org/html/rfc8018#section-6.1
|
// 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
|
// 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)
|
if (!elem.read(encrypted) || elem.type() != QAsn1Element::SequenceType)
|
||||||
return encrypted;
|
return encrypted;
|
||||||
|
|
||||||
const QVector<QAsn1Element> items = elem.toVector();
|
const auto items = elem.toList();
|
||||||
if (items.size() != 2
|
if (items.size() != 2
|
||||||
|| items[0].type() != QAsn1Element::SequenceType
|
|| items[0].type() != QAsn1Element::SequenceType
|
||||||
|| items[1].type() != QAsn1Element::OctetStringType) {
|
|| items[1].type() != QAsn1Element::OctetStringType) {
|
||||||
return encrypted;
|
return encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<QAsn1Element> encryptionSchemeContainer = items[0].toVector();
|
const auto encryptionSchemeContainer = items[0].toList();
|
||||||
|
|
||||||
if (encryptionSchemeContainer.size() != 2
|
if (encryptionSchemeContainer.size() != 2
|
||||||
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
|| encryptionSchemeContainer[0].type() != QAsn1Element::ObjectIdentifierType
|
||||||
@ -749,7 +750,7 @@ QByteArray QSslKeyPrivate::decryptPkcs8(const QByteArray &encrypted, const QByte
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray encryptionScheme = encryptionSchemeContainer[0].toObjectId();
|
const QByteArray encryptionScheme = encryptionSchemeContainer[0].toObjectId();
|
||||||
const QVector<QAsn1Element> schemeParameterContainer = encryptionSchemeContainer[1].toVector();
|
const auto schemeParameterContainer = encryptionSchemeContainer[1].toList();
|
||||||
|
|
||||||
if (schemeParameterContainer.size() != 2
|
if (schemeParameterContainer.size() != 2
|
||||||
&& schemeParameterContainer[0].type() != QAsn1Element::SequenceType
|
&& schemeParameterContainer[0].type() != QAsn1Element::SequenceType
|
||||||
|
@ -488,7 +488,7 @@ public:
|
|||||||
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QList<QSslCipher> supportedCiphers;
|
QList<QSslCipher> supportedCiphers;
|
||||||
QVector<QSslEllipticCurve> supportedEllipticCurves;
|
QList<QSslEllipticCurve> supportedEllipticCurves;
|
||||||
QExplicitlySharedDataPointer<QSslConfigurationPrivate> config;
|
QExplicitlySharedDataPointer<QSslConfigurationPrivate> config;
|
||||||
QExplicitlySharedDataPointer<QSslConfigurationPrivate> dtlsConfig;
|
QExplicitlySharedDataPointer<QSslConfigurationPrivate> dtlsConfig;
|
||||||
};
|
};
|
||||||
@ -1296,12 +1296,12 @@ QSsl::SslProtocol QSslSocket::sessionProtocol() const
|
|||||||
\since 5.13
|
\since 5.13
|
||||||
|
|
||||||
This function returns Online Certificate Status Protocol responses that
|
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.
|
is empty if no definitive response or no response at all was received.
|
||||||
|
|
||||||
\sa QSslConfiguration::setOcspStaplingEnabled()
|
\sa QSslConfiguration::setOcspStaplingEnabled()
|
||||||
*/
|
*/
|
||||||
QVector<QOcspResponse> QSslSocket::ocspResponses() const
|
QList<QOcspResponse> QSslSocket::ocspResponses() const
|
||||||
{
|
{
|
||||||
Q_D(const QSslSocket);
|
Q_D(const QSslSocket);
|
||||||
return d->ocspResponses;
|
return d->ocspResponses;
|
||||||
@ -2061,7 +2061,7 @@ QList<QSslCipher> q_getDefaultDtlsCiphers()
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
QVector<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
|
QList<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
|
||||||
{
|
{
|
||||||
QSslSocketPrivate::ensureInitialized();
|
QSslSocketPrivate::ensureInitialized();
|
||||||
const QMutexLocker locker(&globalData()->mutex);
|
const QMutexLocker locker(&globalData()->mutex);
|
||||||
@ -2071,7 +2071,7 @@ QVector<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
void QSslSocketPrivate::setDefaultSupportedEllipticCurves(const QVector<QSslEllipticCurve> &curves)
|
void QSslSocketPrivate::setDefaultSupportedEllipticCurves(const QList<QSslEllipticCurve> &curves)
|
||||||
{
|
{
|
||||||
const QMutexLocker locker(&globalData()->mutex);
|
const QMutexLocker locker(&globalData()->mutex);
|
||||||
globalData()->config.detach();
|
globalData()->config.detach();
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
#include <QtNetwork/qtnetworkglobal.h>
|
#include <QtNetwork/qtnetworkglobal.h>
|
||||||
#include <QtCore/qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qvector.h>
|
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
# include <QtNetwork/qtcpsocket.h>
|
# include <QtNetwork/qtcpsocket.h>
|
||||||
# include <QtNetwork/qsslerror.h>
|
# include <QtNetwork/qsslerror.h>
|
||||||
@ -187,7 +186,7 @@ public:
|
|||||||
QList<QSslCertificate> peerCertificateChain() const;
|
QList<QSslCertificate> peerCertificateChain() const;
|
||||||
QSslCipher sessionCipher() const;
|
QSslCipher sessionCipher() const;
|
||||||
QSsl::SslProtocol sessionProtocol() const;
|
QSsl::SslProtocol sessionProtocol() const;
|
||||||
QVector<QOcspResponse> ocspResponses() const;
|
QList<QOcspResponse> ocspResponses() const;
|
||||||
|
|
||||||
// Private keys, for server sockets.
|
// Private keys, for server sockets.
|
||||||
void setPrivateKey(const QSslKey &key);
|
void setPrivateKey(const QSslKey &key);
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
#include <QtCore/qsystemdetection.h>
|
#include <QtCore/qsystemdetection.h>
|
||||||
#include <QtCore/qdatastream.h>
|
#include <QtCore/qdatastream.h>
|
||||||
#include <QtCore/qsysinfo.h>
|
#include <QtCore/qsysinfo.h>
|
||||||
#include <QtCore/qvector.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/quuid.h>
|
#include <QtCore/quuid.h>
|
||||||
@ -332,7 +332,7 @@ void QSslSocketPrivate::ensureInitialized()
|
|||||||
size_t numCiphers = 0;
|
size_t numCiphers = 0;
|
||||||
// Fails only if any of parameters is null.
|
// Fails only if any of parameters is null.
|
||||||
SSLGetNumberSupportedCiphers(context, &numCiphers);
|
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.
|
// Fails only if any of parameter is null or number of ciphers is wrong.
|
||||||
SSLGetSupportedCiphers(context, cfCiphers.data(), &numCiphers);
|
SSLGetSupportedCiphers(context, cfCiphers.data(), &numCiphers);
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ void QSslSocketBackendPrivate::continueHandshake()
|
|||||||
const OSStatus result = SSLCopyALPNProtocols(context, &cfArray);
|
const OSStatus result = SSLCopyALPNProtocols(context, &cfArray);
|
||||||
if (result == errSecSuccess && cfArray && CFArrayGetCount(cfArray)) {
|
if (result == errSecSuccess && cfArray && CFArrayGetCount(cfArray)) {
|
||||||
const int size = CFArrayGetCount(cfArray);
|
const int size = CFArrayGetCount(cfArray);
|
||||||
QVector<QString> peerProtocols(size);
|
QList<QString> peerProtocols(size);
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
peerProtocols[i] = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(cfArray, i));
|
peerProtocols[i] = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(cfArray, i));
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ QAlertType tlsAlertType(int value)
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
QSslCertificate findCertificateToFetch(const QVector<QSslError> &tlsErrors, bool checkAIA)
|
QSslCertificate findCertificateToFetch(const QList<QSslError> &tlsErrors, bool checkAIA)
|
||||||
{
|
{
|
||||||
QSslCertificate certToFetch;
|
QSslCertificate certToFetch;
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
// Store the error and at which depth the error was detected.
|
// Store the error and at which depth the error was detected.
|
||||||
|
|
||||||
using ErrorListPtr = QVector<QSslErrorEntry>*;
|
using ErrorListPtr = QList<QSslErrorEntry> *;
|
||||||
ErrorListPtr errors = nullptr;
|
ErrorListPtr errors = nullptr;
|
||||||
|
|
||||||
// Error list is attached to either 'SSL' or 'X509_STORE'.
|
// Error list is attached to either 'SSL' or 'X509_STORE'.
|
||||||
@ -962,7 +962,7 @@ void QSslSocketPrivate::resetDefaultCiphers()
|
|||||||
|
|
||||||
void QSslSocketPrivate::resetDefaultEllipticCurves()
|
void QSslSocketPrivate::resetDefaultEllipticCurves()
|
||||||
{
|
{
|
||||||
QVector<QSslEllipticCurve> curves;
|
QList<QSslEllipticCurve> curves;
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_EC
|
#ifndef OPENSSL_NO_EC
|
||||||
const size_t curveCount = q_EC_get_builtin_curves(nullptr, 0);
|
const size_t curveCount = q_EC_get_builtin_curves(nullptr, 0);
|
||||||
@ -1391,7 +1391,7 @@ bool QSslSocketBackendPrivate::startHandshake()
|
|||||||
|
|
||||||
pendingFatalAlert = false;
|
pendingFatalAlert = false;
|
||||||
errorsReportedFromCallback = false;
|
errorsReportedFromCallback = false;
|
||||||
QVector<QSslErrorEntry> lastErrors;
|
QList<QSslErrorEntry> lastErrors;
|
||||||
q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + errorOffsetInExData, &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.
|
// 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):
|
// wants to check errors (ignored or not):
|
||||||
const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData
|
const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData
|
||||||
+ QSslSocketBackendPrivate::errorOffsetInExData;
|
+ 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);
|
errorList->append(errorAndDepth);
|
||||||
|
|
||||||
// An application is expected to ignore this error (by calling ignoreSslErrors)
|
// 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)) {
|
if (!q_X509_STORE_set_ex_data(certStore, 0, &lastErrors)) {
|
||||||
qCWarning(lcSsl) << "Unable to attach external data (error list) to a store";
|
qCWarning(lcSsl) << "Unable to attach external data (error list) to a store";
|
||||||
errors << QSslError(QSslError::UnspecifiedError);
|
errors << QSslError(QSslError::UnspecifiedError);
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
#include <QtNetwork/private/qtnetworkglobal_p.h>
|
#include <QtNetwork/private/qtnetworkglobal_p.h>
|
||||||
#include "qsslsocket_p.h"
|
#include "qsslsocket_p.h"
|
||||||
|
|
||||||
#include <QtCore/qvector.h>
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
BIO *readBio;
|
BIO *readBio;
|
||||||
BIO *writeBio;
|
BIO *writeBio;
|
||||||
SSL_SESSION *session;
|
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
|
static int s_indexForSSLExtraData; // index used in SSL_get_ex_data to get the matching QSslSocketBackendPrivate
|
||||||
enum ExDataOffset {
|
enum ExDataOffset {
|
||||||
errorOffsetInExData = 1,
|
errorOffsetInExData = 1,
|
||||||
@ -174,7 +174,7 @@ public:
|
|||||||
// This decription will go to setErrorAndEmit(SslHandshakeError, ocspErrorDescription)
|
// This decription will go to setErrorAndEmit(SslHandshakeError, ocspErrorDescription)
|
||||||
QString ocspErrorDescription;
|
QString ocspErrorDescription;
|
||||||
// These will go to sslErrors()
|
// These will go to sslErrors()
|
||||||
QVector<QSslError> ocspErrors;
|
QList<QSslError> ocspErrors;
|
||||||
QByteArray ocspResponseDer;
|
QByteArray ocspResponseDer;
|
||||||
|
|
||||||
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
|
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
|
||||||
|
@ -554,8 +554,8 @@ struct LibGreaterThan
|
|||||||
typedef bool result_type;
|
typedef bool result_type;
|
||||||
result_type operator()(QStringView lhs, QStringView rhs) const
|
result_type operator()(QStringView lhs, QStringView rhs) const
|
||||||
{
|
{
|
||||||
const QVector<QStringView> lhsparts = lhs.split(QLatin1Char('.'));
|
const auto lhsparts = lhs.split(QLatin1Char('.'));
|
||||||
const QVector<QStringView> rhsparts = rhs.split(QLatin1Char('.'));
|
const auto rhsparts = rhs.split(QLatin1Char('.'));
|
||||||
Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
|
Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
|
||||||
|
|
||||||
// note: checking rhs < lhs, the same as lhs > rhs
|
// note: checking rhs < lhs, the same as lhs > rhs
|
||||||
|
@ -65,8 +65,8 @@
|
|||||||
class QSslContext;
|
class QSslContext;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QtCore/qlist.h>
|
||||||
#include <QtCore/qstringlist.h>
|
#include <QtCore/qstringlist.h>
|
||||||
#include <QtCore/qvector.h>
|
|
||||||
#include <private/qringbuffer_p.h>
|
#include <private/qringbuffer_p.h>
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
@ -146,8 +146,8 @@ public:
|
|||||||
static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers);
|
static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers);
|
||||||
static void resetDefaultCiphers();
|
static void resetDefaultCiphers();
|
||||||
|
|
||||||
static QVector<QSslEllipticCurve> supportedEllipticCurves();
|
static QList<QSslEllipticCurve> supportedEllipticCurves();
|
||||||
static void setDefaultSupportedEllipticCurves(const QVector<QSslEllipticCurve> &curves);
|
static void setDefaultSupportedEllipticCurves(const QList<QSslEllipticCurve> &curves);
|
||||||
static void resetDefaultEllipticCurves();
|
static void resetDefaultEllipticCurves();
|
||||||
|
|
||||||
static QList<QSslCertificate> defaultCaCertificates();
|
static QList<QSslCertificate> defaultCaCertificates();
|
||||||
@ -219,7 +219,7 @@ protected:
|
|||||||
bool paused;
|
bool paused;
|
||||||
bool flushTriggered;
|
bool flushTriggered;
|
||||||
bool systemOrSslErrorDetected = false;
|
bool systemOrSslErrorDetected = false;
|
||||||
QVector<QOcspResponse> ocspResponses;
|
QList<QOcspResponse> ocspResponses;
|
||||||
bool handshakeInterrupted = false;
|
bool handshakeInterrupted = false;
|
||||||
bool fetchAuthorityInformation = false;
|
bool fetchAuthorityInformation = false;
|
||||||
};
|
};
|
||||||
|
@ -61,7 +61,7 @@ static QAsn1Element wrap(quint8 type, const QAsn1Element &child)
|
|||||||
|
|
||||||
static QAsn1Element _q_PKCS7_data(const QByteArray &data)
|
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 << QAsn1Element::fromObjectId("1.2.840.113549.1.7.1");
|
||||||
items << wrap(QAsn1Element::Context0Type,
|
items << wrap(QAsn1Element::Context0Type,
|
||||||
QAsn1Element(QAsn1Element::OctetStringType, data));
|
QAsn1Element(QAsn1Element::OctetStringType, data));
|
||||||
@ -145,11 +145,11 @@ static QByteArray _q_PKCS12_salt()
|
|||||||
|
|
||||||
static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
|
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");
|
items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.3");
|
||||||
|
|
||||||
// certificate
|
// certificate
|
||||||
QVector<QAsn1Element> certItems;
|
QList<QAsn1Element> certItems;
|
||||||
certItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.22.1");
|
certItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.22.1");
|
||||||
certItems << wrap(QAsn1Element::Context0Type,
|
certItems << wrap(QAsn1Element::Context0Type,
|
||||||
QAsn1Element(QAsn1Element::OctetStringType, cert.toDer()));
|
QAsn1Element(QAsn1Element::OctetStringType, cert.toDer()));
|
||||||
@ -158,7 +158,7 @@ static QByteArray _q_PKCS12_certBag(const QSslCertificate &cert)
|
|||||||
|
|
||||||
// local key id
|
// local key id
|
||||||
const QByteArray localKeyId = cert.digest(QCryptographicHash::Sha1);
|
const QByteArray localKeyId = cert.digest(QCryptographicHash::Sha1);
|
||||||
QVector<QAsn1Element> idItems;
|
QList<QAsn1Element> idItems;
|
||||||
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
|
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
|
||||||
idItems << wrap(QAsn1Element::SetType,
|
idItems << wrap(QAsn1Element::SetType,
|
||||||
QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
|
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);
|
Q_ASSERT(key.algorithm() == QSsl::Rsa || key.algorithm() == QSsl::Dsa);
|
||||||
|
|
||||||
QVector<QAsn1Element> keyItems;
|
QList<QAsn1Element> keyItems;
|
||||||
keyItems << QAsn1Element::fromInteger(0);
|
keyItems << QAsn1Element::fromInteger(0);
|
||||||
QVector<QAsn1Element> algoItems;
|
QList<QAsn1Element> algoItems;
|
||||||
if (key.algorithm() == QSsl::Rsa)
|
if (key.algorithm() == QSsl::Rsa)
|
||||||
algoItems << QAsn1Element::fromObjectId(RSA_ENCRYPTION_OID);
|
algoItems << QAsn1Element::fromObjectId(RSA_ENCRYPTION_OID);
|
||||||
else if (key.algorithm() == QSsl::Dsa)
|
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,
|
QByteArray crypted = QSslKeyPrivate::encrypt(QSslKeyPrivate::DesEde3Cbc,
|
||||||
plain, cKey, cIv);
|
plain, cKey, cIv);
|
||||||
|
|
||||||
QVector<QAsn1Element> items;
|
QList<QAsn1Element> items;
|
||||||
items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2");
|
items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2");
|
||||||
|
|
||||||
// key
|
// key
|
||||||
QVector<QAsn1Element> keyItems;
|
QList<QAsn1Element> keyItems;
|
||||||
QVector<QAsn1Element> algoItems;
|
QList<QAsn1Element> algoItems;
|
||||||
algoItems << QAsn1Element::fromObjectId("1.2.840.113549.1.12.1.3");
|
algoItems << QAsn1Element::fromObjectId("1.2.840.113549.1.12.1.3");
|
||||||
QVector<QAsn1Element> paramItems;
|
QList<QAsn1Element> paramItems;
|
||||||
paramItems << QAsn1Element(QAsn1Element::OctetStringType, salt);
|
paramItems << QAsn1Element(QAsn1Element::OctetStringType, salt);
|
||||||
paramItems << QAsn1Element::fromInteger(iterations);
|
paramItems << QAsn1Element::fromInteger(iterations);
|
||||||
algoItems << QAsn1Element::fromVector(paramItems);
|
algoItems << QAsn1Element::fromVector(paramItems);
|
||||||
@ -220,7 +220,7 @@ static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &pa
|
|||||||
QAsn1Element::fromVector(keyItems));
|
QAsn1Element::fromVector(keyItems));
|
||||||
|
|
||||||
// local key id
|
// local key id
|
||||||
QVector<QAsn1Element> idItems;
|
QList<QAsn1Element> idItems;
|
||||||
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
|
idItems << QAsn1Element::fromObjectId("1.2.840.113549.1.9.21");
|
||||||
idItems << wrap(QAsn1Element::SetType,
|
idItems << wrap(QAsn1Element::SetType,
|
||||||
QAsn1Element(QAsn1Element::OctetStringType, localKeyId));
|
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)
|
static QByteArray _q_PKCS12_bag(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
|
||||||
{
|
{
|
||||||
QVector<QAsn1Element> items;
|
QList<QAsn1Element> items;
|
||||||
|
|
||||||
// certs
|
// certs
|
||||||
for (int i = 0; i < certs.size(); ++i)
|
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);
|
QMessageAuthenticationCode hmac(QCryptographicHash::Sha1, key);
|
||||||
hmac.addData(data);
|
hmac.addData(data);
|
||||||
|
|
||||||
QVector<QAsn1Element> algoItems;
|
QList<QAsn1Element> algoItems;
|
||||||
algoItems << QAsn1Element::fromObjectId("1.3.14.3.2.26");
|
algoItems << QAsn1Element::fromObjectId("1.3.14.3.2.26");
|
||||||
algoItems << QAsn1Element(QAsn1Element::NullType);
|
algoItems << QAsn1Element(QAsn1Element::NullType);
|
||||||
|
|
||||||
QVector<QAsn1Element> digestItems;
|
QList<QAsn1Element> digestItems;
|
||||||
digestItems << QAsn1Element::fromVector(algoItems);
|
digestItems << QAsn1Element::fromVector(algoItems);
|
||||||
digestItems << QAsn1Element(QAsn1Element::OctetStringType, hmac.result());
|
digestItems << QAsn1Element(QAsn1Element::OctetStringType, hmac.result());
|
||||||
|
|
||||||
QVector<QAsn1Element> macItems;
|
QList<QAsn1Element> macItems;
|
||||||
macItems << QAsn1Element::fromVector(digestItems);
|
macItems << QAsn1Element::fromVector(digestItems);
|
||||||
macItems << QAsn1Element(QAsn1Element::OctetStringType, macSalt);
|
macItems << QAsn1Element(QAsn1Element::OctetStringType, macSalt);
|
||||||
macItems << QAsn1Element::fromInteger(iterations);
|
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)
|
QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key, const QString &passPhrase)
|
||||||
{
|
{
|
||||||
QVector<QAsn1Element> items;
|
QList<QAsn1Element> items;
|
||||||
|
|
||||||
// version
|
// version
|
||||||
items << QAsn1Element::fromInteger(3);
|
items << QAsn1Element::fromInteger(3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user