QXmpp  Version: 1.5.5
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 "QXmppGlobal.h"
9 
10 #include <QByteArray>
11 
12 class QDomElement;
13 class QXmlStreamWriter;
14 
15 namespace QXmpp {
16 
17 enum class HashAlgorithm : uint32_t {
18  Unknown,
19  Md2,
20  Md5,
21  Shake128,
22  Shake256,
23  Sha1,
24  Sha224,
25  Sha256,
26  Sha384,
27  Sha512,
28  Sha3_256,
29  Sha3_512,
30  Blake2b_256,
31  Blake2b_512,
32 };
33 
34 }
35 
36 class QXMPP_EXPORT QXmppHash
37 {
38 public:
39  QXmppHash();
40 
42  bool parse(const QDomElement &el);
43  void toXml(QXmlStreamWriter *writer) const;
45 
46  QXmpp::HashAlgorithm algorithm() const;
47  void setAlgorithm(QXmpp::HashAlgorithm algorithm);
48 
49  QByteArray hash() const;
50  void setHash(const QByteArray &data);
51 
52 private:
53  QXmpp::HashAlgorithm m_algorithm = QXmpp::HashAlgorithm::Unknown;
54  QByteArray m_hash;
55 };
56 
57 class QXMPP_EXPORT QXmppHashUsed
58 {
59 public:
60  QXmppHashUsed();
62 
64  bool parse(const QDomElement &el);
65  void toXml(QXmlStreamWriter *writer) const;
67 
68  QXmpp::HashAlgorithm algorithm() const;
69  void setAlgorithm(QXmpp::HashAlgorithm algorithm);
70 
71 private:
72  QXmpp::HashAlgorithm m_algorithm = QXmpp::HashAlgorithm::Unknown;
73 };
74 
75 #endif // QXMPPHASH_H
Definition: QXmppHash.h:58
Definition: QXmppHash.h:37
HashAlgorithm
Definition: QXmppHash.h:17