diff options
Diffstat (limited to 'src/corelib/tools/qmessageauthenticationcode.h')
-rw-r--r-- | src/corelib/tools/qmessageauthenticationcode.h | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/src/corelib/tools/qmessageauthenticationcode.h b/src/corelib/tools/qmessageauthenticationcode.h index a13a3d2acf..4e88138763 100644 --- a/src/corelib/tools/qmessageauthenticationcode.h +++ b/src/corelib/tools/qmessageauthenticationcode.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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) 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QMESSAGEAUTHENTICATIONCODE_H #define QMESSAGEAUTHENTICATIONCODE_H @@ -48,25 +12,48 @@ QT_BEGIN_NAMESPACE class QMessageAuthenticationCodePrivate; class QIODevice; +// implemented in qcryptographichash.cpp class Q_CORE_EXPORT QMessageAuthenticationCode { public: +#if QT_CORE_REMOVED_SINCE(6, 6) explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method, - const QByteArray &key = QByteArray()); + const QByteArray &key); +#endif + explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method, + QByteArrayView key = {}); + + QMessageAuthenticationCode(QMessageAuthenticationCode &&other) noexcept + : d{std::exchange(other.d, nullptr)} {} ~QMessageAuthenticationCode(); - void reset(); + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QMessageAuthenticationCode) + void swap(QMessageAuthenticationCode &other) noexcept + { qt_ptr_swap(d, other.d); } + + void reset() noexcept; +#if QT_CORE_REMOVED_SINCE(6, 6) void setKey(const QByteArray &key); +#endif + void setKey(QByteArrayView key) noexcept; - void addData(const char *data, int length); + void addData(const char *data, qsizetype length); +#if QT_CORE_REMOVED_SINCE(6, 6) void addData(const QByteArray &data); +#endif + void addData(QByteArrayView data) noexcept; bool addData(QIODevice *device); + QByteArrayView resultView() const noexcept; QByteArray result() const; +#if QT_CORE_REMOVED_SINCE(6, 6) static QByteArray hash(const QByteArray &message, const QByteArray &key, QCryptographicHash::Algorithm method); +#endif + static QByteArray hash(QByteArrayView message, QByteArrayView key, + QCryptographicHash::Algorithm method); private: Q_DISABLE_COPY(QMessageAuthenticationCode) |