certmanager/lib

cryptplugwrapper.h
Go to the documentation of this file.
1 
29 #ifndef cryptplugwrapper_h
30 #define cryptplugwrapper_h
31 
32 #include "cryptplug.h"
33 
34 #ifndef LIBKLEOPATRA_NO_COMPAT
35 
36 /*
37  *
38  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
39  * *
40  * This file's source comments are optimized for processing by Doxygen. *
41  * *
42  * To obtain best results please get an updated version of Doxygen, *
43  * for sources and binaries goto http://www.doxygen.org/index.html *
44  * *
45  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
46 
47  *
48  */
49 #include "kleo/cryptobackend.h"
50 
51 #include <tqdatetime.h>
52 
53 #include <tqvaluelist.h>
54 #include <tqpair.h>
55 #include <tqstringlist.h>
56 #include <tqstring.h>
57 #include <kdemacros.h>
58 
59 
60 class TDEConfigBase;
61 class QGpgMECryptoConfig;
62 
63 namespace GpgME {
64  class ImportResult;
65  class KeyGenerationResult;
66 }
67 
68 namespace Kleo {
69  class KeyListJob;
70  class EncryptJob;
71  class DecryptJob;
72  class SignJob;
73  class VerifyDetachedJob;
74  class VerifyOpaqueJob;
75  class KeyGenerationJob;
76  class ImportJob;
77  class ExportJob;
78  class DownloadJob;
79  class DeleteJob;
80  class SignEncryptJob;
81  class DecryptVerifyJob;
82  class CryptoConfig;
83  class RefreshKeysJob;
84  class SpecialJob;
85 }
86 
227 class CryptPlugWrapper;
436 public:
439  void reset();
441 private:
442  void initMe();
443  void freeMe();
444  bool _initDone;
445  CryptPlugWrapper* _wrapper;
446 };
447 
448 
449 
453 class TDE_EXPORT CryptPlugWrapper : public Kleo::CryptoBackend::Protocol {
454 public:
455  static TQString errorIdToText( int errId, bool & isPassphraseError );
456 
467  typedef enum {
468  IniStatus_undef = 0,
469 
470  IniStatus_Ok = 1,
471  IniStatus_NoLibName = 2,
472  IniStatus_LoadError = 0x1000,
473  IniStatus_InitError = 0x2000
474  } IniStatus;
475 
501  enum {
502  SigStatus_UNKNOWN = 0x0000,
503  SigStatus_VALID = SigStat_VALID,
504  SigStatus_GREEN = SigStat_GREEN,
505  SigStatus_RED = SigStat_RED,
506  SigStatus_KEY_REVOKED = SigStat_KEY_REVOKED,
507  SigStatus_KEY_EXPIRED = SigStat_KEY_EXPIRED,
508  SigStatus_SIG_EXPIRED = SigStat_SIG_EXPIRED,
509  SigStatus_KEY_MISSING = SigStat_KEY_MISSING,
510  SigStatus_CRL_MISSING = SigStat_CRL_MISSING,
511  SigStatus_CRL_TOO_OLD = SigStat_CRL_TOO_OLD,
512  SigStatus_BAD_POLICY = SigStat_BAD_POLICY,
513  SigStatus_SYS_ERROR = SigStat_SYS_ERROR,
514 
515  SigStatus_NUMERICAL_CODE = 0x8000 /* An other error occurred. */
516  };
517  typedef unsigned long SigStatusFlags;
518 
519 
520  enum {
521  CerStatus_EXPIRES_NEVER = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE
522  };
523 
524 
548  CryptPlugWrapper( const TQString& name=TQString(),
549  const TQString& libName=TQString(),
550  const TQString& update=TQString(),
551  bool active = false );
552 
562  ~CryptPlugWrapper();
563 
564  TQString protocol() const;
565 
566  TQString name() const {
567  return protocol();
568  }
569 
595  void setActive( bool active );
596 
604  bool active() const;
605 
606 
631  bool setLibName( const TQString& libName );
632 
641  TQString libName() const;
642 
643 
648  void setDisplayName( const TQString& name );
649 
650 
655  TQString displayName() const;
656 
657 private:
675  bool initialize( IniStatus* iniStatus, TQString* errorMsg );
676 
677 public:
690  void deinitialize();
691 
704  IniStatus iniStatus( TQString* errorMsg ) const;
705 
706 
721  bool hasFeature( ::Feature );
722 
723 
724  /* \ingroup groupSignAct
725  * Frees the members of a signature meta data struct, but not the
726  * signature meta data struct itself as this could be allocated on
727  * the stack.
728  */
729  void freeSignatureMetaData( CryptPlug::SignatureMetaData* );
730 
752  bool checkMessageSignature( char** cleartext,
753  const char* signaturetext,
754  bool signatureIsBinary,
755  int signatureLen,
756  CryptPlug::SignatureMetaData* sigmeta );
757 
768  bool decryptMessage( const char* ciphertext,
769  bool cipherIsBinary,
770  int cipherLen,
771  char** cleartext,
772  const char* certificate,
773  int* errId,
774  char** errTxt );
775 
788  bool decryptAndCheckMessage( const char* ciphertext,
789  bool cipherIsBinary,
790  int cipherLen,
791  char** cleartext,
792  const char* certificate,
793  bool* signatureFound,
794  CryptPlug::SignatureMetaData* sigmeta,
795  int* errId,
796  char** errTxt );
797 
798  Kleo::KeyListJob * keyListJob( bool remote=false, bool includeSigs=false, bool validate=true ) const;
799  Kleo::EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const;
800  Kleo::DecryptJob * decryptJob() const;
801  Kleo::SignJob * signJob( bool armor=false, bool textMode=false ) const;
802  Kleo::VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const;
803  Kleo::VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const;
804  Kleo::KeyGenerationJob * keyGenerationJob() const;
805 
806  Kleo::ImportJob * importJob() const;
807  Kleo::ExportJob * publicKeyExportJob( bool armor=false ) const;
808  Kleo::ExportJob * secretKeyExportJob( bool armor=false, const TQString& charset = TQString() ) const;
809  Kleo::DownloadJob * downloadJob( bool armor=false ) const;
810  Kleo::DeleteJob * deleteJob() const;
811 
812  Kleo::SignEncryptJob * signEncryptJob( bool armor=false, bool textmode=false ) const;
813  Kleo::DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const;
814  Kleo::RefreshKeysJob * refreshKeysJob() const;
815 
816  Kleo::SpecialJob * specialJob( const char *, const TQStringVariantMap & ) const { return 0; }
817 
818  GpgME::ImportResult importCertificate( const char* data, size_t length );
819 
820  CryptPlug * cryptPlug() const { return _cp; }
821 
822 private:
823  TQString _name;
824  TQString _libName;
825  TQString _updateURL;
826  bool _active;
827  IniStatus _iniStatus;
828  TQString _lastError;
829  CryptPlug* _cp;
830  // local parameters without representation in cryptplug.h
831  bool mAlwaysEncryptToSelf;
832  class Config;
833  Config * _config;
834  QGpgMECryptoConfig * _cryptoConfig;
835 };
836 
837 #endif // !LIBKLEOPATRA_NO_COMPAT
838 
839 #endif // cryptplugwrapper_h
This class provides C++ access to the CRYPTPLUG API.
An abstract base class for asynchronous decrypters.
Definition: decryptjob.h:62
An abstract base class for asynchronous combined decrypters and verifiers.
An abstract base class for asynchronous deleters.
Definition: deletejob.h:58
An abstract base class for asynchronous downloaders.
Definition: downloadjob.h:61
An abstract base class for asynchronous encrypters.
Definition: encryptjob.h:64
An abstract base class for asynchronous exporters.
Definition: exportjob.h:61
An abstract base class for asynchronous importers.
Definition: importjob.h:62
An abstract base class for asynchronous key generation.
An abstract base class for asynchronous key listers.
Definition: keylistjob.h:65
An abstract base class for asynchronous key refreshers.
An abstract base class for asynchronous combined signing and encrypting.
An abstract base class for asynchronous signing.
Definition: signjob.h:65
An abstract base class for protocol-specific jobs.
Definition: specialjob.h:65
An abstract base class for asynchronous verification of detached signatures.
An abstract base class for asynchronous verification of opaque signatures.
CryptoConfig implementation around the gpgconf command-line tool For method docu, see kleo/cryptoconf...
This class provides C++ access to the StructuringInfo helper struct that is specified in cryptplug....
Common API header for CRYPTPLUG.
Information record returned by signing and by encrypting functions - this record should be used toget...
Definition: cryptplug.h:621