• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

gpgop.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2005  Justin Karneges <justin@affinix.com>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00017  *
00018  */
00019 
00020 #ifndef GPGOP_H
00021 #define GPGOP_H
00022 
00023 #include <QtCrypto>
00024 #include "qpipe.h"
00025 
00026 namespace gpgQCAPlugin {
00027 
00028 class GpgOp : public QObject
00029 {
00030     Q_OBJECT
00031 public:
00032     enum Type
00033     {
00034         Check,             // --version
00035         SecretKeyringFile, // --list-secret-keys
00036         PublicKeyringFile, // --list-public-keys
00037         SecretKeys,        // --fixed-list-mode --with-colons --list-secret-keys
00038         PublicKeys,        // --fixed-list-mode --with-colons --list-public-keys
00039         Encrypt,           // --encrypt
00040         Decrypt,           // --decrypt
00041         Sign,              // --sign
00042         SignAndEncrypt,    // --sign --encrypt
00043         SignClearsign,     // --clearsign
00044         SignDetached,      // --detach-sign
00045         Verify,            // --verify
00046         VerifyDetached,    // --verify
00047         Import,            // --import
00048         Export,            // --export
00049         DeleteKey          // --delete-key
00050     };
00051 
00052     enum VerifyResult
00053     {
00054         VerifyGood,        // good sig
00055         VerifyBad,         // bad sig
00056         VerifyNoKey        // we don't have signer's public key
00057     };
00058 
00059     enum Error
00060     {
00061         ErrorProcess,          // startup, process, or ipc error
00062         ErrorPassphrase,       // passphrase was either wrong or not provided
00063         ErrorFormat,           // input format was bad
00064         ErrorSignerExpired,    // signing key is expired
00065         ErrorEncryptExpired,   // encrypting key is expired
00066         ErrorEncryptUntrusted, // encrypting key is untrusted
00067         ErrorEncryptInvalid,   // encrypting key is invalid in some way
00068         ErrorDecryptNoKey,     // missing decrypt key
00069         ErrorUnknown           // other error
00070     };
00071 
00072     class Event
00073     {
00074     public:
00075         enum Type
00076         {
00077             None,
00078             ReadyRead,
00079             BytesWritten,
00080             Finished,
00081             NeedPassphrase,
00082             NeedCard,
00083             ReadyReadDiagnosticText
00084         };
00085 
00086         Type type;
00087         int written;   // BytesWritten
00088         QString keyId; // NeedPassphrase
00089 
00090         Event() : type(None), written(0) {}
00091     };
00092 
00093     class KeyItem
00094     {
00095     public:
00096         enum Type
00097         {
00098             RSA,
00099             DSA,
00100             ElGamal,
00101             Unknown
00102         };
00103 
00104         enum Caps
00105         {
00106             Encrypt = 0x01,
00107             Sign    = 0x02,
00108             Certify = 0x04,
00109             Auth    = 0x08
00110         };
00111 
00112         QString id;
00113         Type type;
00114         int bits;
00115         QDateTime creationDate;
00116         QDateTime expirationDate;
00117         int caps; // flags OR'd together
00118         QString fingerprint;
00119 
00120         KeyItem() : type(Unknown), bits(0), caps(0) {}
00121     };
00122 
00123     class Key
00124     {
00125     public:
00126         QList<KeyItem> keyItems; // first item is primary
00127         QStringList userIds;
00128         bool isTrusted;
00129 
00130         Key() : isTrusted(false) {}
00131     };
00132     typedef QList<Key> KeyList;
00133 
00134     explicit GpgOp(const QString &bin, QObject *parent = 0);
00135     ~GpgOp();
00136 
00137     void reset();
00138 
00139     bool isActive() const;
00140     Type op() const;
00141 
00142     void setAsciiFormat(bool b);
00143     void setDisableAgent(bool b);
00144     void setAlwaysTrust(bool b);
00145     void setKeyrings(const QString &pubfile, const QString &secfile); // for keylists and import
00146 
00147     void doCheck();
00148     void doSecretKeyringFile();
00149     void doPublicKeyringFile();
00150     void doSecretKeys();
00151     void doPublicKeys();
00152     void doEncrypt(const QStringList &recip_ids);
00153     void doDecrypt();
00154     void doSign(const QString &signer_id);
00155     void doSignAndEncrypt(const QString &signer_id, const QStringList &recip_ids);
00156     void doSignClearsign(const QString &signer_id);
00157     void doSignDetached(const QString &signer_id);
00158     void doVerify();
00159     void doVerifyDetached(const QByteArray &sig);
00160     void doImport(const QByteArray &in);
00161     void doExport(const QString &key_id);
00162     void doDeleteKey(const QString &key_fingerprint);
00163 
00164 #ifdef QPIPE_SECURE
00165     void submitPassphrase(const QCA::SecureArray &a);
00166 #else
00167     void submitPassphrase(const QByteArray &a);
00168 #endif
00169     void cardOkay();
00170 
00171     // for encrypt, decrypt, sign, verify, export
00172     QByteArray read();
00173     void write(const QByteArray &in);
00174     void endWrite();
00175 
00176     QString readDiagnosticText();
00177 
00178     // for synchronous operation
00179     Event waitForEvent(int msecs = -1);
00180 
00181     // results
00182     bool success() const;
00183     Error errorCode() const;
00184     KeyList keys() const;              // Keys
00185     QString keyringFile() const;       // KeyringFile
00186     QString encryptedToId() const;     // Decrypt (for ErrorDecryptNoKey)
00187     bool wasSigned() const;            // Decrypt
00188     QString signerId() const;          // Verify
00189     QDateTime timestamp() const;       // Verify
00190     VerifyResult verifyResult() const; // Verify
00191 
00192 Q_SIGNALS:
00193     void readyRead();
00194     void bytesWritten(int bytes);
00195     void finished();
00196     void needPassphrase(const QString &keyId);
00197     void needCard();
00198     void readyReadDiagnosticText();
00199 
00200 private:
00201     class Private;
00202     friend class Private;
00203     Private *d;
00204 };
00205 
00206 }
00207 
00208 #endif

qca

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

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal