File indexing completed on 2024-06-16 05:00:14

0001 /*
0002     cryptohelper.h
0003 
0004     SPDX-FileCopyrightText: 2015 Sandro Knauß <knauss@kolabsys.com>
0005     SPDX-FileCopyrightText: 2001,2002 the KPGP authors
0006     See file AUTHORS.kpgp for details
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009  */
0010 
0011 #pragma once
0012 
0013 #include <QByteArray>
0014 #include <QList>
0015 
0016 namespace MimeTreeParser
0017 {
0018 enum PGPBlockType {
0019     UnknownBlock = -1, // BEGIN PGP ???
0020     NoPgpBlock = 0,
0021     PgpMessageBlock = 1, // BEGIN PGP MESSAGE
0022     MultiPgpMessageBlock = 2, // BEGIN PGP MESSAGE, PART X[/Y]
0023     SignatureBlock = 3, // BEGIN PGP SIGNATURE
0024     ClearsignedBlock = 4, // BEGIN PGP SIGNED MESSAGE
0025     PublicKeyBlock = 5, // BEGIN PGP PUBLIC KEY BLOCK
0026     PrivateKeyBlock = 6, // BEGIN PGP PRIVATE KEY BLOCK (PGP 2.x: ...SECRET...)
0027 };
0028 
0029 class Block
0030 {
0031 public:
0032     Block();
0033     Block(const QByteArray &m);
0034 
0035     Block(const QByteArray &m, PGPBlockType t);
0036 
0037     [[nodiscard]] QByteArray text() const;
0038     [[nodiscard]] PGPBlockType type() const;
0039     [[nodiscard]] PGPBlockType determineType() const;
0040 
0041     QByteArray msg;
0042     PGPBlockType mType = UnknownBlock;
0043 };
0044 
0045 /** Parses the given message and splits it into OpenPGP blocks and
0046     Non-OpenPGP blocks.
0047 */
0048 [[nodiscard]] QList<Block> prepareMessageForDecryption(const QByteArray &msg);
0049 } // namespace MimeTreeParser
0050 
0051 Q_DECLARE_TYPEINFO(MimeTreeParser::Block, Q_RELOCATABLE_TYPE);