QXmpp: QXmppHash.h Source File

QXmpp Version: 1.14.3

Loading...
Searching...
No Matches
QXmppHash.h
1// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPHASH_H
6#define QXMPPHASH_H
7
8#include "QXmppConstants_p.h"
9#include "QXmppGlobal.h"
10
11#include <tuple>
12
13#include <QByteArray>
14
15class QDomElement;
16class QXmlStreamWriter;
17
18namespace QXmpp {
19
20 enum class HashAlgorithm : uint32_t {
21 Unknown,
22 Md2,
23 Md5,
24 Shake128,
25 Shake256,
26 Sha1,
27 Sha224,
28 Sha256,
29 Sha384,
30 Sha512,
31 Sha3_256,
32 Sha3_512,
33 Blake2b_256,
34 Blake2b_512,
35};
36
37}
38
39 class QXMPP_EXPORT QXmppHash
40{
41public:
42 QXmppHash();
43
45 static constexpr std::tuple XmlTag = { u"hash", QXmpp::Private::ns_hashes };
46 bool parse(const QDomElement &el);
47 void toXml(QXmlStreamWriter *writer) const;
49
50 QXmpp::HashAlgorithm algorithm() const;
51 void setAlgorithm(QXmpp::HashAlgorithm algorithm);
52
53 QByteArray hash() const;
54 void setHash(const QByteArray &data);
55
56private:
57 QXmpp::HashAlgorithm m_algorithm = QXmpp::HashAlgorithm::Unknown;
58 QByteArray m_hash;
59};
60
61 class QXMPP_EXPORT QXmppHashUsed
62{
63public:
64 QXmppHashUsed();
65 QXmppHashUsed(QXmpp::HashAlgorithm algorithm);
66
68 static constexpr auto XmlTag = std::tuple { u"hash-used", QXmpp::Private::ns_hashes };
69 bool parse(const QDomElement &el);
70 void toXml(QXmlStreamWriter *writer) const;
72
73 QXmpp::HashAlgorithm algorithm() const;
74 void setAlgorithm(QXmpp::HashAlgorithm algorithm);
75
76private:
77 QXmpp::HashAlgorithm m_algorithm = QXmpp::HashAlgorithm::Unknown;
78};
79
80#endif // QXMPPHASH_H
QXmppHash::setHash
void setHash(const QByteArray &data)
Definition QXmppHash.cpp:147
QXmppHash::hash
QByteArray hash() const
Definition QXmppHash.cpp:139
QXmppHash::algorithm
QXmpp::HashAlgorithm algorithm() const
Definition QXmppHash.cpp:123
QXmppHash::setAlgorithm
void setAlgorithm(QXmpp::HashAlgorithm algorithm)
Definition QXmppHash.cpp:131
QXmppHashUsed::setAlgorithm
void setAlgorithm(QXmpp::HashAlgorithm algorithm)
Definition QXmppHash.cpp:163
QXmppHashUsed::algorithm
QXmpp::HashAlgorithm algorithm() const
Definition QXmppHash.cpp:155
QXmpp
Definition Algorithms.h:14
QXmpp::HashAlgorithm
HashAlgorithm
Definition QXmppHash.h:20