Qt Cryptographic Architecture
qcaprovider.h
Go to the documentation of this file.
1 /*
2  * qcaprovider.h - QCA Plugin API
3  * Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
4  * Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  *
21  */
22 
33 #ifndef QCAPROVIDER_H
34 #define QCAPROVIDER_H
35 
36 #include "qca_core.h"
37 #include "qca_basic.h"
38 #include "qca_publickey.h"
39 #include "qca_cert.h"
40 #include "qca_keystore.h"
41 #include "qca_securelayer.h"
42 #include "qca_securemessage.h"
43 
44 #include <limits>
45 
46 #ifndef DOXYGEN_NO_PROVIDER_API
47 
82 class QCA_EXPORT QCAPlugin
83 {
84 public:
88  virtual ~QCAPlugin() {}
89 
93  virtual QCA::Provider *createProvider() = 0;
94 };
95 
96 Q_DECLARE_INTERFACE(QCAPlugin, "com.affinix.qca.Plugin/1.0")
97 
98 namespace QCA {
99 
110 class QCA_EXPORT InfoContext : public BasicContext
111 {
112  Q_OBJECT
113 public:
119  InfoContext(Provider *p) : BasicContext(p, QStringLiteral("info") ) {}
120 
124  virtual QStringList supportedHashTypes() const;
125 
129  virtual QStringList supportedCipherTypes() const;
130 
134  virtual QStringList supportedMACTypes() const;
135 };
136 
147 class QCA_EXPORT RandomContext : public BasicContext
148 {
149  Q_OBJECT
150 public:
156  RandomContext(Provider *p) : BasicContext(p, QStringLiteral("random")) {}
157 
163  virtual SecureArray nextBytes(int size) = 0;
164 };
165 
176 class QCA_EXPORT HashContext : public BasicContext
177 {
178  Q_OBJECT
179 public:
186  HashContext(Provider *p, const QString &type) : BasicContext(p, type) {}
187 
191  virtual void clear() = 0;
192 
198  virtual void update(const MemoryRegion &a) = 0;
199 
203  virtual MemoryRegion final() = 0;
204 };
205 
216 class QCA_EXPORT CipherContext : public BasicContext
217 {
218  Q_OBJECT
219 public:
229  CipherContext(Provider *p, const QString &type) : BasicContext(p, type) {}
230 
239  virtual void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv, const AuthTag &tag) = 0;
240 
244  virtual KeyLength keyLength() const = 0;
245 
249  virtual int blockSize() const = 0;
250 
254  virtual AuthTag tag() const = 0;
255 
262  virtual bool update(const SecureArray &in, SecureArray *out) = 0;
263 
269  virtual bool final(SecureArray *out) = 0;
270 };
271 
283 class QCA_EXPORT MACContext : public BasicContext
284 {
285  Q_OBJECT
286 public:
292  MACContext(Provider *p, const QString &type) : BasicContext(p, type) {}
293 
299  virtual void setup(const SymmetricKey &key) = 0;
300 
304  virtual KeyLength keyLength() const = 0;
305 
311  virtual void update(const MemoryRegion &in) = 0;
312 
318  virtual void final(MemoryRegion *out) = 0;
319 
320 protected:
325  {
326  // this is used instead of a default implementation to make sure that
327  // provider authors think about it, at least a bit.
328  // See Meyers, Effective C++, Effective C++ (2nd Ed), Item 36
329  return KeyLength( 0, INT_MAX, 1 );
330  }
331 };
332 
344 class QCA_EXPORT KDFContext : public BasicContext
345 {
346  Q_OBJECT
347 public:
354  KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}
355 
364  virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
365 
375  virtual SymmetricKey makeKey(const SecureArray &secret,
376  const InitializationVector &salt,
377  unsigned int keyLength,
378  int msecInterval,
379  unsigned int *iterationCount) = 0;
380 };
381 
392 class QCA_EXPORT DLGroupContext : public Provider::Context
393 {
394  Q_OBJECT
395 public:
401  DLGroupContext(Provider *p) : Provider::Context(p, QStringLiteral("dlgroup")) {}
402 
406  virtual QList<DLGroupSet> supportedGroupSets() const = 0;
407 
411  virtual bool isNull() const = 0;
412 
426  virtual void fetchGroup(DLGroupSet set, bool block) = 0;
427 
436  virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;
437 
438 Q_SIGNALS:
443  void finished();
444 };
445 
457 class QCA_EXPORT PKeyBase : public BasicContext
458 {
459  Q_OBJECT
460 public:
467  PKeyBase(Provider *p, const QString &type);
468 
474  virtual bool isNull() const = 0;
475 
479  virtual PKey::Type type() const = 0;
480 
484  virtual bool isPrivate() const = 0;
485 
491  virtual bool canExport() const = 0;
492 
499  virtual void convertToPublic() = 0;
500 
504  virtual int bits() const = 0;
505 
512  virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;
513 
520  virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);
521 
530  virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
531 
538  virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);
539 
546  virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);
547 
554  virtual void update(const MemoryRegion &in);
555 
561  virtual QByteArray endSign();
562 
570  virtual bool endVerify(const QByteArray &sig);
571 
580  virtual SymmetricKey deriveKey(const PKeyBase &theirs);
581 
582 Q_SIGNALS:
587  void finished();
588 };
589 
601 class QCA_EXPORT RSAContext : public PKeyBase
602 {
603  Q_OBJECT
604 public:
610  RSAContext(Provider *p) : PKeyBase(p, QStringLiteral("rsa")) {}
611 
626  virtual void createPrivate(int bits, int exp, bool block) = 0;
627 
637  virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;
638 
645  virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;
646 
650  virtual BigInteger n() const = 0;
651 
655  virtual BigInteger e() const = 0;
656 
660  virtual BigInteger p() const = 0;
661 
665  virtual BigInteger q() const = 0;
666 
670  virtual BigInteger d() const = 0;
671 };
672 
684 class QCA_EXPORT DSAContext : public PKeyBase
685 {
686  Q_OBJECT
687 public:
693  DSAContext(Provider *p) : PKeyBase(p, QStringLiteral("dsa")) {}
694 
708  virtual void createPrivate(const DLGroup &domain, bool block) = 0;
709 
717  virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
718 
725  virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
726 
730  virtual DLGroup domain() const = 0;
731 
735  virtual BigInteger y() const = 0;
736 
740  virtual BigInteger x() const = 0;
741 };
742 
754 class QCA_EXPORT DHContext : public PKeyBase
755 {
756  Q_OBJECT
757 public:
763  DHContext(Provider *p) : PKeyBase(p, QStringLiteral("dh")) {}
764 
778  virtual void createPrivate(const DLGroup &domain, bool block) = 0;
779 
788  virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
789 
797  virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
798 
802  virtual DLGroup domain() const = 0;
803 
807  virtual BigInteger y() const = 0;
808 
812  virtual BigInteger x() const = 0;
813 };
814 
830 class QCA_EXPORT PKeyContext : public BasicContext
831 {
832  Q_OBJECT
833 public:
839  PKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pkey")) {}
840 
844  virtual QList<PKey::Type> supportedTypes() const = 0;
845 
850  virtual QList<PKey::Type> supportedIOTypes() const = 0;
851 
856  virtual QList<PBEAlgorithm> supportedPBEAlgorithms() const = 0;
857 
861  virtual PKeyBase *key() = 0;
862 
866  virtual const PKeyBase *key() const = 0;
867 
875  virtual void setKey(PKeyBase *key) = 0;
876 
888  virtual bool importKey(const PKeyBase *key) = 0;
889 
895  virtual QByteArray publicToDER() const;
896 
902  virtual QString publicToPEM() const;
903 
912  virtual ConvertResult publicFromDER(const QByteArray &a);
913 
922  virtual ConvertResult publicFromPEM(const QString &s);
923 
933  virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;
934 
944  virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;
945 
955  virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);
956 
966  virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
967 };
968 
980 class QCA_EXPORT CertBase : public BasicContext
981 {
982  Q_OBJECT
983 public:
990  CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}
991 
997  virtual QByteArray toDER() const = 0;
998 
1004  virtual QString toPEM() const = 0;
1005 
1014  virtual ConvertResult fromDER(const QByteArray &a) = 0;
1015 
1024  virtual ConvertResult fromPEM(const QString &s) = 0;
1025 };
1026 
1041 class QCA_EXPORT CertContextProps
1042 {
1043 public:
1049  int version;
1050 
1056  QDateTime start;
1057 
1063  QDateTime end;
1064 
1069 
1076 
1081 
1085  QStringList policies;
1086 
1092  QStringList crlLocations;
1093 
1099  QStringList issuerLocations;
1100 
1106  QStringList ocspLocations;
1107 
1114 
1119  bool isCA;
1120 
1127 
1132 
1136  QByteArray sig;
1137 
1142 
1148  QByteArray subjectId;
1149 
1155  QByteArray issuerId;
1156 
1162  QString challenge;
1163 
1170 };
1171 
1184 class QCA_EXPORT CRLContextProps
1185 {
1186 public:
1191 
1195  int number;
1196 
1200  QDateTime thisUpdate;
1201 
1205  QDateTime nextUpdate;
1206 
1211 
1215  QByteArray sig;
1216 
1221 
1225  QByteArray issuerId;
1226 };
1227 
1228 class CRLContext;
1229 
1240 class QCA_EXPORT CertContext : public CertBase
1241 {
1242  Q_OBJECT
1243 public:
1249  CertContext(Provider *p) : CertBase(p, QStringLiteral("cert")) {}
1250 
1262  virtual bool createSelfSigned(const CertificateOptions &opts, const PKeyContext &priv) = 0;
1263 
1267  virtual const CertContextProps *props() const = 0;
1268 
1275  virtual bool compare(const CertContext *other) const = 0;
1276 
1281  virtual PKeyContext *subjectPublicKey() const = 0;
1282 
1289  virtual bool isIssuerOf(const CertContext *other) const = 0;
1290 
1302  virtual Validity validate(const QList<CertContext*> &trusted, const QList<CertContext*> &untrusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
1303 
1319  virtual Validity validate_chain(const QList<CertContext*> &chain, const QList<CertContext*> &trusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
1320 };
1321 
1333 class QCA_EXPORT CSRContext : public CertBase
1334 {
1335  Q_OBJECT
1336 public:
1342  CSRContext(Provider *p) : CertBase(p, QStringLiteral("csr")) {}
1343 
1350  virtual bool canUseFormat(CertificateRequestFormat f) const = 0;
1351 
1363  virtual bool createRequest(const CertificateOptions &opts, const PKeyContext &priv) = 0;
1364 
1368  virtual const CertContextProps *props() const = 0;
1369 
1376  virtual bool compare(const CSRContext *other) const = 0;
1377 
1382  virtual PKeyContext *subjectPublicKey() const = 0;
1383 
1390  virtual QString toSPKAC() const = 0;
1391 
1401  virtual ConvertResult fromSPKAC(const QString &s) = 0;
1402 };
1403 
1414 class QCA_EXPORT CRLContext : public CertBase
1415 {
1416  Q_OBJECT
1417 public:
1423  CRLContext(Provider *p) : CertBase(p, QStringLiteral("crl")) {}
1424 
1428  virtual const CRLContextProps *props() const = 0;
1429 
1435  virtual bool compare(const CRLContext *other) const = 0;
1436 };
1437 
1449 class QCA_EXPORT CertCollectionContext : public BasicContext
1450 {
1451  Q_OBJECT
1452 public:
1458  CertCollectionContext(Provider *p) : BasicContext(p, QStringLiteral("certcollection")) {}
1459 
1468  virtual QByteArray toPKCS7(const QList<CertContext*> &certs, const QList<CRLContext*> &crls) const = 0;
1469 
1483  virtual ConvertResult fromPKCS7(const QByteArray &a, QList<CertContext*> *certs, QList<CRLContext*> *crls) const = 0;
1484 };
1485 
1497 class QCA_EXPORT CAContext : public BasicContext
1498 {
1499  Q_OBJECT
1500 public:
1506  CAContext(Provider *p) : BasicContext(p, QStringLiteral("ca")) {}
1507 
1516  virtual void setup(const CertContext &cert, const PKeyContext &priv) = 0;
1517 
1522  virtual CertContext *certificate() const = 0;
1523 
1531  virtual CertContext *signRequest(const CSRContext &req, const QDateTime &notValidAfter) const = 0;
1532 
1540  virtual CertContext *createCertificate(const PKeyContext &pub, const CertificateOptions &opts) const = 0;
1541 
1550  virtual CRLContext *createCRL(const QDateTime &nextUpdate) const = 0;
1551 
1561  virtual CRLContext *updateCRL(const CRLContext &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const = 0;
1562 };
1563 
1574 class QCA_EXPORT PKCS12Context : public BasicContext
1575 {
1576  Q_OBJECT
1577 public:
1583  PKCS12Context(Provider *p) : BasicContext(p, QStringLiteral("pkcs12")) {}
1584 
1595  virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;
1596 
1611  virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
1612 };
1613 
1626 class QCA_EXPORT PGPKeyContextProps
1627 {
1628 public:
1632  QString keyId;
1633 
1638  QStringList userIds;
1639 
1643  bool isSecret;
1644 
1648  QDateTime creationDate;
1649 
1653  QDateTime expirationDate;
1654 
1660  QString fingerprint;
1661 
1667 
1673 };
1674 
1685 class QCA_EXPORT PGPKeyContext : public BasicContext
1686 {
1687  Q_OBJECT
1688 public:
1694  PGPKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pgpkey")) {}
1695 
1699  virtual const PGPKeyContextProps *props() const = 0;
1700 
1704  virtual QByteArray toBinary() const = 0;
1705 
1709  virtual QString toAscii() const = 0;
1710 
1719  virtual ConvertResult fromBinary(const QByteArray &a) = 0;
1720 
1729  virtual ConvertResult fromAscii(const QString &s) = 0;
1730 };
1731 
1743 class QCA_EXPORT KeyStoreEntryContext : public BasicContext
1744 {
1745  Q_OBJECT
1746 public:
1752  KeyStoreEntryContext(Provider *p) : BasicContext(p, QStringLiteral("keystoreentry")) {}
1753 
1757  virtual KeyStoreEntry::Type type() const = 0;
1758 
1764  virtual QString id() const = 0;
1765 
1769  virtual QString name() const = 0;
1770 
1774  virtual QString storeId() const = 0;
1775 
1779  virtual QString storeName() const = 0;
1780 
1784  virtual bool isAvailable() const;
1785 
1794  virtual QString serialize() const = 0;
1795 
1800  virtual KeyBundle keyBundle() const;
1801 
1806  virtual Certificate certificate() const;
1807 
1812  virtual CRL crl() const;
1813 
1818  virtual PGPKey pgpSecretKey() const;
1819 
1825  virtual PGPKey pgpPublicKey() const;
1826 
1835  virtual bool ensureAccess();
1836 };
1837 
1848 class QCA_EXPORT KeyStoreListContext : public Provider::Context
1849 {
1850  Q_OBJECT
1851 public:
1857  KeyStoreListContext(Provider *p) : Provider::Context(p, QStringLiteral("keystorelist")) {}
1858 
1862  virtual void start();
1863 
1872  virtual void setUpdatesEnabled(bool enabled);
1873 
1883  virtual QList<int> keyStores() = 0;
1884 
1891  virtual KeyStore::Type type(int id) const = 0;
1892 
1904  virtual QString storeId(int id) const = 0;
1905 
1912  virtual QString name(int id) const = 0;
1913 
1922  virtual bool isReadOnly(int id) const;
1923 
1933  virtual QList<KeyStoreEntry::Type> entryTypes(int id) const = 0;
1934 
1943  virtual QList<KeyStoreEntryContext*> entryList(int id) = 0;
1944 
1954  virtual KeyStoreEntryContext *entry(int id, const QString &entryId);
1955 
1968  virtual KeyStoreEntryContext *entryPassive(const QString &serialized);
1969 
1979  virtual QString writeEntry(int id, const KeyBundle &kb);
1980 
1990  virtual QString writeEntry(int id, const Certificate &cert);
1991 
2001  virtual QString writeEntry(int id, const CRL &crl);
2002 
2012  virtual QString writeEntry(int id, const PGPKey &key);
2013 
2023  virtual bool removeEntry(int id, const QString &entryId);
2024 
2025 Q_SIGNALS:
2043  void busyStart();
2044 
2052  void busyEnd();
2053 
2058  void updated();
2059 
2065  void diagnosticText(const QString &str);
2066 
2073  void storeUpdated(int id);
2074 };
2075 
2086 class QCA_EXPORT TLSSessionContext : public BasicContext
2087 {
2088  Q_OBJECT
2089 public:
2095  TLSSessionContext(Provider *p) : BasicContext(p, QStringLiteral("tlssession")) {}
2096 };
2097 
2108 class QCA_EXPORT TLSContext : public Provider::Context
2109 {
2110  Q_OBJECT
2111 public:
2122  {
2123  public:
2128 
2133 
2139  QString cipherSuite;
2140 
2145 
2151 
2157  };
2158 
2162  enum Result
2163  {
2166  Continue
2167  };
2168 
2175  TLSContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
2176 
2180  virtual void reset() = 0;
2181 
2189  virtual QStringList supportedCipherSuites(const TLS::Version &version) const = 0;
2190 
2194  virtual bool canCompress() const = 0;
2195 
2199  virtual bool canSetHostName() const = 0;
2200 
2204  virtual int maxSSF() const = 0;
2205 
2216  virtual void setup(bool serverMode, const QString &hostName, bool compress) = 0;
2217 
2226  virtual void setConstraints(int minSSF, int maxSSF) = 0;
2227 
2240  virtual void setConstraints(const QStringList &cipherSuiteList) = 0;
2241 
2249  virtual void setTrustedCertificates(const CertificateCollection &trusted) = 0;
2250 
2260  virtual void setIssuerList(const QList<CertificateInfoOrdered> &issuerList) = 0;
2261 
2270  virtual void setCertificate(const CertificateChain &cert, const PrivateKey &key) = 0;
2271 
2279  virtual void setSessionId(const TLSSessionContext &id) = 0;
2280 
2289  virtual void shutdown() = 0;
2290 
2298  virtual void setMTU(int size);
2299 
2312  virtual void start() = 0;
2313 
2339  virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
2340 
2350  virtual bool waitForResultsReady(int msecs) = 0;
2351 
2355  virtual Result result() const = 0;
2356 
2360  virtual QByteArray to_net() = 0;
2361 
2366  virtual int encoded() const = 0;
2367 
2372  virtual QByteArray to_app() = 0;
2373 
2377  virtual bool eof() const = 0;
2378 
2385  virtual bool clientHelloReceived() const = 0;
2386 
2392  virtual bool serverHelloReceived() const = 0;
2393 
2400  virtual QString hostName() const = 0;
2401 
2407  virtual bool certificateRequested() const = 0;
2408 
2414  virtual QList<CertificateInfoOrdered> issuerList() const = 0;
2415 
2421  virtual Validity peerCertificateValidity() const = 0;
2422 
2428  virtual CertificateChain peerCertificateChain() const = 0;
2429 
2435  virtual SessionInfo sessionInfo() const = 0;
2436 
2442  virtual QByteArray unprocessed() = 0;
2443 
2444 Q_SIGNALS:
2448  void resultsReady();
2449 
2454  void dtlsTimeout();
2455 };
2456 
2467 class QCA_EXPORT SASLContext : public Provider::Context
2468 {
2469  Q_OBJECT
2470 public:
2480  class HostPort
2481  {
2482  public:
2486  QString addr;
2487 
2491  quint16 port;
2492  };
2493 
2497  enum Result
2498  {
2503  Continue
2504  };
2505 
2511  SASLContext(Provider *p) : Provider::Context(p, QStringLiteral("sasl")) {}
2512 
2516  virtual void reset() = 0;
2517 
2539  virtual void setup(const QString &service, const QString &host, const HostPort *local, const HostPort *remote, const QString &ext_id, int ext_ssf) = 0;
2540 
2551  virtual void setConstraints(SASL::AuthFlags f, int minSSF, int maxSSF) = 0;
2552 
2568  virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) = 0;
2569 
2585  virtual void startServer(const QString &realm, bool disableServerSendLast) = 0;
2586 
2600  virtual void serverFirstStep(const QString &mech, const QByteArray *clientInit) = 0;
2601 
2613  virtual void nextStep(const QByteArray &from_net) = 0;
2614 
2624  virtual void tryAgain() = 0;
2625 
2638  virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
2639 
2650  virtual bool waitForResultsReady(int msecs) = 0;
2651 
2655  virtual Result result() const = 0;
2656 
2660  virtual QStringList mechlist() const = 0;
2661 
2665  virtual QString mech() const = 0;
2666 
2670  virtual bool haveClientInit() const = 0;
2671 
2676  virtual QByteArray stepData() const = 0;
2677 
2682  virtual QByteArray to_net() = 0;
2683 
2688  virtual int encoded() const = 0;
2689 
2694  virtual QByteArray to_app() = 0;
2695 
2701  virtual int ssf() const = 0;
2702 
2709  virtual SASL::AuthCondition authCondition() const = 0;
2710 
2716  virtual SASL::Params clientParams() const = 0;
2717 
2726  virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;
2727 
2734  virtual QStringList realmlist() const = 0;
2735 
2741  virtual QString username() const = 0;
2742 
2748  virtual QString authzid() const = 0;
2749 
2750 Q_SIGNALS:
2755  void resultsReady();
2756 };
2757 
2769 class QCA_EXPORT MessageContext : public Provider::Context
2770 {
2771  Q_OBJECT
2772 public:
2777  {
2782  SignAndEncrypt
2783  };
2784 
2791  MessageContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
2792 
2797  virtual bool canSignMultiple() const = 0;
2798 
2802  virtual SecureMessage::Type type() const = 0;
2803 
2807  virtual void reset() = 0;
2808 
2814  virtual void setupEncrypt(const SecureMessageKeyList &keys) = 0;
2815 
2824  virtual void setupSign(const SecureMessageKeyList &keys, SecureMessage::SignMode m, bool bundleSigner, bool smime) = 0;
2825 
2831  virtual void setupVerify(const QByteArray &detachedSig) = 0;
2832 
2846  virtual void start(SecureMessage::Format f, Operation op) = 0;
2847 
2853  virtual void update(const QByteArray &in) = 0;
2854 
2858  virtual QByteArray read() = 0;
2859 
2864  virtual int written() = 0;
2865 
2869  virtual void end() = 0;
2870 
2874  virtual bool finished() const = 0;
2875 
2885  virtual bool waitForFinished(int msecs) = 0;
2886 
2892  virtual bool success() const = 0;
2893 
2900  virtual SecureMessage::Error errorCode() const = 0;
2901 
2908  virtual QByteArray signature() const = 0;
2909 
2916  virtual QString hashName() const = 0;
2917 
2924  virtual SecureMessageSignatureList signers() const = 0;
2925 
2933  virtual QString diagnosticText() const;
2934 
2935 Q_SIGNALS:
2940  void updated();
2941 };
2942 
2954 class QCA_EXPORT SMSContext : public BasicContext
2955 {
2956  Q_OBJECT
2957 public:
2964  SMSContext(Provider *p, const QString &type) : BasicContext(p, type) {}
2965 
2976  virtual void setTrustedCertificates(const CertificateCollection &trusted);
2977 
2986  virtual void setUntrustedCertificates(const CertificateCollection &untrusted);
2987 
2996  virtual void setPrivateKeys(const QList<SecureMessageKey> &keys);
2997 
3002  virtual MessageContext *createMessage() = 0;
3003 };
3004 
3005 }
3006 #endif
3007 
3008 #endif
ConvertResult
Return value from a format conversion.
Definition: qca_publickey.h:117
X.509 certificate request provider.
Definition: qcaprovider.h:1333
CertificateInfoOrdered issuer
The issuer information of the CRL.
Definition: qcaprovider.h:1190
bool isCompressed
True if the TLS connection is compressed, otherwise false.
Definition: qcaprovider.h:2127
X.509 certificate provider.
Definition: qcaprovider.h:1240
PKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:839
PBEAlgorithm
Password-based encryption.
Definition: qca_publickey.h:101
Version
Version of TLS or SSL.
Definition: qca_securelayer.h:305
Diffie-Hellman provider.
Definition: qcaprovider.h:754
MessageContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2791
Message authentication code provider.
Definition: qcaprovider.h:283
QDateTime end
The time the certificate expires.
Definition: qcaprovider.h:1063
X.509 certificate or certificate request properties.
Definition: qcaprovider.h:1041
Parameter flags for the SASL authentication.
Definition: qca_securelayer.h:914
CSRContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1342
Generic private key.
Definition: qca_publickey.h:826
QString challenge
The SPKAC challenge value.
Definition: qcaprovider.h:1162
CertificateInfoOrdered subject
The subject information.
Definition: qcaprovider.h:1068
int cipherBits
The bit size of the cipher used for this connection.
Definition: qcaprovider.h:2144
CRLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1423
KeyStore provider.
Definition: qcaprovider.h:1848
CertificateInfoOrdered issuer
The issuer information.
Definition: qcaprovider.h:1075
int number
The CRL number, which increases at each update.
Definition: qcaprovider.h:1195
X.509 certificate revocation list provider.
Definition: qcaprovider.h:1414
OpenPGP key properties.
Definition: qcaprovider.h:1626
QDateTime thisUpdate
The time this CRL was created.
Definition: qcaprovider.h:1200
Type
The type of entry in the KeyStore.
Definition: qca_keystore.h:146
Certificate chain and private key pair.
Definition: qca_cert.h:2135
Provider plugin base class
Definition: qcaprovider.h:82
Discrete logarithm provider.
Definition: qcaprovider.h:392
Header file for PGP key and X.509 certificate related classes.
SignatureAlgorithm sigalgo
The signature algorithm used by the issuer to sign the CRL.
Definition: qcaprovider.h:1220
Operation completed.
Definition: qcaprovider.h:2164
X.509 certificate revocation list properties.
Definition: qcaprovider.h:1184
SecureMessage provider.
Definition: qcaprovider.h:2769
ValidateFlags
The conditions to validate for a certificate.
Definition: qca_cert.h:508
DSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:693
Validity
The validity (or otherwise) of a certificate.
Definition: qca_cert.h:489
QStringList policies
The policies.
Definition: qcaprovider.h:1085
Header file for SecureLayer and its subclasses.
Algorithm provider.
Definition: qca_core.h:749
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1225
bool inKeyring
True if this key is in a keyring (and thus usable), otherwise false.
Definition: qcaprovider.h:1666
RSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:610
QString addr
The IP address.
Definition: qcaprovider.h:2486
Hash provider.
Definition: qcaprovider.h:176
Encrypt operation.
Definition: qcaprovider.h:2778
Header file for PublicKey and PrivateKey related classes.
RandomContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:156
KeyStoreEntry provider.
Definition: qcaprovider.h:1743
Decrypt (or Decrypt and Verify) operation.
Definition: qcaprovider.h:2779
QStringList userIds
List of user id strings for the key, the first one being the primary user id.
Definition: qcaprovider.h:1638
CAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1506
TLS "session" provider.
Definition: qcaprovider.h:2086
PKCS12Context(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1583
TLSSessionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2095
PKCS#12 provider.
Definition: qcaprovider.h:1574
DHContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:763
CertCollectionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1458
bool isCA
True if the certificate is a CA or the certificate request is requesting to be a CA, otherwise false.
Definition: qcaprovider.h:1119
Information about an active TLS connection.
Definition: qcaprovider.h:2121
QStringList crlLocations
A list of URIs for CRLs.
Definition: qcaprovider.h:1092
DSA provider.
Definition: qcaprovider.h:684
Type
The type of secure message.
Definition: qca_securemessage.h:327
QString keyId
The key id.
Definition: qcaprovider.h:1632
X.509 certificate collection provider.
Definition: qcaprovider.h:1449
SASL provider.
Definition: qcaprovider.h:2467
Certificate Revocation List
Definition: qca_cert.h:1702
Convenience class to hold an IP address and an associated port.
Definition: qcaprovider.h:2480
Error
Errors for secure messages.
Definition: qca_securemessage.h:355
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1155
Container for keys for symmetric encryption algorithms.
Definition: qca_core.h:1248
Container for authentication tag.
Definition: qca_core.h:1331
QList< CRLEntry > revoked
The revoked entries.
Definition: qcaprovider.h:1210
Simple container for acceptable key lengths
Definition: qca_core.h:697
CertContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1249
Header file for core QCA infrastructure.
TLSSessionContext * id
Pointer to the id of this TLS session, for use with resuming.
Definition: qcaprovider.h:2156
Result
Result of a TLS operation.
Definition: qcaprovider.h:2162
Public key implementation provider base.
Definition: qcaprovider.h:457
Operation completed.
Definition: qcaprovider.h:2499
quint16 port
The port.
Definition: qcaprovider.h:2491
SignatureAlgorithm
Signature algorithm variants.
Definition: qca_publickey.h:73
A discrete logarithm group.
Definition: qca_publickey.h:170
InfoContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:119
CertificateRequestFormat format
The format used for the certificate request.
Definition: qcaprovider.h:1169
Ordered certificate properties type.
Definition: qca_cert.h:539
DLGroupSet
Well known discrete logarithm group sets
Definition: qca_publickey.h:133
Client login can be inspected (server only)
Definition: qcaprovider.h:2502
Header file for classes that provide and manage keys.
CipherContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:229
Parameters are needed to complete authentication.
Definition: qcaprovider.h:2501
Container for initialisation vectors and nonces.
Definition: qca_core.h:1294
Format
Formats for secure messages.
Definition: qca_securemessage.h:346
TLSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2175
bool isTrusted
True if this key is trusted (e.g.
Definition: qcaprovider.h:1672
Direction
Direction settings for symmetric algorithms.
Definition: qca_core.h:140
QDateTime nextUpdate
The time this CRL expires, and the next CRL should be fetched.
Definition: qcaprovider.h:1205
Public key container provider.
Definition: qcaprovider.h:830
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:48
CertBase(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:990
SASLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2511
int pathLimit
The path limit.
Definition: qcaprovider.h:1131
Base class to use for primitive provider contexts.
Definition: qca_core.h:994
QString cipherSuite
The cipher suite being used for this connection.
Definition: qcaprovider.h:2139
virtual QString name() const =0
The name of the provider.
KDFContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:354
HashContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:186
Header file for secure message (PGP, CMS) classes.
Type
The type of keystore.
Definition: qca_keystore.h:423
AuthFlags
Authentication requirement flag values.
Definition: qca_securelayer.h:875
Verify operation.
Definition: qcaprovider.h:2781
int cipherMaxBits
The maximum bit size possible of the cipher used for this connection.
Definition: qcaprovider.h:2150
Sign operation.
Definition: qcaprovider.h:2780
bool isSelfSigned
True if the certificate is self-signed.
Definition: qcaprovider.h:1126
Header file for classes for cryptographic primitives (basic operations).
SignatureFormat
Signature formats (DSA only)
Definition: qca_publickey.h:91
SignatureAlgorithm sigalgo
The signature algorithm used to create the signature.
Definition: qcaprovider.h:1141
QDateTime start
The time the certificate becomes valid (often the time of create)
Definition: qcaprovider.h:1056
Type
Types of public key cryptography keys supported by QCA.
Definition: qca_publickey.h:255
Secure array of bytes.
Definition: qca_tools.h:316
OpenPGP key provider.
Definition: qcaprovider.h:1685
MACContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:292
Result
Result of a SASL operation.
Definition: qcaprovider.h:2497
AuthCondition
Possible authentication error states.
Definition: qca_securelayer.h:856
KeyStoreListContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1857
bool isSecret
True if this key is a secret key, otherwise false.
Definition: qcaprovider.h:1643
virtual ~QCAPlugin()
Destructs the object.
Definition: qcaprovider.h:88
CertificateRequestFormat
Certificate Request Format.
Definition: qca_cert.h:54
QList< ConstraintType > Constraints
Certificate constraints type
Definition: qca_cert.h:582
Certificate options
Definition: qca_cert.h:601
TLS provider.
Definition: qcaprovider.h:2108
RSA provider.
Definition: qcaprovider.h:601
Key derivation function provider.
Definition: qcaprovider.h:344
EncryptionAlgorithm
Encryption algorithms.
Definition: qca_publickey.h:54
DLGroupContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:401
QByteArray sig
The signature data of the CRL.
Definition: qcaprovider.h:1215
A chain of related Certificates.
Definition: qca_cert.h:1207
Operation failed.
Definition: qcaprovider.h:2165
Operation
The type of operation being performed.
Definition: qcaprovider.h:2776
QDateTime expirationDate
The time the key expires.
Definition: qcaprovider.h:1653
QStringList issuerLocations
A list of URIs for issuer certificates.
Definition: qcaprovider.h:1099
Constraints constraints
The constraints.
Definition: qcaprovider.h:1080
QByteArray subjectId
The subject id.
Definition: qcaprovider.h:1148
Extended provider information.
Definition: qcaprovider.h:110
QStringList ocspLocations
A list of URIs for OCSP services.
Definition: qcaprovider.h:1106
QString type() const
The type of context, as passed to the constructor.
QString fingerprint
The hex fingerprint of the key.
Definition: qcaprovider.h:1660
Public Key (X.509) certificate.
Definition: qca_cert.h:848
SMSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2964
SecureMessageSystem provider.
Definition: qcaprovider.h:2954
BigInteger serial
The certificate serial number.
Definition: qcaprovider.h:1113
int version
The X.509 certificate version, usually 3.
Definition: qcaprovider.h:1049
SignMode
The type of message signature.
Definition: qca_securemessage.h:336
Operation failed.
Definition: qcaprovider.h:2500
PGPKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1694
Internal context class used for the plugin.
QDateTime creationDate
The time the key was created.
Definition: qcaprovider.h:1648
KeyStoreEntryContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1752
UsageMode
Specify the intended usage of a certificate.
Definition: qca_cert.h:475
Arbitrary precision integer
Definition: qca_tools.h:570
X.509 certificate and certificate request provider base.
Definition: qcaprovider.h:980
Cipher provider.
Definition: qcaprovider.h:216
TLS::Version version
The TLS protocol version being used for this connection.
Definition: qcaprovider.h:2132
Pretty Good Privacy key.
Definition: qca_cert.h:2360
Bundle of Certificates and CRLs.
Definition: qca_cert.h:1890
KeyLength anyKeyLength() const
Returns a KeyLength that supports any length.
Definition: qcaprovider.h:324
Random provider.
Definition: qcaprovider.h:147
X.509 certificate authority provider.
Definition: qcaprovider.h:1497
Array of bytes that may be optionally secured.
Definition: qca_tools.h:90
QByteArray sig
The signature data.
Definition: qcaprovider.h:1136