9#include "cryptohelper.h"
11using namespace MimeTreeParser;
13PGPBlockType Block::determineType()
const
16 if (data.
startsWith(
"-----BEGIN PGP PUBLIC KEY BLOCK-----")) {
18 }
else if (data.
startsWith(
"-----BEGIN PGP SIGNED")) {
19 return ClearsignedBlock;
20 }
else if (data.
startsWith(
"-----BEGIN PGP SIGNATURE")) {
21 return SignatureBlock;
22 }
else if (data.
startsWith(
"-----BEGIN PGP PUBLIC")) {
23 return PublicKeyBlock;
24 }
else if (data.
startsWith(
"-----BEGIN PGP PRIVATE") || data.
startsWith(
"-----BEGIN PGP SECRET")) {
25 return PrivateKeyBlock;
26 }
else if (data.
startsWith(
"-----BEGIN PGP MESSAGE")) {
27 if (data.
startsWith(
"-----BEGIN PGP MESSAGE PART")) {
28 return MultiPgpMessageBlock;
30 return PgpMessageBlock;
32 }
else if (data.
startsWith(
"-----BEGIN PGP ARMORED FILE")) {
33 return PgpMessageBlock;
34 }
else if (data.
startsWith(
"-----BEGIN PGP ")) {
43 PGPBlockType pgpBlock = NoPgpBlock;
47 const int length = msg.
length();
52 if (msg.
startsWith(
"-----BEGIN PGP PUBLIC KEY BLOCK-----")) {
61 blocks.
append(Block(msg, NoPgpBlock));
72 pgpBlock = ClearsignedBlock;
74 pgpBlock = UnknownBlock;
78 nextStart = msg.
indexOf(
"\n-----BEGIN PGP ",
start + 15);
82 blocks.
append(Block(msg.
mid(lastEnd + 1), UnknownBlock));
89 if ((nextStart == -1) || (nextEnd < nextStart) || (pgpBlock == ClearsignedBlock)) {
93 if (
start - lastEnd - 1 > 0) {
94 blocks.
append(Block(msg.
mid(lastEnd + 1,
start - lastEnd - 1), NoPgpBlock));
97 lastEnd = msg.
indexOf(
"\n", nextEnd + 14);
105 if ((nextStart != -1) && (nextEnd > nextStart)) {
106 nextStart = msg.
indexOf(
"\n-----BEGIN PGP ", lastEnd + 1);
114 if (lastEnd + 1 < length) {
116 blocks.
append(Block(msg.
mid(lastEnd + 1), NoPgpBlock));
127Block::Block() =
default;
132 mType = determineType();
135Block::Block(
const QByteArray &m, PGPBlockType t)
146PGPBlockType Block::type()
const
Q_SCRIPTABLE Q_NOREPLY void start()
const char * constData() const const
qsizetype indexOf(QByteArrayView bv, qsizetype from) const const
bool isEmpty() const const
qsizetype length() const const
QByteArray mid(qsizetype pos, qsizetype len) const const
bool startsWith(QByteArrayView bv) const const
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.