Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmessageauthenticationcode.h
Go to the documentation of this file.
1// Copyright (C) 2013 Ruslan Nigmatullin <euroelessar@yandex.ru>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMESSAGEAUTHENTICATIONCODE_H
5#define QMESSAGEAUTHENTICATIONCODE_H
6
7#include <QtCore/qcryptographichash.h>
8
10
11
13class QIODevice;
14
15// implemented in qcryptographichash.cpp
16class Q_CORE_EXPORT QMessageAuthenticationCode
17{
18public:
19#if QT_CORE_REMOVED_SINCE(6, 6)
20 explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method,
21 const QByteArray &key);
22#endif
23 explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method,
24 QByteArrayView key = {});
25
26 QMessageAuthenticationCode(QMessageAuthenticationCode &&other) noexcept
27 : d{std::exchange(other.d, nullptr)} {}
28 ~QMessageAuthenticationCode();
29
30 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QMessageAuthenticationCode)
31 void swap(QMessageAuthenticationCode &other) noexcept
32 { qt_ptr_swap(d, other.d); }
33
34 void reset() noexcept;
35
36#if QT_CORE_REMOVED_SINCE(6, 6)
37 void setKey(const QByteArray &key);
38#endif
39 void setKey(QByteArrayView key) noexcept;
40
41 void addData(const char *data, qsizetype length);
42#if QT_CORE_REMOVED_SINCE(6, 6)
43 void addData(const QByteArray &data);
44#endif
45 void addData(QByteArrayView data) noexcept;
46 bool addData(QIODevice *device);
47
48 QByteArrayView resultView() const noexcept;
49 QByteArray result() const;
50
51#if QT_CORE_REMOVED_SINCE(6, 6)
52 static QByteArray hash(const QByteArray &message, const QByteArray &key,
53 QCryptographicHash::Algorithm method);
54#endif
55 static QByteArray hash(QByteArrayView message, QByteArrayView key,
56 QCryptographicHash::Algorithm method);
57
58 static QByteArrayView
59 hashInto(QSpan<char> buffer, QByteArrayView message, QByteArrayView key,
60 QCryptographicHash::Algorithm method) noexcept
61 { return hashInto(as_writable_bytes(buffer), {&message, 1}, key, method); }
62 static QByteArrayView
63 hashInto(QSpan<uchar> buffer, QByteArrayView message, QByteArrayView key,
64 QCryptographicHash::Algorithm method) noexcept
65 { return hashInto(as_writable_bytes(buffer), {&message, 1}, key, method); }
66 static QByteArrayView
67 hashInto(QSpan<std::byte> buffer, QByteArrayView message,
68 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
69 { return hashInto(buffer, {&message, 1}, key, method); }
70 static QByteArrayView
71 hashInto(QSpan<char> buffer, QSpan<const QByteArrayView> messageParts,
72 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
73 { return hashInto(as_writable_bytes(buffer), messageParts, key, method); }
74 static QByteArrayView
75 hashInto(QSpan<uchar> buffer, QSpan<const QByteArrayView> messageParts,
76 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
77 { return hashInto(as_writable_bytes(buffer), messageParts, key, method); }
78 static QByteArrayView
79 hashInto(QSpan<std::byte> buffer, QSpan<const QByteArrayView> message,
80 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept;
81
82private:
83 Q_DISABLE_COPY(QMessageAuthenticationCode)
84 QMessageAuthenticationCodePrivate *d;
85};
86
87QT_END_NAMESPACE
88
89#endif
void addData(QByteArrayView bytes) noexcept
QCryptographicHashPrivate(QCryptographicHash::Algorithm method) noexcept
QByteArrayView resultView() const noexcept
static bool supportsAlgorithm(QCryptographicHash::Algorithm method)
QMessageAuthenticationCodePrivate(QCryptographicHash::Algorithm m) noexcept
void setKey(QByteArrayView k) noexcept
Combined button and popup list for selecting options.
constexpr int maxHashBlockSize()
QT_WARNING_PUSH QT_WARNING_POP static QT_BEGIN_NAMESPACE constexpr int hashLengthInternal(QCryptographicHash::Algorithm method) noexcept
static constexpr int qt_hash_block_size(QCryptographicHash::Algorithm method)
static HashBlock xored(const HashBlock &block, quint8 val) noexcept
static constexpr int maxHashLength()
constexpr int minHashBlockSize()
constexpr int gcdHashBlockSize()
@ BAD_HASHLEN
unsigned long long DataLength
spongeState SHA3Context
unsigned char BitSequence
spongeState hashState
#define CASE(Enum, Size)
QMutex QBasicMutex
Definition qmutex.h:346
void addData(QCryptographicHash::Algorithm method, QByteArrayView data) noexcept
void finalizeUnchecked(QCryptographicHash::Algorithm method, HashResult &result) noexcept
void destroy(QCryptographicHash::Algorithm method)
static void sha3Finish(SHA3Context &ctx, HashResult &result, int bitCount, Sha3Variant sha3Variant)
State(QCryptographicHash::Algorithm method)
void reset(QCryptographicHash::Algorithm method) noexcept