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 
238  virtual void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv) = 0;
239 
243  virtual KeyLength keyLength() const = 0;
244 
248  virtual int blockSize() const = 0;
249 
256  virtual bool update(const SecureArray &in, SecureArray *out) = 0;
257 
263  virtual bool final(SecureArray *out) = 0;
264 };
265 
277 class QCA_EXPORT MACContext : public BasicContext
278 {
279  Q_OBJECT
280 public:
286  MACContext(Provider *p, const QString &type) : BasicContext(p, type) {}
287 
293  virtual void setup(const SymmetricKey &key) = 0;
294 
298  virtual KeyLength keyLength() const = 0;
299 
305  virtual void update(const MemoryRegion &in) = 0;
306 
312  virtual void final(MemoryRegion *out) = 0;
313 
314 protected:
319  {
320  // this is used instead of a default implementation to make sure that
321  // provider authors think about it, at least a bit.
322  // See Meyers, Effective C++, Effective C++ (2nd Ed), Item 36
323  return KeyLength( 0, INT_MAX, 1 );
324  }
325 };
326 
338 class QCA_EXPORT KDFContext : public BasicContext
339 {
340  Q_OBJECT
341 public:
348  KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}
349 
358  virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
359 
369  virtual SymmetricKey makeKey(const SecureArray &secret,
370  const InitializationVector &salt,
371  unsigned int keyLength,
372  int msecInterval,
373  unsigned int *iterationCount) = 0;
374 };
375 
386 class QCA_EXPORT DLGroupContext : public Provider::Context
387 {
388  Q_OBJECT
389 public:
395  DLGroupContext(Provider *p) : Provider::Context(p, QStringLiteral("dlgroup")) {}
396 
400  virtual QList<DLGroupSet> supportedGroupSets() const = 0;
401 
405  virtual bool isNull() const = 0;
406 
420  virtual void fetchGroup(DLGroupSet set, bool block) = 0;
421 
430  virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;
431 
432 Q_SIGNALS:
437  void finished();
438 };
439 
451 class QCA_EXPORT PKeyBase : public BasicContext
452 {
453  Q_OBJECT
454 public:
461  PKeyBase(Provider *p, const QString &type);
462 
468  virtual bool isNull() const = 0;
469 
473  virtual PKey::Type type() const = 0;
474 
478  virtual bool isPrivate() const = 0;
479 
485  virtual bool canExport() const = 0;
486 
493  virtual void convertToPublic() = 0;
494 
498  virtual int bits() const = 0;
499 
506  virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;
507 
514  virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);
515 
524  virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
525 
532  virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);
533 
540  virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);
541 
548  virtual void update(const MemoryRegion &in);
549 
555  virtual QByteArray endSign();
556 
564  virtual bool endVerify(const QByteArray &sig);
565 
574  virtual SymmetricKey deriveKey(const PKeyBase &theirs);
575 
576 Q_SIGNALS:
581  void finished();
582 };
583 
595 class QCA_EXPORT RSAContext : public PKeyBase
596 {
597  Q_OBJECT
598 public:
604  RSAContext(Provider *p) : PKeyBase(p, QStringLiteral("rsa")) {}
605 
620  virtual void createPrivate(int bits, int exp, bool block) = 0;
621 
631  virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;
632 
639  virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;
640 
644  virtual BigInteger n() const = 0;
645 
649  virtual BigInteger e() const = 0;
650 
654  virtual BigInteger p() const = 0;
655 
659  virtual BigInteger q() const = 0;
660 
664  virtual BigInteger d() const = 0;
665 };
666 
678 class QCA_EXPORT DSAContext : public PKeyBase
679 {
680  Q_OBJECT
681 public:
687  DSAContext(Provider *p) : PKeyBase(p, QStringLiteral("dsa")) {}
688 
702  virtual void createPrivate(const DLGroup &domain, bool block) = 0;
703 
711  virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
712 
719  virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
720 
724  virtual DLGroup domain() const = 0;
725 
729  virtual BigInteger y() const = 0;
730 
734  virtual BigInteger x() const = 0;
735 };
736 
748 class QCA_EXPORT DHContext : public PKeyBase
749 {
750  Q_OBJECT
751 public:
757  DHContext(Provider *p) : PKeyBase(p, QStringLiteral("dh")) {}
758 
772  virtual void createPrivate(const DLGroup &domain, bool block) = 0;
773 
782  virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
783 
791  virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
792 
796  virtual DLGroup domain() const = 0;
797 
801  virtual BigInteger y() const = 0;
802 
806  virtual BigInteger x() const = 0;
807 };
808 
824 class QCA_EXPORT PKeyContext : public BasicContext
825 {
826  Q_OBJECT
827 public:
833  PKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pkey")) {}
834 
838  virtual QList<PKey::Type> supportedTypes() const = 0;
839 
844  virtual QList<PKey::Type> supportedIOTypes() const = 0;
845 
850  virtual QList<PBEAlgorithm> supportedPBEAlgorithms() const = 0;
851 
855  virtual PKeyBase *key() = 0;
856 
860  virtual const PKeyBase *key() const = 0;
861 
869  virtual void setKey(PKeyBase *key) = 0;
870 
882  virtual bool importKey(const PKeyBase *key) = 0;
883 
889  virtual QByteArray publicToDER() const;
890 
896  virtual QString publicToPEM() const;
897 
906  virtual ConvertResult publicFromDER(const QByteArray &a);
907 
916  virtual ConvertResult publicFromPEM(const QString &s);
917 
927  virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;
928 
938  virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;
939 
949  virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);
950 
960  virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
961 };
962 
974 class QCA_EXPORT CertBase : public BasicContext
975 {
976  Q_OBJECT
977 public:
984  CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}
985 
991  virtual QByteArray toDER() const = 0;
992 
998  virtual QString toPEM() const = 0;
999 
1008  virtual ConvertResult fromDER(const QByteArray &a) = 0;
1009 
1018  virtual ConvertResult fromPEM(const QString &s) = 0;
1019 };
1020 
1035 class QCA_EXPORT CertContextProps
1036 {
1037 public:
1043  int version;
1044 
1050  QDateTime start;
1051 
1057  QDateTime end;
1058 
1063 
1070 
1075 
1079  QStringList policies;
1080 
1086  QStringList crlLocations;
1087 
1093  QStringList issuerLocations;
1094 
1100  QStringList ocspLocations;
1101 
1108 
1113  bool isCA;
1114 
1121 
1126 
1130  QByteArray sig;
1131 
1136 
1142  QByteArray subjectId;
1143 
1149  QByteArray issuerId;
1150 
1156  QString challenge;
1157 
1164 };
1165 
1178 class QCA_EXPORT CRLContextProps
1179 {
1180 public:
1185 
1189  int number;
1190 
1194  QDateTime thisUpdate;
1195 
1199  QDateTime nextUpdate;
1200 
1205 
1209  QByteArray sig;
1210 
1215 
1219  QByteArray issuerId;
1220 };
1221 
1222 class CRLContext;
1223 
1234 class QCA_EXPORT CertContext : public CertBase
1235 {
1236  Q_OBJECT
1237 public:
1243  CertContext(Provider *p) : CertBase(p, QStringLiteral("cert")) {}
1244 
1256  virtual bool createSelfSigned(const CertificateOptions &opts, const PKeyContext &priv) = 0;
1257 
1261  virtual const CertContextProps *props() const = 0;
1262 
1269  virtual bool compare(const CertContext *other) const = 0;
1270 
1275  virtual PKeyContext *subjectPublicKey() const = 0;
1276 
1283  virtual bool isIssuerOf(const CertContext *other) const = 0;
1284 
1296  virtual Validity validate(const QList<CertContext*> &trusted, const QList<CertContext*> &untrusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
1297 
1313  virtual Validity validate_chain(const QList<CertContext*> &chain, const QList<CertContext*> &trusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
1314 };
1315 
1327 class QCA_EXPORT CSRContext : public CertBase
1328 {
1329  Q_OBJECT
1330 public:
1336  CSRContext(Provider *p) : CertBase(p, QStringLiteral("csr")) {}
1337 
1344  virtual bool canUseFormat(CertificateRequestFormat f) const = 0;
1345 
1357  virtual bool createRequest(const CertificateOptions &opts, const PKeyContext &priv) = 0;
1358 
1362  virtual const CertContextProps *props() const = 0;
1363 
1370  virtual bool compare(const CSRContext *other) const = 0;
1371 
1376  virtual PKeyContext *subjectPublicKey() const = 0;
1377 
1384  virtual QString toSPKAC() const = 0;
1385 
1395  virtual ConvertResult fromSPKAC(const QString &s) = 0;
1396 };
1397 
1408 class QCA_EXPORT CRLContext : public CertBase
1409 {
1410  Q_OBJECT
1411 public:
1417  CRLContext(Provider *p) : CertBase(p, QStringLiteral("crl")) {}
1418 
1422  virtual const CRLContextProps *props() const = 0;
1423 
1429  virtual bool compare(const CRLContext *other) const = 0;
1430 };
1431 
1443 class QCA_EXPORT CertCollectionContext : public BasicContext
1444 {
1445  Q_OBJECT
1446 public:
1452  CertCollectionContext(Provider *p) : BasicContext(p, QStringLiteral("certcollection")) {}
1453 
1462  virtual QByteArray toPKCS7(const QList<CertContext*> &certs, const QList<CRLContext*> &crls) const = 0;
1463 
1477  virtual ConvertResult fromPKCS7(const QByteArray &a, QList<CertContext*> *certs, QList<CRLContext*> *crls) const = 0;
1478 };
1479 
1491 class QCA_EXPORT CAContext : public BasicContext
1492 {
1493  Q_OBJECT
1494 public:
1500  CAContext(Provider *p) : BasicContext(p, QStringLiteral("ca")) {}
1501 
1510  virtual void setup(const CertContext &cert, const PKeyContext &priv) = 0;
1511 
1516  virtual CertContext *certificate() const = 0;
1517 
1525  virtual CertContext *signRequest(const CSRContext &req, const QDateTime &notValidAfter) const = 0;
1526 
1534  virtual CertContext *createCertificate(const PKeyContext &pub, const CertificateOptions &opts) const = 0;
1535 
1544  virtual CRLContext *createCRL(const QDateTime &nextUpdate) const = 0;
1545 
1555  virtual CRLContext *updateCRL(const CRLContext &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const = 0;
1556 };
1557 
1568 class QCA_EXPORT PKCS12Context : public BasicContext
1569 {
1570  Q_OBJECT
1571 public:
1577  PKCS12Context(Provider *p) : BasicContext(p, QStringLiteral("pkcs12")) {}
1578 
1589  virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;
1590 
1605  virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
1606 };
1607 
1620 class QCA_EXPORT PGPKeyContextProps
1621 {
1622 public:
1626  QString keyId;
1627 
1632  QStringList userIds;
1633 
1637  bool isSecret;
1638 
1642  QDateTime creationDate;
1643 
1647  QDateTime expirationDate;
1648 
1654  QString fingerprint;
1655 
1661 
1667 };
1668 
1679 class QCA_EXPORT PGPKeyContext : public BasicContext
1680 {
1681  Q_OBJECT
1682 public:
1688  PGPKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pgpkey")) {}
1689 
1693  virtual const PGPKeyContextProps *props() const = 0;
1694 
1698  virtual QByteArray toBinary() const = 0;
1699 
1703  virtual QString toAscii() const = 0;
1704 
1713  virtual ConvertResult fromBinary(const QByteArray &a) = 0;
1714 
1723  virtual ConvertResult fromAscii(const QString &s) = 0;
1724 };
1725 
1737 class QCA_EXPORT KeyStoreEntryContext : public BasicContext
1738 {
1739  Q_OBJECT
1740 public:
1746  KeyStoreEntryContext(Provider *p) : BasicContext(p, QStringLiteral("keystoreentry")) {}
1747 
1751  virtual KeyStoreEntry::Type type() const = 0;
1752 
1758  virtual QString id() const = 0;
1759 
1763  virtual QString name() const = 0;
1764 
1768  virtual QString storeId() const = 0;
1769 
1773  virtual QString storeName() const = 0;
1774 
1778  virtual bool isAvailable() const;
1779 
1788  virtual QString serialize() const = 0;
1789 
1794  virtual KeyBundle keyBundle() const;
1795 
1800  virtual Certificate certificate() const;
1801 
1806  virtual CRL crl() const;
1807 
1812  virtual PGPKey pgpSecretKey() const;
1813 
1819  virtual PGPKey pgpPublicKey() const;
1820 
1829  virtual bool ensureAccess();
1830 };
1831 
1842 class QCA_EXPORT KeyStoreListContext : public Provider::Context
1843 {
1844  Q_OBJECT
1845 public:
1851  KeyStoreListContext(Provider *p) : Provider::Context(p, QStringLiteral("keystorelist")) {}
1852 
1856  virtual void start();
1857 
1866  virtual void setUpdatesEnabled(bool enabled);
1867 
1877  virtual QList<int> keyStores() = 0;
1878 
1885  virtual KeyStore::Type type(int id) const = 0;
1886 
1898  virtual QString storeId(int id) const = 0;
1899 
1906  virtual QString name(int id) const = 0;
1907 
1916  virtual bool isReadOnly(int id) const;
1917 
1927  virtual QList<KeyStoreEntry::Type> entryTypes(int id) const = 0;
1928 
1937  virtual QList<KeyStoreEntryContext*> entryList(int id) = 0;
1938 
1948  virtual KeyStoreEntryContext *entry(int id, const QString &entryId);
1949 
1962  virtual KeyStoreEntryContext *entryPassive(const QString &serialized);
1963 
1973  virtual QString writeEntry(int id, const KeyBundle &kb);
1974 
1984  virtual QString writeEntry(int id, const Certificate &cert);
1985 
1995  virtual QString writeEntry(int id, const CRL &crl);
1996 
2006  virtual QString writeEntry(int id, const PGPKey &key);
2007 
2017  virtual bool removeEntry(int id, const QString &entryId);
2018 
2019 Q_SIGNALS:
2037  void busyStart();
2038 
2046  void busyEnd();
2047 
2052  void updated();
2053 
2059  void diagnosticText(const QString &str);
2060 
2067  void storeUpdated(int id);
2068 };
2069 
2080 class QCA_EXPORT TLSSessionContext : public BasicContext
2081 {
2082  Q_OBJECT
2083 public:
2089  TLSSessionContext(Provider *p) : BasicContext(p, QStringLiteral("tlssession")) {}
2090 };
2091 
2102 class QCA_EXPORT TLSContext : public Provider::Context
2103 {
2104  Q_OBJECT
2105 public:
2116  {
2117  public:
2122 
2127 
2133  QString cipherSuite;
2134 
2139 
2145 
2151  };
2152 
2156  enum Result
2157  {
2160  Continue
2161  };
2162 
2169  TLSContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
2170 
2174  virtual void reset() = 0;
2175 
2183  virtual QStringList supportedCipherSuites(const TLS::Version &version) const = 0;
2184 
2188  virtual bool canCompress() const = 0;
2189 
2193  virtual bool canSetHostName() const = 0;
2194 
2198  virtual int maxSSF() const = 0;
2199 
2210  virtual void setup(bool serverMode, const QString &hostName, bool compress) = 0;
2211 
2220  virtual void setConstraints(int minSSF, int maxSSF) = 0;
2221 
2234  virtual void setConstraints(const QStringList &cipherSuiteList) = 0;
2235 
2243  virtual void setTrustedCertificates(const CertificateCollection &trusted) = 0;
2244 
2254  virtual void setIssuerList(const QList<CertificateInfoOrdered> &issuerList) = 0;
2255 
2264  virtual void setCertificate(const CertificateChain &cert, const PrivateKey &key) = 0;
2265 
2273  virtual void setSessionId(const TLSSessionContext &id) = 0;
2274 
2283  virtual void shutdown() = 0;
2284 
2292  virtual void setMTU(int size);
2293 
2306  virtual void start() = 0;
2307 
2333  virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
2334 
2344  virtual bool waitForResultsReady(int msecs) = 0;
2345 
2349  virtual Result result() const = 0;
2350 
2354  virtual QByteArray to_net() = 0;
2355 
2360  virtual int encoded() const = 0;
2361 
2366  virtual QByteArray to_app() = 0;
2367 
2371  virtual bool eof() const = 0;
2372 
2379  virtual bool clientHelloReceived() const = 0;
2380 
2386  virtual bool serverHelloReceived() const = 0;
2387 
2394  virtual QString hostName() const = 0;
2395 
2401  virtual bool certificateRequested() const = 0;
2402 
2408  virtual QList<CertificateInfoOrdered> issuerList() const = 0;
2409 
2415  virtual Validity peerCertificateValidity() const = 0;
2416 
2422  virtual CertificateChain peerCertificateChain() const = 0;
2423 
2429  virtual SessionInfo sessionInfo() const = 0;
2430 
2436  virtual QByteArray unprocessed() = 0;
2437 
2438 Q_SIGNALS:
2442  void resultsReady();
2443 
2448  void dtlsTimeout();
2449 };
2450 
2461 class QCA_EXPORT SASLContext : public Provider::Context
2462 {
2463  Q_OBJECT
2464 public:
2474  class HostPort
2475  {
2476  public:
2480  QString addr;
2481 
2485  quint16 port;
2486  };
2487 
2491  enum Result
2492  {
2497  Continue
2498  };
2499 
2505  SASLContext(Provider *p) : Provider::Context(p, QStringLiteral("sasl")) {}
2506 
2510  virtual void reset() = 0;
2511 
2533  virtual void setup(const QString &service, const QString &host, const HostPort *local, const HostPort *remote, const QString &ext_id, int ext_ssf) = 0;
2534 
2545  virtual void setConstraints(SASL::AuthFlags f, int minSSF, int maxSSF) = 0;
2546 
2562  virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) = 0;
2563 
2579  virtual void startServer(const QString &realm, bool disableServerSendLast) = 0;
2580 
2594  virtual void serverFirstStep(const QString &mech, const QByteArray *clientInit) = 0;
2595 
2607  virtual void nextStep(const QByteArray &from_net) = 0;
2608 
2618  virtual void tryAgain() = 0;
2619 
2632  virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
2633 
2644  virtual bool waitForResultsReady(int msecs) = 0;
2645 
2649  virtual Result result() const = 0;
2650 
2654  virtual QStringList mechlist() const = 0;
2655 
2659  virtual QString mech() const = 0;
2660 
2664  virtual bool haveClientInit() const = 0;
2665 
2670  virtual QByteArray stepData() const = 0;
2671 
2676  virtual QByteArray to_net() = 0;
2677 
2682  virtual int encoded() const = 0;
2683 
2688  virtual QByteArray to_app() = 0;
2689 
2695  virtual int ssf() const = 0;
2696 
2703  virtual SASL::AuthCondition authCondition() const = 0;
2704 
2710  virtual SASL::Params clientParams() const = 0;
2711 
2720  virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;
2721 
2728  virtual QStringList realmlist() const = 0;
2729 
2735  virtual QString username() const = 0;
2736 
2742  virtual QString authzid() const = 0;
2743 
2744 Q_SIGNALS:
2749  void resultsReady();
2750 };
2751 
2763 class QCA_EXPORT MessageContext : public Provider::Context
2764 {
2765  Q_OBJECT
2766 public:
2771  {
2776  SignAndEncrypt
2777  };
2778 
2785  MessageContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
2786 
2791  virtual bool canSignMultiple() const = 0;
2792 
2796  virtual SecureMessage::Type type() const = 0;
2797 
2801  virtual void reset() = 0;
2802 
2808  virtual void setupEncrypt(const SecureMessageKeyList &keys) = 0;
2809 
2818  virtual void setupSign(const SecureMessageKeyList &keys, SecureMessage::SignMode m, bool bundleSigner, bool smime) = 0;
2819 
2825  virtual void setupVerify(const QByteArray &detachedSig) = 0;
2826 
2840  virtual void start(SecureMessage::Format f, Operation op) = 0;
2841 
2847  virtual void update(const QByteArray &in) = 0;
2848 
2852  virtual QByteArray read() = 0;
2853 
2858  virtual int written() = 0;
2859 
2863  virtual void end() = 0;
2864 
2868  virtual bool finished() const = 0;
2869 
2879  virtual bool waitForFinished(int msecs) = 0;
2880 
2886  virtual bool success() const = 0;
2887 
2894  virtual SecureMessage::Error errorCode() const = 0;
2895 
2902  virtual QByteArray signature() const = 0;
2903 
2910  virtual QString hashName() const = 0;
2911 
2918  virtual SecureMessageSignatureList signers() const = 0;
2919 
2927  virtual QString diagnosticText() const;
2928 
2929 Q_SIGNALS:
2934  void updated();
2935 };
2936 
2948 class QCA_EXPORT SMSContext : public BasicContext
2949 {
2950  Q_OBJECT
2951 public:
2958  SMSContext(Provider *p, const QString &type) : BasicContext(p, type) {}
2959 
2970  virtual void setTrustedCertificates(const CertificateCollection &trusted);
2971 
2980  virtual void setUntrustedCertificates(const CertificateCollection &untrusted);
2981 
2990  virtual void setPrivateKeys(const QList<SecureMessageKey> &keys);
2991 
2996  virtual MessageContext *createMessage() = 0;
2997 };
2998 
2999 }
3000 #endif
3001 
3002 #endif
ConvertResult
Return value from a format conversion.
Definition: qca_publickey.h:117
X.509 certificate request provider.
Definition: qcaprovider.h:1327
CertificateInfoOrdered issuer
The issuer information of the CRL.
Definition: qcaprovider.h:1184
bool isCompressed
True if the TLS connection is compressed, otherwise false.
Definition: qcaprovider.h:2121
X.509 certificate provider.
Definition: qcaprovider.h:1234
PKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:833
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:748
MessageContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2785
Message authentication code provider.
Definition: qcaprovider.h:277
QDateTime end
The time the certificate expires.
Definition: qcaprovider.h:1057
X.509 certificate or certificate request properties.
Definition: qcaprovider.h:1035
Parameter flags for the SASL authentication.
Definition: qca_securelayer.h:914
CSRContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1336
Generic private key.
Definition: qca_publickey.h:826
QString challenge
The SPKAC challenge value.
Definition: qcaprovider.h:1156
CertificateInfoOrdered subject
The subject information.
Definition: qcaprovider.h:1062
int cipherBits
The bit size of the cipher used for this connection.
Definition: qcaprovider.h:2138
CRLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1417
KeyStore provider.
Definition: qcaprovider.h:1842
CertificateInfoOrdered issuer
The issuer information.
Definition: qcaprovider.h:1069
int number
The CRL number, which increases at each update.
Definition: qcaprovider.h:1189
X.509 certificate revocation list provider.
Definition: qcaprovider.h:1408
OpenPGP key properties.
Definition: qcaprovider.h:1620
QDateTime thisUpdate
The time this CRL was created.
Definition: qcaprovider.h:1194
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:386
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:1214
Operation completed.
Definition: qcaprovider.h:2158
X.509 certificate revocation list properties.
Definition: qcaprovider.h:1178
SecureMessage provider.
Definition: qcaprovider.h:2763
ValidateFlags
The conditions to validate for a certificate.
Definition: qca_cert.h:508
DSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:687
Validity
The validity (or otherwise) of a certificate.
Definition: qca_cert.h:489
QStringList policies
The policies.
Definition: qcaprovider.h:1079
Header file for SecureLayer and its subclasses.
Algorithm provider.
Definition: qca_core.h:722
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1219
bool inKeyring
True if this key is in a keyring (and thus usable), otherwise false.
Definition: qcaprovider.h:1660
RSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:604
QString addr
The IP address.
Definition: qcaprovider.h:2480
Hash provider.
Definition: qcaprovider.h:176
Encrypt operation.
Definition: qcaprovider.h:2772
Header file for PublicKey and PrivateKey related classes.
RandomContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:156
KeyStoreEntry provider.
Definition: qcaprovider.h:1737
Decrypt (or Decrypt and Verify) operation.
Definition: qcaprovider.h:2773
QStringList userIds
List of user id strings for the key, the first one being the primary user id.
Definition: qcaprovider.h:1632
CAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1500
TLS "session" provider.
Definition: qcaprovider.h:2080
PKCS12Context(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1577
TLSSessionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2089
PKCS#12 provider.
Definition: qcaprovider.h:1568
DHContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:757
CertCollectionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1452
bool isCA
True if the certificate is a CA or the certificate request is requesting to be a CA, otherwise false.
Definition: qcaprovider.h:1113
Information about an active TLS connection.
Definition: qcaprovider.h:2115
QStringList crlLocations
A list of URIs for CRLs.
Definition: qcaprovider.h:1086
DSA provider.
Definition: qcaprovider.h:678
KeyLength anyKeyLength() const
Returns a KeyLength that supports any length.
Definition: qcaprovider.h:318
Type
The type of secure message.
Definition: qca_securemessage.h:327
QString keyId
The key id.
Definition: qcaprovider.h:1626
X.509 certificate collection provider.
Definition: qcaprovider.h:1443
SASL provider.
Definition: qcaprovider.h:2461
Certificate Revocation List
Definition: qca_cert.h:1702
Convenience class to hold an IP address and an associated port.
Definition: qcaprovider.h:2474
Error
Errors for secure messages.
Definition: qca_securemessage.h:355
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1149
Container for keys for symmetric encryption algorithms.
Definition: qca_core.h:1221
QList< CRLEntry > revoked
The revoked entries.
Definition: qcaprovider.h:1204
QString type() const
The type of context, as passed to the constructor.
Simple container for acceptable key lengths.
Definition: qca_core.h:670
CertContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1243
Header file for core QCA infrastructure.
TLSSessionContext * id
Pointer to the id of this TLS session, for use with resuming.
Definition: qcaprovider.h:2150
Result
Result of a TLS operation.
Definition: qcaprovider.h:2156
Public key implementation provider base.
Definition: qcaprovider.h:451
Operation completed.
Definition: qcaprovider.h:2493
quint16 port
The port.
Definition: qcaprovider.h:2485
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:1163
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:2496
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:2495
Container for initialisation vectors and nonces.
Definition: qca_core.h:1267
Format
Formats for secure messages.
Definition: qca_securemessage.h:346
TLSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2169
bool isTrusted
True if this key is trusted (e.g.
Definition: qcaprovider.h:1666
Direction
Direction settings for symmetric algorithms.
Definition: qca_core.h:139
QDateTime nextUpdate
The time this CRL expires, and the next CRL should be fetched.
Definition: qcaprovider.h:1199
Public key container provider.
Definition: qcaprovider.h:824
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:47
CertBase(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:984
SASLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2505
int pathLimit
The path limit.
Definition: qcaprovider.h:1125
Base class to use for primitive provider contexts.
Definition: qca_core.h:967
QString cipherSuite
The cipher suite being used for this connection.
Definition: qcaprovider.h:2133
KDFContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:348
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:2775
int cipherMaxBits
The maximum bit size possible of the cipher used for this connection.
Definition: qcaprovider.h:2144
Sign operation.
Definition: qcaprovider.h:2774
bool isSelfSigned
True if the certificate is self-signed.
Definition: qcaprovider.h:1120
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:1135
QDateTime start
The time the certificate becomes valid (often the time of create)
Definition: qcaprovider.h:1050
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:1679
MACContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:286
Result
Result of a SASL operation.
Definition: qcaprovider.h:2491
AuthCondition
Possible authentication error states.
Definition: qca_securelayer.h:856
KeyStoreListContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1851
bool isSecret
True if this key is a secret key, otherwise false.
Definition: qcaprovider.h:1637
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:2102
RSA provider.
Definition: qcaprovider.h:595
Key derivation function provider.
Definition: qcaprovider.h:338
EncryptionAlgorithm
Encryption algorithms.
Definition: qca_publickey.h:54
DLGroupContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:395
QByteArray sig
The signature data of the CRL.
Definition: qcaprovider.h:1209
A chain of related Certificates.
Definition: qca_cert.h:1207
Operation failed.
Definition: qcaprovider.h:2159
Operation
The type of operation being performed.
Definition: qcaprovider.h:2770
QDateTime expirationDate
The time the key expires.
Definition: qcaprovider.h:1647
QStringList issuerLocations
A list of URIs for issuer certificates.
Definition: qcaprovider.h:1093
Constraints constraints
The constraints.
Definition: qcaprovider.h:1074
QByteArray subjectId
The subject id.
Definition: qcaprovider.h:1142
Extended provider information.
Definition: qcaprovider.h:110
QStringList ocspLocations
A list of URIs for OCSP services.
Definition: qcaprovider.h:1100
QString fingerprint
The hex fingerprint of the key.
Definition: qcaprovider.h:1654
Public Key (X.509) certificate.
Definition: qca_cert.h:848
SMSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2958
SecureMessageSystem provider.
Definition: qcaprovider.h:2948
BigInteger serial
The certificate serial number.
Definition: qcaprovider.h:1107
int version
The X.509 certificate version, usually 3.
Definition: qcaprovider.h:1043
SignMode
The type of message signature.
Definition: qca_securemessage.h:336
Operation failed.
Definition: qcaprovider.h:2494
PGPKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1688
Internal context class used for the plugin.
QDateTime creationDate
The time the key was created.
Definition: qcaprovider.h:1642
KeyStoreEntryContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1746
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:974
Cipher provider.
Definition: qcaprovider.h:216
TLS::Version version
The TLS protocol version being used for this connection.
Definition: qcaprovider.h:2126
Pretty Good Privacy key.
Definition: qca_cert.h:2360
Bundle of Certificates and CRLs.
Definition: qca_cert.h:1890
virtual QString name() const =0
The name of the provider.
Random provider.
Definition: qcaprovider.h:147
X.509 certificate authority provider.
Definition: qcaprovider.h:1491
Array of bytes that may be optionally secured.
Definition: qca_tools.h:90
QByteArray sig
The signature data.
Definition: qcaprovider.h:1130