QXmpp
Version: 1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
QXmppHashing_p.h
1
// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
2
//
3
// SPDX-License-Identifier: LGPL-2.1-or-later
4
5
#ifndef QXMPPHASHING_H
6
#define QXMPPHASHING_H
7
8
#include "QXmppError.h"
9
#include "QXmppGlobal.h"
10
#include "QXmppHash.h"
11
12
#include <memory>
13
#include <variant>
14
#include <vector>
15
16
#include <QCryptographicHash>
17
18
template
<
typename
T>
19
class
QFuture;
20
class
QXmppHash
;
21
22
namespace
QXmpp::Private {
23
24
struct
HashingResult {
25
using
Result = std::variant<std::vector<QXmppHash>, Cancelled, QXmppError>;
26
27
HashingResult(Result result, std::unique_ptr<QIODevice> data)
28
: result(std::move(result)), data(std::move(data))
29
{
30
}
31
32
Result result;
33
std::unique_ptr<QIODevice> data;
34
};
35
36
struct
HashVerificationResult {
37
struct
NoStrongHashes { };
38
struct
NotMatching { };
39
struct
Verified { };
40
using
Result = std::variant<NoStrongHashes, NotMatching, Verified, Cancelled, QXmppError>;
41
42
HashVerificationResult(Result result, std::unique_ptr<QIODevice> data)
43
: result(std::move(result)), data(std::move(data))
44
{
45
}
46
47
Result result;
48
std::unique_ptr<QIODevice> data;
49
};
50
51
using
HashingResultPtr = std::shared_ptr<HashingResult>;
52
using
HashVerificationResultPtr = std::shared_ptr<HashVerificationResult>;
53
54
bool
isHashingAlgorithmSecure(
HashAlgorithm
algorithm);
55
uint16_t hashPriority(
HashAlgorithm
algorithm);
56
57
// QXMPP_EXPORT for unit tests
58
QXMPP_EXPORT QFuture<HashingResultPtr> calculateHashes(std::unique_ptr<QIODevice> data, std::vector<HashAlgorithm> hashes);
59
QFuture<HashVerificationResultPtr> verifyHashes(std::unique_ptr<QIODevice> data, std::vector<QXmppHash> hashes);
60
61
}
// namespace QXmpp::Private
62
63
#endif
// QXMPPHASHING_H
QXmppHash
Definition
QXmppHash.h:40
QXmpp::HashAlgorithm
HashAlgorithm
Definition
QXmppHash.h:20
src
base
QXmppHashing_p.h
Generated by
1.17.0