certmanager/lib Library API Documentation

cryptplugwrapper.h

Go to the documentation of this file.
00001 
00029 #ifndef cryptplugwrapper_h
00030 #define cryptplugwrapper_h
00031 
00032 #include "cryptplug.h"
00033 
00034 #ifndef LIBKLEOPATRA_NO_COMPAT
00035 
00036 /*
00037  *
00038  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00039  *                                                                        *
00040  *  This file's source comments are optimized for processing by Doxygen.  *
00041  *                                                                        *
00042  *  To obtain best results please get an updated version of Doxygen,      *
00043  *  for sources and binaries goto http://www.doxygen.org/index.html       *
00044  *                                                                        *
00045   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00046 
00047                                                                           *
00048                                                                           */
00049 #include <kdemacros.h>
00050 
00051 #include "kleo/cryptobackend.h"
00052 
00053 #include <qdatetime.h>
00054 
00055 #include <qvaluelist.h>
00056 #include <qpair.h>
00057 #include <qstringlist.h>
00058 #include <qstring.h>
00059 
00060 
00061 class KConfigBase;
00062 class QGpgMECryptoConfig;
00063 
00064 namespace GpgME {
00065   class ImportResult;
00066   class KeyGenerationResult;
00067 }
00068 
00069 namespace Kleo {
00070   class KeyListJob;
00071   class EncryptJob;
00072   class DecryptJob;
00073   class SignJob;
00074   class VerifyDetachedJob;
00075   class VerifyOpaqueJob;
00076   class KeyGenerationJob;
00077   class ImportJob;
00078   class ExportJob;
00079   class DownloadJob;
00080   class DeleteJob;
00081   class SignEncryptJob;
00082   class DecryptVerifyJob;
00083   class CryptoConfig;
00084   class RefreshKeysJob;
00085 }
00086 
00227 class CryptPlugWrapper;
00435 class StructuringInfoWrapper {
00436 public:
00437   StructuringInfoWrapper( CryptPlugWrapper* wrapper );
00438   ~StructuringInfoWrapper();
00439   void reset();
00440   CryptPlug::StructuringInfo data;
00441 private:
00442   void initMe();
00443   void freeMe();
00444   bool _initDone;
00445   CryptPlugWrapper* _wrapper;
00446 };
00447 
00448 
00449 
00453 class CryptPlugWrapper : public Kleo::CryptoBackend::Protocol {
00454 public:
00455     static QString errorIdToText( int errId, bool & isPassphraseError );
00456 
00467     typedef enum {
00468         InitStatus_undef         = 0,
00469 
00470         InitStatus_Ok            = 1,
00471         InitStatus_NoLibName     = 2,
00472         InitStatus_LoadError     = 0x1000,
00473         InitStatus_InitError     = 0x2000
00474     } InitStatus;
00475 
00501     enum {
00502         SigStatus_UNKNOWN     = 0x0000,
00503         SigStatus_VALID       = SigStat_VALID,
00504         SigStatus_GREEN       = SigStat_GREEN,
00505         SigStatus_RED         = SigStat_RED,
00506         SigStatus_KEY_REVOKED = SigStat_KEY_REVOKED,
00507         SigStatus_KEY_EXPIRED = SigStat_KEY_EXPIRED,
00508         SigStatus_SIG_EXPIRED = SigStat_SIG_EXPIRED,
00509         SigStatus_KEY_MISSING = SigStat_KEY_MISSING,
00510         SigStatus_CRL_MISSING = SigStat_CRL_MISSING,
00511         SigStatus_CRL_TOO_OLD = SigStat_CRL_TOO_OLD,
00512         SigStatus_BAD_POLICY  = SigStat_BAD_POLICY,
00513         SigStatus_SYS_ERROR   = SigStat_SYS_ERROR,
00514 
00515         SigStatus_NUMERICAL_CODE = 0x8000 /* An other error occurred. */
00516     };
00517     typedef unsigned long SigStatusFlags;
00518 
00519 
00520     enum {
00521         CertStatus_EXPIRES_NEVER = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE
00522     };
00523 
00524 
00551     CryptPlugWrapper( const QString& name=QString::null,
00552                       const QString& libName=QString::null,
00553                       const QString& update=QString::null,
00554                       bool           active = false );
00555 
00565     ~CryptPlugWrapper();
00566 
00567     QString protocol() const;
00568 
00569     QString name() const {
00570       return protocol();
00571     }
00572 
00598     void setActive( bool active );
00599 
00607     bool active() const;
00608 
00609 
00634     bool setLibName( const QString& libName );
00635 
00644     QString libName() const;
00645 
00646 
00651     void setDisplayName( const QString& name );
00652 
00653 
00658     QString displayName() const;
00659 
00660 
00668     QString libVersion() const;
00669 
00674     QString updateURL() const;
00675 
00679     void setUpdateURL( const QString& url );
00680 
00681 private:
00699     bool initialize( InitStatus* initStatus, QString* errorMsg );
00700 
00701 public:
00714     void deinitialize();
00715 
00728     InitStatus initStatus( QString* errorMsg ) const;
00729 
00730 
00745     bool hasFeature( Feature );
00746 
00747 
00759     const char* bugURL();
00760 
00761 
00765     void setSignatureAlgorithm( SignatureAlgorithm );
00766 
00770     SignatureAlgorithm signatureAlgorithm();
00771 
00776     void setWarnSendUnsigned( bool );
00777 
00778 
00783     bool warnSendUnsigned();
00784 
00785 
00790     void setSignatureCertificateExpiryNearWarning( bool );
00791 
00796     bool signatureCertificateExpiryNearWarning( void );
00797 
00803     void setSignatureCertificateExpiryNearInterval( int );
00804 
00810     int signatureCertificateExpiryNearInterval( void );
00811 
00816     void setCACertificateExpiryNearWarning( bool );
00817 
00822     bool caCertificateExpiryNearWarning( void );
00823 
00829     void setCACertificateExpiryNearInterval( int );
00830 
00836     int caCertificateExpiryNearInterval( void );
00837 
00842     void setRootCertificateExpiryNearWarning( bool );
00843 
00848     bool rootCertificateExpiryNearWarning( void );
00849 
00855     void setRootCertificateExpiryNearInterval( int );
00856 
00862     int rootCertificateExpiryNearInterval( void );
00863 
00864 
00868     void setEncryptionAlgorithm( EncryptionAlgorithm );
00869 
00873     EncryptionAlgorithm encryptionAlgorithm();
00874 
00880     void setEncryptEmail( EncryptEmail );
00881 
00887     EncryptEmail encryptEmail();
00888 
00893     void setWarnSendUnencrypted( bool );
00894 
00899     bool warnSendUnencrypted();
00900 
00906     void setAlwaysEncryptToSelf( bool ) KDE_DEPRECATED;
00907 
00913     bool alwaysEncryptToSelf() KDE_DEPRECATED;
00914 
00915 
00920     void setSaveMessagesEncrypted( bool );
00921 
00926     bool saveMessagesEncrypted();
00927 
00932     void setCheckCertificatePath( bool );
00933 
00938     bool checkCertificatePath();
00939 
00940 
00945     void setReceiverCertificateExpiryNearWarning( bool );
00946 
00951     bool receiverCertificateExpiryNearWarning();
00952 
00957     void setReceiverCertificateExpiryNearWarningInterval( int );
00958 
00963     int receiverCertificateExpiryNearWarningInterval();
00964 
00965 
00970     void setCertificateInChainExpiryNearWarning( bool );
00971 
00976     bool certificateInChainExpiryNearWarning();
00977 
00982     void setCertificateInChainExpiryNearWarningInterval( int );
00983 
00988     int certificateInChainExpiryNearWarningInterval();
00989 
00990 
00995     void setReceiverEmailAddressNotInCertificateWarning( bool );
00996 
01001     bool receiverEmailAddressNotInCertificateWarning();
01002 
01003 
01008     void setEncryptionUseCRLs( bool );
01009 
01014     bool encryptionUseCRLs();
01015 
01021     void setEncryptionCRLExpiryNearWarning( bool );
01022 
01028     bool encryptionCRLExpiryNearWarning();
01029 
01035     void setEncryptionCRLNearExpiryInterval( int );
01036 
01042     int encryptionCRLNearExpiryInterval();
01043 
01044 
01049     void setCertificateSource( CertificateSource );
01050 
01055     CertificateSource certificateSource();
01056 
01057 
01094     bool signMessage( const char* cleartext,
01095                       char** ciphertext,
01096                       const size_t* cipherLen,
01097                       const char* certificate,
01098                       StructuringInfoWrapper& structuring,
01099                       int* errId,
01100                       char** errTxt );
01101 
01102 
01103     /* \ingroup groupSignAct
01104      * Frees the members of a signature meta data struct, but not the
01105      * signature meta data struct itself as this could be allocated on
01106      * the stack.
01107      */
01108     void freeSignatureMetaData( CryptPlug::SignatureMetaData* );
01109 
01110 
01132     bool checkMessageSignature( char** cleartext,
01133                                 const char* signaturetext,
01134                                 bool signatureIsBinary,
01135                                 int signatureLen,
01136                                 CryptPlug::SignatureMetaData* sigmeta );
01137 
01142     bool storeCertificatesFromMessage( const char* ciphertext );
01143 
01144 
01153     bool findCertificates( const char* addressee,
01154                         char** certificates,
01155                         int* newSize,
01156                         bool secretOnly );
01157 
01193     bool encryptMessage( const char*  cleartext,
01194                          const char** ciphertext,
01195                          const size_t* cipherLen,
01196                          const char*  addressee,
01197                          StructuringInfoWrapper& structuring,
01198                          int* errId,
01199                          char** errTxt );
01200 
01232     bool encryptAndSignMessage( const char* cleartext,
01233                                 const char** ciphertext,
01234                                 const char* certificate,
01235                                 StructuringInfoWrapper& structuring );
01236 
01247     bool decryptMessage( const char* ciphertext,
01248                          bool        cipherIsBinary,
01249                          int         cipherLen,
01250                          char**      cleartext,
01251                          const char* certificate,
01252                          int* errId,
01253                          char** errTxt );
01254 
01267     bool decryptAndCheckMessage( const char*  ciphertext,
01268                                  bool         cipherIsBinary,
01269                                  int          cipherLen,
01270                                  char**       cleartext,
01271                                  const char*  certificate,
01272                                  bool*        signatureFound,
01273                                  CryptPlug::SignatureMetaData* sigmeta,
01274                                  int*   errId,
01275                                  char** errTxt );
01276 
01277 
01278     struct CertificateInfo {
01279       QStringList userid;
01280       QString userid_0_org;
01281       QString serial;
01282       QString fingerprint;
01283 
01284       QString issuer_org;
01285       QString issuer_reord;
01286       QString chainid;
01287 
01288       QDateTime created;
01289       QDateTime expire;
01290 
01291       bool secret   : 1;
01292       bool invalid  : 1;
01293       bool expired  : 1;
01294       bool disabled : 1;
01295 
01296       bool sign     : 1;
01297       bool encrypt  : 1;
01298       bool certify  : 1;
01299 
01300       QValueList< QPair<QString,QString> > dn;
01301     };
01302 
01303     typedef QValueList<CryptPlugWrapper::CertificateInfo> CertificateInfoList;
01304 
01305     CertificateInfoList listKeys(const QString& pattern = QString::null,
01306                                  bool remote = false,
01307                                  bool *truncated = 0 );
01308 
01309     Kleo::KeyListJob * keyListJob( bool remote=false, bool includeSigs=false, bool validate=true ) const;
01310     Kleo::EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const;
01311     Kleo::DecryptJob * decryptJob() const;
01312     Kleo::SignJob * signJob( bool armor=false, bool textMode=false ) const;
01313     Kleo::VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const;
01314     Kleo::VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const;
01315     Kleo::KeyGenerationJob * keyGenerationJob() const;
01316 
01317     Kleo::ImportJob * importJob() const;
01318     Kleo::ExportJob * publicKeyExportJob( bool armor=false ) const;
01319     Kleo::ExportJob * secretKeyExportJob( bool armor=false ) const;
01320     Kleo::DownloadJob * downloadJob( bool armor=false ) const;
01321     Kleo::DeleteJob * deleteJob() const;
01322 
01323     Kleo::SignEncryptJob * signEncryptJob( bool armor=false, bool textmode=false ) const;
01324     Kleo::DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const;
01325     Kleo::RefreshKeysJob * refreshKeysJob() const;
01326 
01327     GpgME::ImportResult importCertificate( const char* data, size_t length );
01328 
01329     CryptPlug * cryptPlug() const { return _cp; }
01330 
01331 private:
01332     QString    _name;
01333     QString    _libName;
01334     QString    _updateURL;
01335     bool       _active;
01336     InitStatus _initStatus;
01337     QString    _lastError;
01338     CryptPlug* _cp;
01339     // local parameters without representation in cryptplug.h
01340     bool mAlwaysEncryptToSelf;
01341     class Config;
01342     Config * _config;
01343     QGpgMECryptoConfig * _cryptoConfig;
01344 };
01345 
01346 #endif // !LIBKLEOPATRA_NO_COMPAT
01347 
01348 #endif // cryptplugwrapper_h
KDE Logo
This file is part of the documentation for certmanager/lib Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 04:46:15 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003