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// Qt-Security score:critical reason:cryptography
4
5#ifndef QMESSAGEAUTHENTICATIONCODE_H
6#define QMESSAGEAUTHENTICATIONCODE_H
7
8#include <QtCore/qcryptographichash.h>
9
11
12
14class QIODevice;
15
16// implemented in qcryptographichash.cpp
17class Q_CORE_EXPORT QMessageAuthenticationCode
18{
19public:
20#if QT_CORE_REMOVED_SINCE(6, 6)
21 explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method,
22 const QByteArray &key);
23#endif
24 explicit QMessageAuthenticationCode(QCryptographicHash::Algorithm method,
25 QByteArrayView key = {});
26
27 QMessageAuthenticationCode(QMessageAuthenticationCode &&other) noexcept
28 : d{std::exchange(other.d, nullptr)} {}
29 ~QMessageAuthenticationCode();
30
31 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QMessageAuthenticationCode)
32 void swap(QMessageAuthenticationCode &other) noexcept
33 { qt_ptr_swap(d, other.d); }
34
35 void reset() noexcept;
36
37#if QT_CORE_REMOVED_SINCE(6, 6)
38 void setKey(const QByteArray &key);
39#endif
40 void setKey(QByteArrayView key) noexcept;
41
42 void addData(const char *data, qsizetype length);
43#if QT_CORE_REMOVED_SINCE(6, 6)
44 void addData(const QByteArray &data);
45#endif
46 void addData(QByteArrayView data) noexcept;
47 bool addData(QIODevice *device);
48
49 QByteArrayView resultView() const noexcept;
50 QByteArray result() const;
51
52#if QT_CORE_REMOVED_SINCE(6, 6)
53 static QByteArray hash(const QByteArray &message, const QByteArray &key,
54 QCryptographicHash::Algorithm method);
55#endif
56 static QByteArray hash(QByteArrayView message, QByteArrayView key,
57 QCryptographicHash::Algorithm method);
58
59 static QByteArrayView
60 hashInto(QSpan<char> buffer, QByteArrayView message, QByteArrayView key,
61 QCryptographicHash::Algorithm method) noexcept
62 { return hashInto(as_writable_bytes(buffer), {&message, 1}, key, method); }
63 static QByteArrayView
64 hashInto(QSpan<uchar> buffer, QByteArrayView message, QByteArrayView key,
65 QCryptographicHash::Algorithm method) noexcept
66 { return hashInto(as_writable_bytes(buffer), {&message, 1}, key, method); }
67 static QByteArrayView
68 hashInto(QSpan<std::byte> buffer, QByteArrayView message,
69 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
70 { return hashInto(buffer, {&message, 1}, key, method); }
71 static QByteArrayView
72 hashInto(QSpan<char> buffer, QSpan<const QByteArrayView> messageParts,
73 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
74 { return hashInto(as_writable_bytes(buffer), messageParts, key, method); }
75 static QByteArrayView
76 hashInto(QSpan<uchar> buffer, QSpan<const QByteArrayView> messageParts,
77 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept
78 { return hashInto(as_writable_bytes(buffer), messageParts, key, method); }
79 static QByteArrayView
80 hashInto(QSpan<std::byte> buffer, QSpan<const QByteArrayView> message,
81 QByteArrayView key, QCryptographicHash::Algorithm method) noexcept;
82
83private:
84 Q_DISABLE_COPY(QMessageAuthenticationCode)
85 QMessageAuthenticationCodePrivate *d;
86};
87
88QT_END_NAMESPACE
89
90#endif
void addData(QByteArrayView bytes) noexcept
QCryptographicHashPrivate(QCryptographicHash::Algorithm method) noexcept
QByteArrayView resultView() const noexcept
static bool supportsAlgorithm(QCryptographicHash::Algorithm method)
QSpan< uchar > finalizeUnchecked(QSpan< uchar > buffer) noexcept
QMessageAuthenticationCodePrivate(QCryptographicHash::Algorithm m) noexcept
void setKey(QByteArrayView k) noexcept
Combined button and popup list for selecting options.
#define CASE(E, member)
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
QMutex QBasicMutex
Definition qmutex.h:360
static void sha3Finish(SHA3Context &ctx, QSpan< uchar > result, Sha3Variant sha3Variant)
void addData(QCryptographicHash::Algorithm method, QByteArrayView data) noexcept
void finalizeUnchecked(QCryptographicHash::Algorithm method, QSpan< uchar > buffer) noexcept
void destroy(QCryptographicHash::Algorithm method)
State(QCryptographicHash::Algorithm method)
void reset(QCryptographicHash::Algorithm method) noexcept