From d858e4ae6e0adeaad8d03b055883f411e6d19ab0 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 16 Sep 2022 19:08:02 +0200 Subject: Implement XEP-0448: Encryption for stateless file sharing parsing (#463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://xmpp.org/extensions/xep-0448.html Co-authored-by: Jonah BrĂ¼chert --- src/base/QXmppEncryptedFileSource_p.h | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/base/QXmppEncryptedFileSource_p.h (limited to 'src/base/QXmppEncryptedFileSource_p.h') diff --git a/src/base/QXmppEncryptedFileSource_p.h b/src/base/QXmppEncryptedFileSource_p.h new file mode 100644 index 00000000..21270de2 --- /dev/null +++ b/src/base/QXmppEncryptedFileSource_p.h @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: 2022 Linus Jahn +// SPDX-FileCopyrightText: 2022 Jonah BrĂ¼chert +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef QXMPPENCRYPTEDFILESOURCE_H +#define QXMPPENCRYPTEDFILESOURCE_H + +#include "QXmppGlobal.h" +#include "QXmppHash.h" +#include "QXmppHttpFileSource.h" + +#include +#include +#include + +class QXmppEncryptedFileSourcePrivate; + +// exported for tests +class QXMPP_EXPORT QXmppEncryptedFileSource +{ +public: + enum Cipher { + Aes128GcmNopadding, + Aes256GcmNopadding, + Aes256CbcPkcs7, + }; + + QXmppEncryptedFileSource(); + + Cipher cipher() const; + void setCipher(Cipher newCipher); + + const QByteArray &key() const; + void setKey(const QByteArray &newKey); + + const QByteArray &iv() const; + void setIv(const QByteArray &newIv); + + const QVector &hashes() const; + void setHashes(const QVector &newHashes); + + const QVector &httpSources() const; + void setHttpSources(const QVector &newHttpSources); + + /// \cond + bool parse(const QDomElement &el); + void toXml(QXmlStreamWriter *writer) const; + /// \endcond + +private: + Cipher m_cipher = Aes128GcmNopadding; + QByteArray m_key; + QByteArray m_iv; + QVector m_hashes; + QVector m_httpSources; +}; + +#endif // QXMPPENCRYPTEDFILESOURCE_H -- cgit v1.2.3