# qcaprovider.h

Go to the documentation of this file.

    00001 /*
    00002  * qcaprovider.h - QCA Plugin API
    00003  * Copyright (C) 2003-2007  Justin Karneges <justin@affinix.com>
    00004  * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU Lesser General Public
    00008  * License as published by the Free Software Foundation; either
    00009  * version 2.1 of the License, or (at your option) any later version.
    00010  *
    00011  * This library is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  * Lesser General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU Lesser General Public
    00017  * License along with this library; if not, write to the Free Software
    00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    00019  * 02110-1301  USA
    00020  *
    00021  */
    00022
    00033 #ifndef QCAPROVIDER_H
    00034 #define QCAPROVIDER_H
    00035
    00036 #include "qca_core.h"
    00037 #include "qca_basic.h"
    00038 #include "qca_publickey.h"
    00039 #include "qca_cert.h"
    00040 #include "qca_keystore.h"
    00041 #include "qca_securelayer.h"
    00042 #include "qca_securemessage.h"
    00043
    00044 #include <limits>
    00045
    00046 #ifndef DOXYGEN_NO_PROVIDER_API
    00047
    00082 class QCA_EXPORT QCAPlugin
    00083 {
    00084 public:
    00088         virtual ~QCAPlugin() {}
    00089
    00093         virtual QCA::Provider *createProvider() = 0;
    00094 };
    00095
    00096 Q_DECLARE_INTERFACE(QCAPlugin, "com.affinix.qca.Plugin/1.0")
    00097
    00098 namespace QCA {
    00099
    00110 class QCA_EXPORT InfoContext : public BasicContext
    00111 {
    00112         Q_OBJECT
    00113 public:
    00119         InfoContext(Provider *p) : BasicContext(p, "info") {}
    00120
    00124         virtual QStringList supportedHashTypes() const;
    00125
    00129         virtual QStringList supportedCipherTypes() const;
    00130
    00134         virtual QStringList supportedMACTypes() const;
    00135 };
    00136
    00147 class QCA_EXPORT RandomContext : public BasicContext
    00148 {
    00149         Q_OBJECT
    00150 public:
    00156         RandomContext(Provider *p) : BasicContext(p, "random") {}
    00157
    00163         virtual SecureArray nextBytes(int size) = 0;
    00164 };
    00165
    00176 class QCA_EXPORT HashContext : public BasicContext
    00177 {
    00178         Q_OBJECT
    00179 public:
    00186         HashContext(Provider *p, const QString &type) : BasicContext(p, type) {}
    00187
    00191         virtual void clear() = 0;
    00192
    00198         virtual void update(const MemoryRegion &a) = 0;
    00199
    00203         virtual MemoryRegion final() = 0;
    00204 };
    00205
    00216 class QCA_EXPORT CipherContext : public BasicContext
    00217 {
    00218         Q_OBJECT
    00219 public:
    00229         CipherContext(Provider *p, const QString &type) : BasicContext(p, type) {}
    00230
    00238         virtual void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv) = 0;
    00239
    00243         virtual KeyLength keyLength() const = 0;
    00244
    00248         virtual int blockSize() const = 0;
    00249
    00256         virtual bool update(const SecureArray &in, SecureArray *out) = 0;
    00257
    00263         virtual bool final(SecureArray *out) = 0;
    00264 };
    00265
    00277 class QCA_EXPORT MACContext : public BasicContext
    00278 {
    00279         Q_OBJECT
    00280 public:
    00286         MACContext(Provider *p, const QString &type) : BasicContext(p, type) {}
    00287
    00293         virtual void setup(const SymmetricKey &key) = 0;
    00294
    00298         virtual KeyLength keyLength() const = 0;
    00299
    00305         virtual void update(const MemoryRegion &in) = 0;
    00306
    00312         virtual void final(MemoryRegion *out) = 0;
    00313
    00314 protected:
    00318         KeyLength anyKeyLength() const
    00319         {
    00320                 // this is used instead of a default implementation to make sure that
    00321                 // provider authors think about it, at least a bit.
    00322                 // See Meyers, Effective C++, Effective C++ (2nd Ed), Item 36
    00323                 return KeyLength( 0, INT_MAX, 1 );
    00324         }
    00325 };
    00326
    00338 class QCA_EXPORT KDFContext : public BasicContext
    00339 {
    00340         Q_OBJECT
    00341 public:
    00348         KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}
    00349
    00358         virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
    00359 };
    00360
    00371 class QCA_EXPORT DLGroupContext : public Provider::Context
    00372 {
    00373         Q_OBJECT
    00374 public:
    00380         DLGroupContext(Provider *p) : Provider::Context(p, "dlgroup") {}
    00381
    00385         virtual QList<DLGroupSet> supportedGroupSets() const = 0;
    00386
    00390         virtual bool isNull() const = 0;
    00391
    00405         virtual void fetchGroup(DLGroupSet set, bool block) = 0;
    00406
    00415         virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;
    00416
    00417 Q_SIGNALS:
    00422         void finished();
    00423 };
    00424
    00436 class QCA_EXPORT PKeyBase : public BasicContext
    00437 {
    00438         Q_OBJECT
    00439 public:
    00446         PKeyBase(Provider *p, const QString &type);
    00447
    00453         virtual bool isNull() const = 0;
    00454
    00458         virtual PKey::Type type() const = 0;
    00459
    00463         virtual bool isPrivate() const = 0;
    00464
    00470         virtual bool canExport() const = 0;
    00471
    00478         virtual void convertToPublic() = 0;
    00479
    00483         virtual int bits() const = 0;
    00484
    00491         virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;
    00492
    00499         virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);
    00500
    00509         virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
    00510
    00517         virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);
    00518
    00525         virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);
    00526
    00533         virtual void update(const MemoryRegion &in);
    00534
    00540         virtual QByteArray endSign();
    00541
    00549         virtual bool endVerify(const QByteArray &sig);
    00550
    00559         virtual SymmetricKey deriveKey(const PKeyBase &theirs);
    00560
    00561 Q_SIGNALS:
    00566         void finished();
    00567 };
    00568
    00580 class QCA_EXPORT RSAContext : public PKeyBase
    00581 {
    00582         Q_OBJECT
    00583 public:
    00589         RSAContext(Provider *p) : PKeyBase(p, "rsa") {}
    00590
    00605         virtual void createPrivate(int bits, int exp, bool block) = 0;
    00606
    00616         virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;
    00617
    00624         virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;
    00625
    00629         virtual BigInteger n() const = 0;
    00630
    00634         virtual BigInteger e() const = 0;
    00635
    00639         virtual BigInteger p() const = 0;
    00640
    00644         virtual BigInteger q() const = 0;
    00645
    00649         virtual BigInteger d() const = 0;
    00650 };
    00651
    00663 class QCA_EXPORT DSAContext : public PKeyBase
    00664 {
    00665         Q_OBJECT
    00666 public:
    00672         DSAContext(Provider *p) : PKeyBase(p, "dsa") {}
    00673
    00687         virtual void createPrivate(const DLGroup &domain, bool block) = 0;
    00688
    00696         virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
    00697
    00704         virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
    00705
    00709         virtual DLGroup domain() const = 0;
    00710
    00714         virtual BigInteger y() const = 0;
    00715
    00719         virtual BigInteger x() const = 0;
    00720 };
    00721
    00733 class QCA_EXPORT DHContext : public PKeyBase
    00734 {
    00735         Q_OBJECT
    00736 public:
    00742         DHContext(Provider *p) : PKeyBase(p, "dh") {}
    00743
    00757         virtual void createPrivate(const DLGroup &domain, bool block) = 0;
    00758
    00767         virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
    00768
    00776         virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
    00777
    00781         virtual DLGroup domain() const = 0;
    00782
    00786         virtual BigInteger y() const = 0;
    00787
    00791         virtual BigInteger x() const = 0;
    00792 };
    00793
    00809 class QCA_EXPORT PKeyContext : public BasicContext
    00810 {
    00811         Q_OBJECT
    00812 public:
    00818         PKeyContext(Provider *p) : BasicContext(p, "pkey") {}
    00819
    00823         virtual QList<PKey::Type> supportedTypes() const = 0;
    00824
    00829         virtual QList<PKey::Type> supportedIOTypes() const = 0;
    00830
    00835         virtual QList<PBEAlgorithm> supportedPBEAlgorithms() const = 0;
    00836
    00840         virtual PKeyBase *key() = 0;
    00841
    00845         virtual const PKeyBase *key() const = 0;
    00846
    00854         virtual void setKey(PKeyBase *key) = 0;
    00855
    00867         virtual bool importKey(const PKeyBase *key) = 0;
    00868
    00874         virtual QByteArray publicToDER() const;
    00875
    00881         virtual QString publicToPEM() const;
    00882
    00891         virtual ConvertResult publicFromDER(const QByteArray &a);
    00892
    00901         virtual ConvertResult publicFromPEM(const QString &s);
    00902
    00912         virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;
    00913
    00923         virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;
    00924
    00934         virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);
    00935
    00945         virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
    00946 };
    00947
    00959 class QCA_EXPORT CertBase : public BasicContext
    00960 {
    00961         Q_OBJECT
    00962 public:
    00969         CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}
    00970
    00976         virtual QByteArray toDER() const = 0;
    00977
    00983         virtual QString toPEM() const = 0;
    00984
    00993         virtual ConvertResult fromDER(const QByteArray &a) = 0;
    00994
    01003         virtual ConvertResult fromPEM(const QString &s) = 0;
    01004 };
    01005
    01020 class QCA_EXPORT CertContextProps
    01021 {
    01022 public:
    01028         int version;
    01029
    01035         QDateTime start;
    01036
    01042         QDateTime end;
    01043
    01047         CertificateInfoOrdered subject;
    01048
    01054         CertificateInfoOrdered issuer;
    01055
    01059         Constraints constraints;
    01060
    01064         QStringList policies;
    01065
    01071         QStringList crlLocations;
    01072
    01078         QStringList issuerLocations;
    01079
    01085         QStringList ocspLocations;
    01086
    01092         BigInteger serial;
    01093
    01098         bool isCA;
    01099
    01105         bool isSelfSigned;
    01106
    01110         int pathLimit;
    01111
    01115         QByteArray sig;
    01116
    01120         SignatureAlgorithm sigalgo;
    01121
    01127         QByteArray subjectId;
    01128
    01134         QByteArray issuerId;
    01135
    01141         QString challenge;
    01142
    01148         CertificateRequestFormat format;
    01149 };
    01150
    01163 class QCA_EXPORT CRLContextProps
    01164 {
    01165 public:
    01169         CertificateInfoOrdered issuer;
    01170
    01174         int number;
    01175
    01179         QDateTime thisUpdate;
    01180
    01184         QDateTime nextUpdate;
    01185
    01189         QList<CRLEntry> revoked;
    01190
    01194         QByteArray sig;
    01195
    01199         SignatureAlgorithm sigalgo;
    01200
    01204         QByteArray issuerId;
    01205 };
    01206
    01207 class CRLContext;
    01208
    01219 class QCA_EXPORT CertContext : public CertBase
    01220 {
    01221         Q_OBJECT
    01222 public:
    01228         CertContext(Provider *p) : CertBase(p, "cert") {}
    01229
    01241         virtual bool createSelfSigned(const CertificateOptions &opts, const PKeyContext &priv) = 0;
    01242
    01246         virtual const CertContextProps *props() const = 0;
    01247
    01254         virtual bool compare(const CertContext *other) const = 0;
    01255
    01260         virtual PKeyContext *subjectPublicKey() const = 0;
    01261
    01268         virtual bool isIssuerOf(const CertContext *other) const = 0;
    01269
    01281         virtual Validity validate(const QList<CertContext*> &trusted, const QList<CertContext*> &untrusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
    01282
    01298         virtual Validity validate_chain(const QList<CertContext*> &chain, const QList<CertContext*> &trusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
    01299 };
    01300
    01312 class QCA_EXPORT CSRContext : public CertBase
    01313 {
    01314         Q_OBJECT
    01315 public:
    01321         CSRContext(Provider *p) : CertBase(p, "csr") {}
    01322
    01329         virtual bool canUseFormat(CertificateRequestFormat f) const = 0;
    01330
    01342         virtual bool createRequest(const CertificateOptions &opts, const PKeyContext &priv) = 0;
    01343
    01347         virtual const CertContextProps *props() const = 0;
    01348
    01355         virtual bool compare(const CSRContext *other) const = 0;
    01356
    01361         virtual PKeyContext *subjectPublicKey() const = 0;
    01362
    01369         virtual QString toSPKAC() const = 0;
    01370
    01380         virtual ConvertResult fromSPKAC(const QString &s) = 0;
    01381 };
    01382
    01393 class QCA_EXPORT CRLContext : public CertBase
    01394 {
    01395         Q_OBJECT
    01396 public:
    01402         CRLContext(Provider *p) : CertBase(p, "crl") {}
    01403
    01407         virtual const CRLContextProps *props() const = 0;
    01408
    01414         virtual bool compare(const CRLContext *other) const = 0;
    01415 };
    01416
    01428 class QCA_EXPORT CertCollectionContext : public BasicContext
    01429 {
    01430         Q_OBJECT
    01431 public:
    01437         CertCollectionContext(Provider *p) : BasicContext(p, "certcollection") {}
    01438
    01447         virtual QByteArray toPKCS7(const QList<CertContext*> &certs, const QList<CRLContext*> &crls) const = 0;
    01448
    01462         virtual ConvertResult fromPKCS7(const QByteArray &a, QList<CertContext*> *certs, QList<CRLContext*> *crls) const = 0;
    01463 };
    01464
    01476 class QCA_EXPORT CAContext : public BasicContext
    01477 {
    01478         Q_OBJECT
    01479 public:
    01485         CAContext(Provider *p) : BasicContext(p, "ca") {}
    01486
    01495         virtual void setup(const CertContext &cert, const PKeyContext &priv) = 0;
    01496
    01501         virtual CertContext *certificate() const = 0;
    01502
    01510         virtual CertContext *signRequest(const CSRContext &req, const QDateTime &notValidAfter) const = 0;
    01511
    01519         virtual CertContext *createCertificate(const PKeyContext &pub, const CertificateOptions &opts) const = 0;
    01520
    01529         virtual CRLContext *createCRL(const QDateTime &nextUpdate) const = 0;
    01530
    01540         virtual CRLContext *updateCRL(const CRLContext &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const = 0;
    01541 };
    01542
    01553 class QCA_EXPORT PKCS12Context : public BasicContext
    01554 {
    01555         Q_OBJECT
    01556 public:
    01562         PKCS12Context(Provider *p) : BasicContext(p, "pkcs12") {}
    01563
    01574         virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;
    01575
    01590         virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
    01591 };
    01592
    01605 class QCA_EXPORT PGPKeyContextProps
    01606 {
    01607 public:
    01611         QString keyId;
    01612
    01617         QStringList userIds;
    01618
    01622         bool isSecret;
    01623
    01627         QDateTime creationDate;
    01628
    01632         QDateTime expirationDate;
    01633
    01639         QString fingerprint;
    01640
    01645         bool inKeyring;
    01646
    01651         bool isTrusted;
    01652 };
    01653
    01664 class QCA_EXPORT PGPKeyContext : public BasicContext
    01665 {
    01666         Q_OBJECT
    01667 public:
    01673         PGPKeyContext(Provider *p) : BasicContext(p, "pgpkey") {}
    01674
    01678         virtual const PGPKeyContextProps *props() const = 0;
    01679
    01683         virtual QByteArray toBinary() const = 0;
    01684
    01688         virtual QString toAscii() const = 0;
    01689
    01698         virtual ConvertResult fromBinary(const QByteArray &a) = 0;
    01699
    01708         virtual ConvertResult fromAscii(const QString &s) = 0;
    01709 };
    01710
    01722 class QCA_EXPORT KeyStoreEntryContext : public BasicContext
    01723 {
    01724         Q_OBJECT
    01725 public:
    01731         KeyStoreEntryContext(Provider *p) : BasicContext(p, "keystoreentry") {}
    01732
    01736         virtual KeyStoreEntry::Type type() const = 0;
    01737
    01743         virtual QString id() const = 0;
    01744
    01748         virtual QString name() const = 0;
    01749
    01753         virtual QString storeId() const = 0;
    01754
    01758         virtual QString storeName() const = 0;
    01759
    01763         virtual bool isAvailable() const;
    01764
    01773         virtual QString serialize() const = 0;
    01774
    01779         virtual KeyBundle keyBundle() const;
    01780
    01785         virtual Certificate certificate() const;
    01786
    01791         virtual CRL crl() const;
    01792
    01797         virtual PGPKey pgpSecretKey() const;
    01798
    01804         virtual PGPKey pgpPublicKey() const;
    01805
    01814         virtual bool ensureAccess();
    01815 };
    01816
    01827 class QCA_EXPORT KeyStoreListContext : public Provider::Context
    01828 {
    01829         Q_OBJECT
    01830 public:
    01836         KeyStoreListContext(Provider *p) : Provider::Context(p, "keystorelist") {}
    01837
    01841         virtual void start();
    01842
    01851         virtual void setUpdatesEnabled(bool enabled);
    01852
    01862         virtual QList<int> keyStores() = 0;
    01863
    01870         virtual KeyStore::Type type(int id) const = 0;
    01871
    01883         virtual QString storeId(int id) const = 0;
    01884
    01891         virtual QString name(int id) const = 0;
    01892
    01901         virtual bool isReadOnly(int id) const;
    01902
    01912         virtual QList<KeyStoreEntry::Type> entryTypes(int id) const = 0;
    01913
    01922         virtual QList<KeyStoreEntryContext*> entryList(int id) = 0;
    01923
    01933         virtual KeyStoreEntryContext *entry(int id, const QString &entryId);
    01934
    01947         virtual KeyStoreEntryContext *entryPassive(const QString &serialized);
    01948
    01958         virtual QString writeEntry(int id, const KeyBundle &kb);
    01959
    01969         virtual QString writeEntry(int id, const Certificate &cert);
    01970
    01980         virtual QString writeEntry(int id, const CRL &crl);
    01981
    01991         virtual QString writeEntry(int id, const PGPKey &key);
    01992
    02002         virtual bool removeEntry(int id, const QString &entryId);
    02003
    02004 Q_SIGNALS:
    02022         void busyStart();
    02023
    02031         void busyEnd();
    02032
    02037         void updated();
    02038
    02044         void diagnosticText(const QString &str);
    02045
    02052         void storeUpdated(int id);
    02053 };
    02054
    02065 class QCA_EXPORT TLSSessionContext : public BasicContext
    02066 {
    02067         Q_OBJECT
    02068 public:
    02074         TLSSessionContext(Provider *p) : BasicContext(p, "tlssession") {}
    02075 };
    02076
    02087 class QCA_EXPORT TLSContext : public Provider::Context
    02088 {
    02089         Q_OBJECT
    02090 public:
    02100         class SessionInfo
    02101         {
    02102         public:
    02106                 bool isCompressed;
    02107
    02111                 TLS::Version version;
    02112
    02118                 QString cipherSuite;
    02119
    02123                 int cipherBits;
    02124
    02129                 int cipherMaxBits;
    02130
    02135                 TLSSessionContext *id;
    02136         };
    02137
    02141         enum Result
    02142         {
    02143                 Success,
    02144                 Error,
    02145                 Continue
    02146         };
    02147
    02154         TLSContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
    02155
    02159         virtual void reset() = 0;
    02160
    02168         virtual QStringList supportedCipherSuites(const TLS::Version &version) const = 0;
    02169
    02173         virtual bool canCompress() const = 0;
    02174
    02178         virtual bool canSetHostName() const = 0;
    02179
    02183         virtual int maxSSF() const = 0;
    02184
    02195         virtual void setup(bool serverMode, const QString &hostName, bool compress) = 0;
    02196
    02205         virtual void setConstraints(int minSSF, int maxSSF) = 0;
    02206
    02219         virtual void setConstraints(const QStringList &cipherSuiteList) = 0;
    02220
    02228         virtual void setTrustedCertificates(const CertificateCollection &trusted) = 0;
    02229
    02239         virtual void setIssuerList(const QList<CertificateInfoOrdered> &issuerList) = 0;
    02240
    02249         virtual void setCertificate(const CertificateChain &cert, const PrivateKey &key) = 0;
    02250
    02258         virtual void setSessionId(const TLSSessionContext &id) = 0;
    02259
    02268         virtual void shutdown() = 0;
    02269
    02277         virtual void setMTU(int size);
    02278
    02291         virtual void start() = 0;
    02292
    02318         virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
    02319
    02329         virtual bool waitForResultsReady(int msecs) = 0;
    02330
    02334         virtual Result result() const = 0;
    02335
    02339         virtual QByteArray to_net() = 0;
    02340
    02345         virtual int encoded() const = 0;
    02346
    02351         virtual QByteArray to_app() = 0;
    02352
    02356         virtual bool eof() const = 0;
    02357
    02364         virtual bool clientHelloReceived() const = 0;
    02365
    02371         virtual bool serverHelloReceived() const = 0;
    02372
    02379         virtual QString hostName() const = 0;
    02380
    02386         virtual bool certificateRequested() const = 0;
    02387
    02393         virtual QList<CertificateInfoOrdered> issuerList() const = 0;
    02394
    02400         virtual Validity peerCertificateValidity() const = 0;
    02401
    02407         virtual CertificateChain peerCertificateChain() const = 0;
    02408
    02414         virtual SessionInfo sessionInfo() const = 0;
    02415
    02421         virtual QByteArray unprocessed() = 0;
    02422
    02423 Q_SIGNALS:
    02427         void resultsReady();
    02428
    02433         void dtlsTimeout();
    02434 };
    02435
    02446 class QCA_EXPORT SASLContext : public Provider::Context
    02447 {
    02448         Q_OBJECT
    02449 public:
    02459         class HostPort
    02460         {
    02461         public:
    02465                 QString addr;
    02466
    02470                 quint16 port;
    02471         };
    02472
    02476         enum Result
    02477         {
    02478                 Success,
    02479                 Error,
    02480                 Params,
    02481                 AuthCheck,
    02482                 Continue
    02483         };
    02484
    02490         SASLContext(Provider *p) : Provider::Context(p, "sasl") {}
    02491
    02495         virtual void reset() = 0;
    02496
    02518         virtual void setup(const QString &service, const QString &host, const HostPort *local, const HostPort *remote, const QString &ext_id, int ext_ssf) = 0;
    02519
    02530         virtual void setConstraints(SASL::AuthFlags f, int minSSF, int maxSSF) = 0;
    02531
    02547         virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) = 0;
    02548
    02564         virtual void startServer(const QString &realm, bool disableServerSendLast) = 0;
    02565
    02579         virtual void serverFirstStep(const QString &mech, const QByteArray *clientInit) = 0;
    02580
    02592         virtual void nextStep(const QByteArray &from_net) = 0;
    02593
    02603         virtual void tryAgain() = 0;
    02604
    02617         virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
    02618
    02629         virtual bool waitForResultsReady(int msecs) = 0;
    02630
    02634         virtual Result result() const = 0;
    02635
    02639         virtual QStringList mechlist() const = 0;
    02640
    02644         virtual QString mech() const = 0;
    02645
    02649         virtual bool haveClientInit() const = 0;
    02650
    02655         virtual QByteArray stepData() const = 0;
    02656
    02661         virtual QByteArray to_net() = 0;
    02662
    02667         virtual int encoded() const = 0;
    02668
    02673         virtual QByteArray to_app() = 0;
    02674
    02680         virtual int ssf() const = 0;
    02681
    02688         virtual SASL::AuthCondition authCondition() const = 0;
    02689
    02695         virtual SASL::Params clientParams() const = 0;
    02696
    02705         virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;
    02706
    02713         virtual QStringList realmlist() const = 0;
    02714
    02720         virtual QString username() const = 0;
    02721
    02727         virtual QString authzid() const = 0;
    02728
    02729 Q_SIGNALS:
    02734         void resultsReady();
    02735 };
    02736
    02748 class QCA_EXPORT MessageContext : public Provider::Context
    02749 {
    02750         Q_OBJECT
    02751 public:
    02755         enum Operation
    02756         {
    02757                 Encrypt,
    02758                 Decrypt,
    02759                 Sign,
    02760                 Verify,
    02761                 SignAndEncrypt
    02762         };
    02763
    02770         MessageContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
    02771
    02776         virtual bool canSignMultiple() const = 0;
    02777
    02781         virtual SecureMessage::Type type() const = 0;
    02782
    02786         virtual void reset() = 0;
    02787
    02793         virtual void setupEncrypt(const SecureMessageKeyList &keys) = 0;
    02794
    02803         virtual void setupSign(const SecureMessageKeyList &keys, SecureMessage::SignMode m, bool bundleSigner, bool smime) = 0;
    02804
    02810         virtual void setupVerify(const QByteArray &detachedSig) = 0;
    02811
    02825         virtual void start(SecureMessage::Format f, Operation op) = 0;
    02826
    02832         virtual void update(const QByteArray &in) = 0;
    02833
    02837         virtual QByteArray read() = 0;
    02838
    02843         virtual int written() = 0;
    02844
    02848         virtual void end() = 0;
    02849
    02853         virtual bool finished() const = 0;
    02854
    02864         virtual bool waitForFinished(int msecs) = 0;
    02865
    02871         virtual bool success() const = 0;
    02872
    02879         virtual SecureMessage::Error errorCode() const = 0;
    02880
    02887         virtual QByteArray signature() const = 0;
    02888
    02895         virtual QString hashName() const = 0;
    02896
    02903         virtual SecureMessageSignatureList signers() const = 0;
    02904
    02912         virtual QString diagnosticText() const;
    02913
    02914 Q_SIGNALS:
    02919         void updated();
    02920 };
    02921
    02933 class QCA_EXPORT SMSContext : public BasicContext
    02934 {
    02935         Q_OBJECT
    02936 public:
    02943         SMSContext(Provider *p, const QString &type) : BasicContext(p, type) {}
    02944
    02955         virtual void setTrustedCertificates(const CertificateCollection &trusted);
    02956
    02965         virtual void setUntrustedCertificates(const CertificateCollection &untrusted);
    02966
    02975         virtual void setPrivateKeys(const QList<SecureMessageKey> &keys);
    02976
    02981         virtual MessageContext *createMessage() = 0;
    02982 };
    02983
    02984 }
    02985 #endif
    02986
    02987 #endif