• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkpgp

  • sources
  • kde-4.14
  • kdepim
  • libkpgp
kpgpbase.h
Go to the documentation of this file.
1 /*
2  kpgpbase.h
3 
4  Copyright (C) 2001,2002 the KPGP authors
5  See file AUTHORS.kpgp for details
6 
7  This file is part of KPGP, the KDE PGP/GnuPG support library.
8 
9  KPGP is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software Foundation,
16  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef KPGPBASE_H
20 #define KPGPBASE_H
21 
22 #include "kpgpkey.h"
23 #include "kpgpblock.h"
24 
25 #include <QtCore/QString>
26 #include <QtCore/QStringList>
27 
28 namespace Kpgp {
29 
30 class Base
31 {
32 public:
33 
35  Base();
36  virtual ~Base();
37 
38 
40  virtual int encrypt( Block& , const KeyIDList& ) { return OK; }
41 
43  virtual int clearsign( Block& , const char *) { return OK; }
44 
46  virtual int encsign( Block& , const KeyIDList& ,
47  const char * = 0) { return OK; }
48 
50  virtual int decrypt( Block& , const char * = 0) { return OK; }
51 
53  virtual int verify( Block& block ) { return decrypt( block, 0 ); }
54 
55 
61  virtual Key* readPublicKey( const KeyID&, const bool = false,
62  Key* = 0 )
63  { return 0; }
64 
66  virtual KeyList publicKeys( const QStringList & = QStringList() )
67  { return KeyList(); }
68 
70  virtual KeyList secretKeys( const QStringList & = QStringList() )
71  { return KeyList(); }
72 
75  virtual QByteArray getAsciiPublicKey(const KeyID& ) { return QByteArray(); }
76 
79  virtual int signKey(const KeyID& , const char *) { return OK; }
80 
81 
84  virtual QString lastErrorMessage() const;
85 
86 
87 protected:
88  virtual int run( const char *cmd, const char *passphrase = 0,
89  bool onlyReadFromPGP = false );
90  virtual int runGpg( const char *cmd, const char *passphrase = 0,
91  bool onlyReadFromGnuPG = false );
92  virtual void clear();
93 
94  QByteArray addUserId();
95 
96  QByteArray input;
97  QByteArray output;
98  QByteArray error;
99  QString errMsg;
100 
101  QByteArray mVersion;
102 
103  int status;
104 
105 };
106 
107 // ---------------------------------------------------------------------------
108 
109 class Base2 : public Base
110 {
111 
112 public:
113  Base2();
114  virtual ~Base2();
115 
116  virtual int encrypt( Block& block, const KeyIDList& recipients );
117  virtual int clearsign( Block& block, const char *passphrase );
118  virtual int encsign( Block& block, const KeyIDList& recipients,
119  const char *passphrase = 0 );
120  virtual int decrypt( Block& block, const char *passphrase = 0 );
121  virtual int verify( Block& block ) { return decrypt( block, 0 ); }
122 
123  virtual Key* readPublicKey( const KeyID& keyID,
124  const bool readTrust = false,
125  Key* key = 0 );
126  virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
127  virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
128  virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
129  virtual int signKey( const KeyID& keyID, const char *passphrase );
130 
131 protected:
132  KeyList doGetPublicKeys( const QByteArray & cmd,
133  const QStringList & patterns );
134  virtual KeyList parseKeyList( const QByteArray&, bool );
135 
136 private:
137  Key* parsePublicKeyData( const QByteArray& output, Key* key = 0 );
138  void parseTrustDataForKey( Key* key, const QByteArray& str );
139 };
140 
141 class BaseG : public Base
142 {
143 
144 public:
145  BaseG();
146  virtual ~BaseG();
147 
148  virtual int encrypt( Block& block, const KeyIDList& recipients );
149  virtual int clearsign( Block& block, const char *passphrase );
150  virtual int encsign( Block& block, const KeyIDList& recipients,
151  const char *passphrase = 0 );
152  virtual int decrypt( Block& block, const char *passphrase = 0 );
153  virtual int verify( Block& block ) { return decrypt( block, 0 ); }
154 
155  virtual Key* readPublicKey( const KeyID& keyID,
156  const bool readTrust = false,
157  Key* key = 0 );
158  virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
159  virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
160  virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
161  virtual int signKey( const KeyID& keyID, const char *passphrase );
162 
163 private:
164  Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
165  KeyList parseKeyList( const QByteArray&, bool );
166 };
167 
168 
169 class Base5 : public Base
170 {
171 
172 public:
173  Base5();
174  virtual ~Base5();
175 
176  virtual int encrypt( Block& block, const KeyIDList& recipients );
177  virtual int clearsign( Block& block, const char *passphrase );
178  virtual int encsign( Block& block, const KeyIDList& recipients,
179  const char *passphrase = 0 );
180  virtual int decrypt( Block& block, const char *passphrase = 0 );
181  virtual int verify( Block& block ) { return decrypt( block, 0 ); }
182 
183  virtual Key* readPublicKey( const KeyID& keyID,
184  const bool readTrust = false,
185  Key* key = 0 );
186  virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
187  virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
188  virtual QByteArray getAsciiPublicKey( const KeyID& keyID );
189  virtual int signKey( const KeyID& keyID, const char *passphrase );
190 
191 private:
192  Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
193  Key* parseSingleKey( const QByteArray& output, Key* key = 0 );
194  KeyList parseKeyList( const QByteArray& output, bool );
195  void parseTrustDataForKey( Key* key, const QByteArray& str );
196 };
197 
198 
199 class Base6 : public Base2
200 {
201 
202 public:
203  Base6();
204  virtual ~Base6();
205 
206  virtual int decrypt( Block& block, const char *passphrase = 0 );
207  virtual int verify( Block& block ) { return decrypt( block, 0 ); }
208 
209  virtual Key* readPublicKey( const KeyID& keyID,
210  const bool readTrust = false,
211  Key* key = 0 );
212  virtual KeyList publicKeys( const QStringList & patterns = QStringList() );
213  virtual KeyList secretKeys( const QStringList & patterns = QStringList() );
214 
215  virtual int isVersion6();
216 
217 protected:
218  virtual KeyList parseKeyList( const QByteArray &, bool );
219 
220 private:
221  Key* parseKeyData( const QByteArray& output, int& offset, Key* key = 0 );
222  Key* parseSingleKey( const QByteArray& output, Key* key = 0 );
223  void parseTrustDataForKey( Key* key, const QByteArray& str );
224 };
225 
226 // ---------------------------------------------------------------------------
227 // inlined functions
228 
229 inline QString
230 Base::lastErrorMessage() const
231 {
232  return errMsg;
233 }
234 
235 
236 } // namespace Kpgp
237 
238 #endif
Kpgp::BaseG::~BaseG
virtual ~BaseG()
Definition: kpgpbaseG.cpp:50
Kpgp::KeyList
QList< Key * > KeyList
Definition: kpgpkey.h:843
Kpgp::Base2::~Base2
virtual ~Base2()
Definition: kpgpbase2.cpp:43
Kpgp::BaseG::publicKeys
virtual KeyList publicKeys(const QStringList &patterns=QStringList())
Returns the list of public keys in the users public keyring.
Definition: kpgpbaseG.cpp:417
Kpgp::Base::publicKeys
virtual KeyList publicKeys(const QStringList &=QStringList())
Returns the list of public keys in the users public keyring.
Definition: kpgpbase.h:66
Kpgp::Base::encsign
virtual int encsign(Block &, const KeyIDList &, const char *=0)
Encrypts and signs the message with the given keys.
Definition: kpgpbase.h:46
Kpgp::BaseG::signKey
virtual int signKey(const KeyID &keyID, const char *passphrase)
Signs the given key with the currently set user key.
Definition: kpgpbaseG.cpp:481
Kpgp::Base5::publicKeys
virtual KeyList publicKeys(const QStringList &patterns=QStringList())
Returns the list of public keys in the users public keyring.
Definition: kpgpbase5.cpp:353
QByteArray
Kpgp::Base::decrypt
virtual int decrypt(Block &, const char *=0)
Decrypts the message.
Definition: kpgpbase.h:50
Kpgp::Base::output
QByteArray output
Definition: kpgpbase.h:97
Kpgp::Base::verify
virtual int verify(Block &block)
Verifies the message.
Definition: kpgpbase.h:53
Kpgp::BaseG::encrypt
virtual int encrypt(Block &block, const KeyIDList &recipients)
Encrypts the message with the given keys.
Definition: kpgpbaseG.cpp:56
Kpgp::Base::lastErrorMessage
virtual QString lastErrorMessage() const
Returns an error message if an error occurred during the last operation.
Definition: kpgpbase.h:230
Kpgp::Base5::readPublicKey
virtual Key * readPublicKey(const KeyID &keyID, const bool readTrust=false, Key *key=0)
Reads the key data for the given key and returns it.
Definition: kpgpbase5.cpp:319
Kpgp::Base::clearsign
virtual int clearsign(Block &, const char *)
Clearsigns the message with the currently set key.
Definition: kpgpbase.h:43
Kpgp::Base2::secretKeys
virtual KeyList secretKeys(const QStringList &patterns=QStringList())
Returns the list of secret keys in the users secret keyring.
Definition: kpgpbase2.cpp:568
Kpgp::Block
Definition: kpgpblock.h:89
Kpgp::Base5::secretKeys
virtual KeyList secretKeys(const QStringList &patterns=QStringList())
Returns the list of secret keys in the users secret keyring.
Definition: kpgpbase5.cpp:386
Kpgp::Base6
Definition: kpgpbase.h:199
Kpgp::Base6::verify
virtual int verify(Block &block)
Verifies the message.
Definition: kpgpbase.h:207
Kpgp::Base5::getAsciiPublicKey
virtual QByteArray getAsciiPublicKey(const KeyID &keyID)
Returns the ascii armored data of the public key with the given key id.
Definition: kpgpbase5.cpp:413
Kpgp::Base::addUserId
QByteArray addUserId()
Definition: kpgpbase.cpp:688
Kpgp::Base2::Base2
Base2()
Definition: kpgpbase2.cpp:37
Kpgp::BaseG::secretKeys
virtual KeyList secretKeys(const QStringList &patterns=QStringList())
Returns the list of secret keys in the users secret keyring.
Definition: kpgpbaseG.cpp:449
Kpgp::BaseG::readPublicKey
virtual Key * readPublicKey(const KeyID &keyID, const bool readTrust=false, Key *key=0)
Reads the key data for the given key and returns it.
Definition: kpgpbaseG.cpp:381
Kpgp::Base::errMsg
QString errMsg
Definition: kpgpbase.h:99
Kpgp::Base2::clearsign
virtual int clearsign(Block &block, const char *passphrase)
Clearsigns the message with the currently set key.
Definition: kpgpbase2.cpp:56
Kpgp::Base2::signKey
virtual int signKey(const KeyID &keyID, const char *passphrase)
Signs the given key with the currently set user key.
Definition: kpgpbase2.cpp:575
Kpgp::BaseG
Definition: kpgpbase.h:141
Kpgp::Base::mVersion
QByteArray mVersion
Definition: kpgpbase.h:101
Kpgp::Base5::signKey
virtual int signKey(const KeyID &keyID, const char *passphrase)
Signs the given key with the currently set user key.
Definition: kpgpbase5.cpp:431
Kpgp::Base::readPublicKey
virtual Key * readPublicKey(const KeyID &, const bool=false, Key *=0)
Reads the key data for the given key and returns it.
Definition: kpgpbase.h:61
Kpgp::Base::signKey
virtual int signKey(const KeyID &, const char *)
Signs the given key with the currently set user key.
Definition: kpgpbase.h:79
Kpgp::Base6::secretKeys
virtual KeyList secretKeys(const QStringList &patterns=QStringList())
Returns the list of secret keys in the users secret keyring.
Definition: kpgpbase6.cpp:339
Kpgp::BaseG::decrypt
virtual int decrypt(Block &block, const char *passphrase=0)
Decrypts the message.
Definition: kpgpbaseG.cpp:206
Kpgp::Base::run
virtual int run(const char *cmd, const char *passphrase=0, bool onlyReadFromPGP=false)
Definition: kpgpbase.cpp:67
Kpgp::Base6::decrypt
virtual int decrypt(Block &block, const char *passphrase=0)
Decrypts the message.
Definition: kpgpbase6.cpp:45
Kpgp::Base6::publicKeys
virtual KeyList publicKeys(const QStringList &patterns=QStringList())
Returns the list of public keys in the users public keyring.
Definition: kpgpbase6.cpp:222
Kpgp::Base5
Definition: kpgpbase.h:169
Kpgp::Base5::~Base5
virtual ~Base5()
Definition: kpgpbase5.cpp:44
Kpgp::BaseG::verify
virtual int verify(Block &block)
Verifies the message.
Definition: kpgpbase.h:153
Kpgp::Base2::encrypt
virtual int encrypt(Block &block, const KeyIDList &recipients)
Encrypts the message with the given keys.
Definition: kpgpbase2.cpp:49
Kpgp::Base::getAsciiPublicKey
virtual QByteArray getAsciiPublicKey(const KeyID &)
Returns the ascii armored data of the public key with the given key id.
Definition: kpgpbase.h:75
Kpgp::Base6::Base6
Base6()
Definition: kpgpbase6.cpp:33
Kpgp::Base2::doGetPublicKeys
KeyList doGetPublicKeys(const QByteArray &cmd, const QStringList &patterns)
Definition: kpgpbase2.cpp:511
QString
Kpgp::Base2::decrypt
virtual int decrypt(Block &block, const char *passphrase=0)
Decrypts the message.
Definition: kpgpbase2.cpp:225
QList
Kpgp::KeyIDList
Definition: kpgpkey.h:57
Kpgp::Base6::~Base6
virtual ~Base6()
Definition: kpgpbase6.cpp:39
Kpgp::Base2::verify
virtual int verify(Block &block)
Verifies the message.
Definition: kpgpbase.h:121
Kpgp::OK
Definition: kpgpblock.h:46
QStringList
Kpgp::Base5::clearsign
virtual int clearsign(Block &block, const char *passphrase)
Clearsigns the message with the currently set key.
Definition: kpgpbase5.cpp:57
Kpgp::Base5::encsign
virtual int encsign(Block &block, const KeyIDList &recipients, const char *passphrase=0)
Encrypts and signs the message with the given keys.
Definition: kpgpbase5.cpp:64
Kpgp::Base::Base
Base()
virtual class used internally by kpgp
Definition: kpgpbase.cpp:44
Kpgp::Base2::encsign
virtual int encsign(Block &block, const KeyIDList &recipients, const char *passphrase=0)
Encrypts and signs the message with the given keys.
Definition: kpgpbase2.cpp:63
Kpgp::Base6::isVersion6
virtual int isVersion6()
Definition: kpgpbase6.cpp:346
Kpgp::BaseG::clearsign
virtual int clearsign(Block &block, const char *passphrase)
Clearsigns the message with the currently set key.
Definition: kpgpbaseG.cpp:63
Kpgp::Base::~Base
virtual ~Base()
Definition: kpgpbase.cpp:50
kpgpkey.h
kpgpblock.h
Kpgp::Base5::Base5
Base5()
Definition: kpgpbase5.cpp:38
Kpgp::Base2::parseKeyList
virtual KeyList parseKeyList(const QByteArray &, bool)
Definition: kpgpbase2.cpp:893
Kpgp::Base::runGpg
virtual int runGpg(const char *cmd, const char *passphrase=0, bool onlyReadFromGnuPG=false)
Definition: kpgpbase.cpp:390
Kpgp::Base6::parseKeyList
virtual KeyList parseKeyList(const QByteArray &, bool)
Definition: kpgpbase6.cpp:727
Kpgp::BaseG::BaseG
BaseG()
Definition: kpgpbaseG.cpp:34
Kpgp::Base::encrypt
virtual int encrypt(Block &, const KeyIDList &)
Encrypts the message with the given keys.
Definition: kpgpbase.h:40
Kpgp::Base
Definition: kpgpbase.h:30
Kpgp::Base::input
QByteArray input
Definition: kpgpbase.h:96
Kpgp::Base6::readPublicKey
virtual Key * readPublicKey(const KeyID &keyID, const bool readTrust=false, Key *key=0)
Reads the key data for the given key and returns it.
Definition: kpgpbase6.cpp:184
Kpgp::Base5::encrypt
virtual int encrypt(Block &block, const KeyIDList &recipients)
Encrypts the message with the given keys.
Definition: kpgpbase5.cpp:50
Kpgp::Base5::verify
virtual int verify(Block &block)
Verifies the message.
Definition: kpgpbase.h:181
Kpgp::Key
This class is used to store information about a PGP key.
Definition: kpgpkey.h:506
Kpgp::Base5::decrypt
virtual int decrypt(Block &block, const char *passphrase=0)
Decrypts the message.
Definition: kpgpbase5.cpp:195
Kpgp::Base2::publicKeys
virtual KeyList publicKeys(const QStringList &patterns=QStringList())
Returns the list of public keys in the users public keyring.
Definition: kpgpbase2.cpp:504
Kpgp::BaseG::encsign
virtual int encsign(Block &block, const KeyIDList &recipients, const char *passphrase=0)
Encrypts and signs the message with the given keys.
Definition: kpgpbaseG.cpp:70
Kpgp::Base2
Definition: kpgpbase.h:109
Kpgp::Base::clear
virtual void clear()
Definition: kpgpbase.cpp:56
Kpgp::Base::error
QByteArray error
Definition: kpgpbase.h:98
Kpgp::Base::status
int status
Definition: kpgpbase.h:103
Kpgp::Base2::readPublicKey
virtual Key * readPublicKey(const KeyID &keyID, const bool readTrust=false, Key *key=0)
Reads the key data for the given key and returns it.
Definition: kpgpbase2.cpp:464
Kpgp::BaseG::getAsciiPublicKey
virtual QByteArray getAsciiPublicKey(const KeyID &keyID)
Returns the ascii armored data of the public key with the given key id.
Definition: kpgpbaseG.cpp:502
Kpgp::Base2::getAsciiPublicKey
virtual QByteArray getAsciiPublicKey(const KeyID &keyID)
Returns the ascii armored data of the public key with the given key id.
Definition: kpgpbase2.cpp:594
Kpgp::Base::secretKeys
virtual KeyList secretKeys(const QStringList &=QStringList())
Returns the list of secret keys in the users secret keyring.
Definition: kpgpbase.h:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkpgp

Skip menu "libkpgp"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal