diff options
Diffstat (limited to 'src/network/ssl/qsslkey_p.cpp')
-rw-r--r-- | src/network/ssl/qsslkey_p.cpp | 88 |
1 files changed, 20 insertions, 68 deletions
diff --git a/src/network/ssl/qsslkey_p.cpp b/src/network/ssl/qsslkey_p.cpp index e0f8651982..55cb2b0436 100644 --- a/src/network/ssl/qsslkey_p.cpp +++ b/src/network/ssl/qsslkey_p.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! @@ -57,12 +21,8 @@ #include "qssl_p.h" #include "qsslkey.h" #include "qsslkey_p.h" -#ifndef QT_NO_OPENSSL -#include "qsslsocket_openssl_symbols_p.h" -#endif #include "qsslsocket.h" #include "qsslsocket_p.h" -#include "qasn1element_p.h" #include "qtlsbackend_p.h" #include <QtCore/qatomic.h> @@ -98,9 +58,9 @@ QSslKeyPrivate::QSslKeyPrivate() const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse(); if (!tlsBackend) return; - keyBackend.reset(tlsBackend->createKey()); - if (keyBackend.get()) - keyBackend->clear(false /*not deep clear*/); + backend.reset(tlsBackend->createKey()); + if (backend.get()) + backend->clear(false /*not deep clear*/); else qCWarning(lcSsl, "Active TLS backend does not support key creation"); } @@ -110,14 +70,14 @@ QSslKeyPrivate::QSslKeyPrivate() */ QSslKeyPrivate::~QSslKeyPrivate() { - if (keyBackend.get()) - keyBackend->clear(true /*deep clear*/); + if (backend.get()) + backend->clear(true /*deep clear*/); } QByteArray QSslKeyPrivate::decrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) { if (const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse()) { - const std::unique_ptr<QSsl::TlsKey> cryptor(tlsBackend->createKey()); + const std::unique_ptr<QTlsPrivate::TlsKey> cryptor(tlsBackend->createKey()); return cryptor->decrypt(cipher, data, key, iv); } @@ -127,7 +87,7 @@ QByteArray QSslKeyPrivate::decrypt(Cipher cipher, const QByteArray &data, const QByteArray QSslKeyPrivate::encrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) { if (const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse()) { - const std::unique_ptr<QSsl::TlsKey> cryptor(tlsBackend->createKey()); + const std::unique_ptr<QTlsPrivate::TlsKey> cryptor(tlsBackend->createKey()); return cryptor->encrypt(cipher, data, key, iv); } @@ -158,7 +118,7 @@ QSslKey::QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding, QSsl::KeyType type, const QByteArray &passPhrase) : d(new QSslKeyPrivate) { - if (auto *tlsKey = d->keyBackend.get()) { + if (auto *tlsKey = d->backend.get()) { if (encoding == QSsl::Der) tlsKey->decodeDer(type, algorithm, encoded, passPhrase, true /*deep clear*/); else @@ -184,7 +144,7 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding if (device) encoded = device->readAll(); - if (auto *tlsKey = d->keyBackend.get()) { + if (auto *tlsKey = d->backend.get()) { if (encoding == QSsl::Der) tlsKey->decodeDer(type, algorithm, encoded, passPhrase, true /*deep clear*/); else @@ -203,7 +163,7 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type) : d(new QSslKeyPrivate) { - if (auto *tlsKey = d->keyBackend.get()) + if (auto *tlsKey = d->backend.get()) tlsKey->fromHandle(handle, type); } @@ -266,7 +226,7 @@ QSslKey &QSslKey::operator=(const QSslKey &other) */ bool QSslKey::isNull() const { - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->isNull(); return true; @@ -287,7 +247,7 @@ void QSslKey::clear() */ int QSslKey::length() const { - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->length(); return -1; @@ -298,7 +258,7 @@ int QSslKey::length() const */ QSsl::KeyType QSslKey::type() const { - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->type(); return QSsl::PublicKey; @@ -309,7 +269,7 @@ QSsl::KeyType QSslKey::type() const */ QSsl::KeyAlgorithm QSslKey::algorithm() const { - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->algorithm(); return QSsl::Opaque; @@ -331,7 +291,7 @@ QByteArray QSslKey::toDer(const QByteArray &passPhrase) const return {}; QMap<QByteArray, QByteArray> headers; - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->derFromPem(toPem(passPhrase), &headers); return {}; @@ -344,7 +304,7 @@ QByteArray QSslKey::toDer(const QByteArray &passPhrase) const */ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const { - if (const auto *tlsKey = d->keyBackend.get()) + if (const auto *tlsKey = d->backend.get()) return tlsKey->toPem(passPhrase); return {}; @@ -363,8 +323,8 @@ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const */ Qt::HANDLE QSslKey::handle() const { - if (d->keyBackend.get()) - return d->keyBackend->handle(); + if (d->backend.get()) + return d->backend->handle(); return nullptr; } @@ -389,14 +349,6 @@ bool QSslKey::operator==(const QSslKey &other) const return toDer() == other.toDer(); } -/*! - \since 6.1 - Returns TLS backend-specific implementation this QSslKey is using. -*/ -QSsl::TlsKey *QSslKey::backendImplementation() const -{ - return d->keyBackend.get(); -} /*! \fn bool QSslKey::operator!=(const QSslKey &other) const Returns \c true if this key is not equal to key \a other; otherwise |