From 2a836ec1fb8329018d23ca3adb5ad388100bd13e Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Sat, 28 Aug 2021 14:37:25 +0200 Subject: Add QXmppTrustStorage --- src/client/QXmppTrustStorage.h | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/client/QXmppTrustStorage.h (limited to 'src/client/QXmppTrustStorage.h') diff --git a/src/client/QXmppTrustStorage.h b/src/client/QXmppTrustStorage.h new file mode 100644 index 00000000..1252c06b --- /dev/null +++ b/src/client/QXmppTrustStorage.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2008-2021 The QXmpp developers + * + * Author: + * Melvin Keskin + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef QXMPPTRUSTSTORAGE_H +#define QXMPPTRUSTSTORAGE_H + +#include "QXmppGlobal.h" + +#include + +class QXmppTrustMessageKeyOwner; + +class QXMPP_EXPORT QXmppTrustStorage +{ +public: + /// + /// trust level of public long-term keys used by end-to-end encryption + /// protocols + /// + enum TrustLevel { + AutomaticallyDistrusted = 1, ///< The key is automatically distrusted (e.g., by ATM's security policy). + ManuallyDistrusted = 2, ///< The key is manually distrusted (e.g., by clicking a button or ATM). + AutomaticallyTrusted = 4, ///< The key is automatically trusted (e.g., by the client for all keys of a bare JID until one of it is authenticated). + ManuallyTrusted = 8, ///< The key is manually trusted (e.g., by clicking a button). + Authenticated = 16, ///< The key is authenticated (e.g., by QR code scanning or ATM). + }; + Q_DECLARE_FLAGS(TrustLevels, TrustLevel) + + virtual QFuture addOwnKey(const QString &encryption, const QString &keyId) = 0; + virtual QFuture removeOwnKey(const QString &encryption) = 0; + virtual QFuture ownKey(const QString &encryption) const = 0; + + virtual QFuture addKeys(const QString &encryption, const QString &keyOwnerJid, const QList &keyIds, TrustLevel trustLevel = TrustLevel::AutomaticallyDistrusted) = 0; + virtual QFuture removeKeys(const QString &encryption = {}, const QList &keyIds = {}) = 0; + virtual QFuture>> keys(const QString &encryption, TrustLevels trustLevels = {}) const = 0; + + virtual QFuture setTrustLevel(const QString &encryption, const QMultiHash &keyIds, TrustLevel trustLevel) = 0; + virtual QFuture setTrustLevel(const QString &encryption, const QList &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) = 0; + virtual QFuture trustLevel(const QString &encryption, const QString &keyId) const = 0; + + virtual QFuture addKeysForPostponedTrustDecisions(const QString &encryption, const QString &senderKeyId, const QList &keyOwners) = 0; + virtual QFuture removeKeysForPostponedTrustDecisions(const QString &encryption, const QList &keyIdsForAuthentication, const QList &keyIdsForDistrusting) = 0; + virtual QFuture removeKeysForPostponedTrustDecisions(const QString &encryption = {}, const QList &senderKeyIds = {}) = 0; + virtual QFuture>> keysForPostponedTrustDecisions(const QString &encryption, const QList &senderKeyIds = {}) = 0; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppTrustStorage::TrustLevels) + +#endif // QXMPPTRUSTSTORAGE_H -- cgit v1.2.3