Qt Cryptographic Architecture: qcaprovider.h Source File

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:
318 KeyLength anyKeyLength() const
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
1062 CertificateInfoOrdered subject;
1063
1069 CertificateInfoOrdered issuer;
1070
1074 Constraints constraints;
1075
1079 QStringList policies;
1080
1086 QStringList crlLocations;
1087
1093 QStringList issuerLocations;
1094
1100 QStringList ocspLocations;
1101
1107 BigInteger serial;
1108
1113 bool isCA;
1114
1120 bool isSelfSigned;
1121
1125 int pathLimit;
1126
1130 QByteArray sig;
1131
1135 SignatureAlgorithm sigalgo;
1136
1142 QByteArray subjectId;
1143
1149 QByteArray issuerId;
1150
1156 QString challenge;
1157
1163 CertificateRequestFormat format;
1164 };
1165
1178 class QCA_EXPORT CRLContextProps
1179 {
1180 public:
1184 CertificateInfoOrdered issuer;
1185
1189 int number;
1190
1194 QDateTime thisUpdate;
1195
1199 QDateTime nextUpdate;
1200
1204 QList<CRLEntry> revoked;
1205
1209 QByteArray sig;
1210
1214 SignatureAlgorithm sigalgo;
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
1660 bool inKeyring;
1661
1666 bool isTrusted;
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:
2115 class SessionInfo
2116 {
2117 public:
2121 bool isCompressed;
2122
2126 TLS::Version version;
2127
2133 QString cipherSuite;
2134
2138 int cipherBits;
2139
2144 int cipherMaxBits;
2145
2150 TLSSessionContext *id;
2151 };
2152
2156 enum Result
2157 {
2158 Success,
2159 Error,
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 {
2493 Success,
2494 Error,
2495 Params,
2496 AuthCheck,
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:
2770 enum Operation
2771 {
2772 Encrypt,
2773 Decrypt,
2774 Sign,
2775 Verify,
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
QCA::ConvertResult
ConvertResult
Return value from a format conversion.
Definition: qca_publickey.h:117
QCA::CSRContext
X.509 certificate request provider.
Definition: qcaprovider.h:1327
QCA::CRLContextProps::issuer
CertificateInfoOrdered issuer
The issuer information of the CRL.
Definition: qcaprovider.h:1184
QCA::TLSContext::SessionInfo::isCompressed
bool isCompressed
True if the TLS connection is compressed, otherwise false.
Definition: qcaprovider.h:2121
QCA::CertContext
X.509 certificate provider.
Definition: qcaprovider.h:1234
QCA::PKeyContext::PKeyContext
PKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:833
QCA::PBEAlgorithm
PBEAlgorithm
Password-based encryption.
Definition: qca_publickey.h:101
QCA::TLS::Version
Version
Version of TLS or SSL.
Definition: qca_securelayer.h:305
QCA::DHContext
Diffie-Hellman provider.
Definition: qcaprovider.h:748
QCA::MessageContext::MessageContext
MessageContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2785
QCA::MACContext
Message authentication code provider.
Definition: qcaprovider.h:277
QCA::CertContextProps::end
QDateTime end
The time the certificate expires.
Definition: qcaprovider.h:1057
QCA::CertContextProps
X.509 certificate or certificate request properties.
Definition: qcaprovider.h:1035
QCA::SASL::Params
Parameter flags for the SASL authentication.
Definition: qca_securelayer.h:914
QCA::CSRContext::CSRContext
CSRContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1336
QCA::PrivateKey
Generic private key.
Definition: qca_publickey.h:826
QCA::CertContextProps::challenge
QString challenge
The SPKAC challenge value.
Definition: qcaprovider.h:1156
QCA::CertContextProps::subject
CertificateInfoOrdered subject
The subject information.
Definition: qcaprovider.h:1062
QCA::TLSContext::SessionInfo::cipherBits
int cipherBits
The bit size of the cipher used for this connection.
Definition: qcaprovider.h:2138
QCA::CRLContext::CRLContext
CRLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1417
QCA::KeyStoreListContext
KeyStore provider.
Definition: qcaprovider.h:1842
QCA::CertContextProps::issuer
CertificateInfoOrdered issuer
The issuer information.
Definition: qcaprovider.h:1069
QCA::CRLContextProps::number
int number
The CRL number, which increases at each update.
Definition: qcaprovider.h:1189
QCA::CRLContext
X.509 certificate revocation list provider.
Definition: qcaprovider.h:1408
QCA::PGPKeyContextProps
OpenPGP key properties.
Definition: qcaprovider.h:1620
QCA::CRLContextProps::thisUpdate
QDateTime thisUpdate
The time this CRL was created.
Definition: qcaprovider.h:1194
QCA::KeyStoreEntry::Type
Type
The type of entry in the KeyStore.
Definition: qca_keystore.h:146
QCA::KeyBundle
Certificate chain and private key pair.
Definition: qca_cert.h:2135
QCAPlugin
Provider plugin base class.
Definition: qcaprovider.h:82
QCA::DLGroupContext
Discrete logarithm provider.
Definition: qcaprovider.h:386
qca_cert.h
Header file for PGP key and X.509 certificate related classes.
QCA::CRLContextProps::sigalgo
SignatureAlgorithm sigalgo
The signature algorithm used by the issuer to sign the CRL.
Definition: qcaprovider.h:1214
QCA::TLSContext::Success
Operation completed.
Definition: qcaprovider.h:2158
QCA::CRLContextProps
X.509 certificate revocation list properties.
Definition: qcaprovider.h:1178
QCA::MessageContext
SecureMessage provider.
Definition: qcaprovider.h:2763
QCA::ValidateFlags
ValidateFlags
The conditions to validate for a certificate.
Definition: qca_cert.h:508
QCA::DSAContext::DSAContext
DSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:687
QCA::Validity
Validity
The validity (or otherwise) of a certificate.
Definition: qca_cert.h:489
QCA::CertContextProps::policies
QStringList policies
The policies.
Definition: qcaprovider.h:1079
qca_securelayer.h
Header file for SecureLayer and its subclasses.
QCA::Provider
Algorithm provider.
Definition: qca_core.h:722
QCA::CRLContextProps::issuerId
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1219
QCA::PGPKeyContextProps::inKeyring
bool inKeyring
True if this key is in a keyring (and thus usable), otherwise false.
Definition: qcaprovider.h:1660
QCA::RSAContext::RSAContext
RSAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:604
QCA::SASLContext::HostPort::addr
QString addr
The IP address.
Definition: qcaprovider.h:2480
QCA::HashContext
Hash provider.
Definition: qcaprovider.h:176
QCA::MessageContext::Encrypt
Encrypt operation.
Definition: qcaprovider.h:2772
qca_publickey.h
Header file for PublicKey and PrivateKey related classes.
QCA::RandomContext::RandomContext
RandomContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:156
QCA::KeyStoreEntryContext
KeyStoreEntry provider.
Definition: qcaprovider.h:1737
QCA::MessageContext::Decrypt
Decrypt (or Decrypt and Verify) operation.
Definition: qcaprovider.h:2773
QCA::PGPKeyContextProps::userIds
QStringList userIds
List of user id strings for the key, the first one being the primary user id.
Definition: qcaprovider.h:1632
QCA::CAContext::CAContext
CAContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1500
QCA::TLSSessionContext
TLS "session" provider.
Definition: qcaprovider.h:2080
QCA::PKCS12Context::PKCS12Context
PKCS12Context(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1577
QCA::TLSSessionContext::TLSSessionContext
TLSSessionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2089
QCA::PKCS12Context
PKCS#12 provider.
Definition: qcaprovider.h:1568
QCA::DHContext::DHContext
DHContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:757
QCA::CertCollectionContext::CertCollectionContext
CertCollectionContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1452
QCA::CertContextProps::isCA
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
QCA::TLSContext::SessionInfo
Information about an active TLS connection.
Definition: qcaprovider.h:2115
QCA::CertContextProps::crlLocations
QStringList crlLocations
A list of URIs for CRLs.
Definition: qcaprovider.h:1086
QCA::DSAContext
DSA provider.
Definition: qcaprovider.h:678
QCA::SecureMessage::Type
Type
The type of secure message.
Definition: qca_securemessage.h:327
QCA::PGPKeyContextProps::keyId
QString keyId
The key id.
Definition: qcaprovider.h:1626
QCA::CertCollectionContext
X.509 certificate collection provider.
Definition: qcaprovider.h:1443
QCA::SASLContext
SASL provider.
Definition: qcaprovider.h:2461
QCA::CRL
Certificate Revocation List
Definition: qca_cert.h:1702
QCA::SASLContext::HostPort
Convenience class to hold an IP address and an associated port.
Definition: qcaprovider.h:2474
QCA::SecureMessage::Error
Error
Errors for secure messages.
Definition: qca_securemessage.h:355
QCA::CertContextProps::issuerId
QByteArray issuerId
The issuer id.
Definition: qcaprovider.h:1149
QCA::SymmetricKey
Container for keys for symmetric encryption algorithms.
Definition: qca_core.h:1221
QCA::CRLContextProps::revoked
QList< CRLEntry > revoked
The revoked entries.
Definition: qcaprovider.h:1204
QCA::KeyLength
Simple container for acceptable key lengths.
Definition: qca_core.h:670
QCA::CertContext::CertContext
CertContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1243
qca_core.h
Header file for core QCA infrastructure.
QCA::TLSContext::SessionInfo::id
TLSSessionContext * id
Pointer to the id of this TLS session, for use with resuming.
Definition: qcaprovider.h:2150
QCA::TLSContext::Result
Result
Result of a TLS operation.
Definition: qcaprovider.h:2156
QCA::PKeyBase
Public key implementation provider base.
Definition: qcaprovider.h:451
QCA::SASLContext::Success
Operation completed.
Definition: qcaprovider.h:2493
QCA::SASLContext::HostPort::port
quint16 port
The port.
Definition: qcaprovider.h:2485
QCA::SignatureAlgorithm
SignatureAlgorithm
Signature algorithm variants.
Definition: qca_publickey.h:73
QCA::DLGroup
A discrete logarithm group.
Definition: qca_publickey.h:170
QCA::InfoContext::InfoContext
InfoContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:119
QCA::CertContextProps::format
CertificateRequestFormat format
The format used for the certificate request.
Definition: qcaprovider.h:1163
QCA::CertificateInfoOrdered
Ordered certificate properties type.
Definition: qca_cert.h:539
QCA::DLGroupSet
DLGroupSet
Well known discrete logarithm group sets.
Definition: qca_publickey.h:133
QCA::SASLContext::AuthCheck
Client login can be inspected (server only)
Definition: qcaprovider.h:2496
qca_keystore.h
Header file for classes that provide and manage keys.
QCA::CipherContext::CipherContext
CipherContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:229
QCA::SASLContext::Params
Parameters are needed to complete authentication.
Definition: qcaprovider.h:2495
QCA::InitializationVector
Container for initialisation vectors and nonces.
Definition: qca_core.h:1267
QCA::SecureMessage::Format
Format
Formats for secure messages.
Definition: qca_securemessage.h:346
QCA::TLSContext::TLSContext
TLSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2169
QCA::PGPKeyContextProps::isTrusted
bool isTrusted
True if this key is trusted (e.g.
Definition: qcaprovider.h:1666
QCA::Direction
Direction
Direction settings for symmetric algorithms.
Definition: qca_core.h:139
QCA::CRLContextProps::nextUpdate
QDateTime nextUpdate
The time this CRL expires, and the next CRL should be fetched.
Definition: qcaprovider.h:1199
QCA::PKeyContext
Public key container provider.
Definition: qcaprovider.h:824
QCA
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:47
QCA::CertBase::CertBase
CertBase(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:984
QCA::SASLContext::SASLContext
SASLContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:2505
QCA::CertContextProps::pathLimit
int pathLimit
The path limit.
Definition: qcaprovider.h:1125
QCA::BasicContext
Base class to use for primitive provider contexts.
Definition: qca_core.h:967
QCA::TLSContext::SessionInfo::cipherSuite
QString cipherSuite
The cipher suite being used for this connection.
Definition: qcaprovider.h:2133
QCA::KDFContext::KDFContext
KDFContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:348
QCA::HashContext::HashContext
HashContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:186
qca_securemessage.h
Header file for secure message (PGP, CMS) classes.
QCA::KeyStore::Type
Type
The type of keystore.
Definition: qca_keystore.h:423
QCA::SASL::AuthFlags
AuthFlags
Authentication requirement flag values.
Definition: qca_securelayer.h:875
QCA::MessageContext::Verify
Verify operation.
Definition: qcaprovider.h:2775
QCA::TLSContext::SessionInfo::cipherMaxBits
int cipherMaxBits
The maximum bit size possible of the cipher used for this connection.
Definition: qcaprovider.h:2144
QCA::MessageContext::Sign
Sign operation.
Definition: qcaprovider.h:2774
QCA::CertContextProps::isSelfSigned
bool isSelfSigned
True if the certificate is self-signed.
Definition: qcaprovider.h:1120
qca_basic.h
Header file for classes for cryptographic primitives (basic operations).
QCA::SignatureFormat
SignatureFormat
Signature formats (DSA only)
Definition: qca_publickey.h:91
QCA::CertContextProps::sigalgo
SignatureAlgorithm sigalgo
The signature algorithm used to create the signature.
Definition: qcaprovider.h:1135
QCA::CertContextProps::start
QDateTime start
The time the certificate becomes valid (often the time of create)
Definition: qcaprovider.h:1050
QCA::PKey::Type
Type
Types of public key cryptography keys supported by QCA.
Definition: qca_publickey.h:255
QCA::SecureArray
Secure array of bytes.
Definition: qca_tools.h:316
QCA::PGPKeyContext
OpenPGP key provider.
Definition: qcaprovider.h:1679
QCA::MACContext::MACContext
MACContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:286
QCA::SASLContext::Result
Result
Result of a SASL operation.
Definition: qcaprovider.h:2491
QCA::SASL::AuthCondition
AuthCondition
Possible authentication error states.
Definition: qca_securelayer.h:856
QCA::KeyStoreListContext::KeyStoreListContext
KeyStoreListContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1851
QCA::PGPKeyContextProps::isSecret
bool isSecret
True if this key is a secret key, otherwise false.
Definition: qcaprovider.h:1637
QCAPlugin::~QCAPlugin
virtual ~QCAPlugin()
Destructs the object.
Definition: qcaprovider.h:88
QCA::CertificateRequestFormat
CertificateRequestFormat
Certificate Request Format.
Definition: qca_cert.h:54
QCA::Constraints
QList< ConstraintType > Constraints
Certificate constraints type
Definition: qca_cert.h:582
QCA::CertificateOptions
Certificate options
Definition: qca_cert.h:601
QCA::TLSContext
TLS provider.
Definition: qcaprovider.h:2102
QCA::RSAContext
RSA provider.
Definition: qcaprovider.h:595
QCA::KDFContext
Key derivation function provider.
Definition: qcaprovider.h:338
QCA::EncryptionAlgorithm
EncryptionAlgorithm
Encryption algorithms.
Definition: qca_publickey.h:54
QCA::DLGroupContext::DLGroupContext
DLGroupContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:395
QCA::CRLContextProps::sig
QByteArray sig
The signature data of the CRL.
Definition: qcaprovider.h:1209
QCA::CertificateChain
A chain of related Certificates.
Definition: qca_cert.h:1207
QCA::TLSContext::Error
Operation failed.
Definition: qcaprovider.h:2159
QCA::MessageContext::Operation
Operation
The type of operation being performed.
Definition: qcaprovider.h:2770
QCA::PGPKeyContextProps::expirationDate
QDateTime expirationDate
The time the key expires.
Definition: qcaprovider.h:1647
QCA::CertContextProps::issuerLocations
QStringList issuerLocations
A list of URIs for issuer certificates.
Definition: qcaprovider.h:1093
QCA::CertContextProps::constraints
Constraints constraints
The constraints.
Definition: qcaprovider.h:1074
QCA::CertContextProps::subjectId
QByteArray subjectId
The subject id.
Definition: qcaprovider.h:1142
QCA::InfoContext
Extended provider information.
Definition: qcaprovider.h:110
QCA::CertContextProps::ocspLocations
QStringList ocspLocations
A list of URIs for OCSP services.
Definition: qcaprovider.h:1100
QCA::PGPKeyContextProps::fingerprint
QString fingerprint
The hex fingerprint of the key.
Definition: qcaprovider.h:1654
QCA::Certificate
Public Key (X.509) certificate.
Definition: qca_cert.h:848
QCA::SMSContext::SMSContext
SMSContext(Provider *p, const QString &type)
Standard constructor.
Definition: qcaprovider.h:2958
QCA::SMSContext
SecureMessageSystem provider.
Definition: qcaprovider.h:2948
QCA::CertContextProps::serial
BigInteger serial
The certificate serial number.
Definition: qcaprovider.h:1107
QCA::CertContextProps::version
int version
The X.509 certificate version, usually 3.
Definition: qcaprovider.h:1043
QCA::SecureMessage::SignMode
SignMode
The type of message signature.
Definition: qca_securemessage.h:336
QCA::SASLContext::Error
Operation failed.
Definition: qcaprovider.h:2494
QCA::PGPKeyContext::PGPKeyContext
PGPKeyContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1688
QCA::Provider::Context
Internal context class used for the plugin.
QCA::PGPKeyContextProps::creationDate
QDateTime creationDate
The time the key was created.
Definition: qcaprovider.h:1642
QCA::KeyStoreEntryContext::KeyStoreEntryContext
KeyStoreEntryContext(Provider *p)
Standard constructor.
Definition: qcaprovider.h:1746
QCA::UsageMode
UsageMode
Specify the intended usage of a certificate.
Definition: qca_cert.h:475
QCA::BigInteger
Arbitrary precision integer.
Definition: qca_tools.h:570
QCA::CertBase
X.509 certificate and certificate request provider base.
Definition: qcaprovider.h:974
QCA::CipherContext
Cipher provider.
Definition: qcaprovider.h:216
QCA::TLSContext::SessionInfo::version
TLS::Version version
The TLS protocol version being used for this connection.
Definition: qcaprovider.h:2126
QCA::PGPKey
Pretty Good Privacy key.
Definition: qca_cert.h:2360
QCA::CertificateCollection
Bundle of Certificates and CRLs.
Definition: qca_cert.h:1890
QCA::MACContext::anyKeyLength
KeyLength anyKeyLength() const
Returns a KeyLength that supports any length.
Definition: qcaprovider.h:318
QCA::RandomContext
Random provider.
Definition: qcaprovider.h:147
QCA::CAContext
X.509 certificate authority provider.
Definition: qcaprovider.h:1491
QList
QCA::MemoryRegion
Array of bytes that may be optionally secured.
Definition: qca_tools.h:90
QCA::CertContextProps::sig
QByteArray sig
The signature data.
Definition: qcaprovider.h:1130