• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

qca

qca_core.h

Go to the documentation of this file.
00001 /*
00002  * qca_core.h - Qt Cryptographic Architecture
00003  * Copyright (C) 2003-2007  Justin Karneges <justin@affinix.com>
00004  * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301  USA
00020  *
00021  */
00022 
00033 #ifndef QCA_CORE_H
00034 #define QCA_CORE_H
00035 
00043 #define QCA_VERSION 0x020002
00044 
00045 #include <QString>
00046 #include <QStringList>
00047 #include <QList>
00048 #include <QSharedData>
00049 #include <QSharedDataPointer>
00050 #include "qca_export.h"
00051 #include "qca_support.h"
00052 #include "qca_tools.h"
00053 
00060 QCA_EXPORT int qcaVersion();
00061 
00065 namespace QCA {
00066 
00067 class Provider;
00068 class Random;
00069 class CertificateCollection;
00070 class Global;
00071 class KeyStore;
00072 class KeyStoreEntry;
00073 class KeyStoreInfo;
00074 class KeyStoreManager;
00075 class Logger;
00076 
00086 typedef QList<Provider*> ProviderList;
00087 
00102 enum MemoryMode
00103 {
00104     Practical, 
00105     Locking, 
00106     LockingKeepPrivileges 
00107 };
00108 
00115 enum Direction
00116 {
00117     Encode, 
00118     Decode  
00119 };
00120 
00126 QCA_EXPORT void init();
00127 
00135 QCA_EXPORT void init(MemoryMode m, int prealloc);
00136 
00144 QCA_EXPORT void deinit();
00145 
00151 QCA_EXPORT bool haveSecureMemory();
00152 
00161 QCA_EXPORT bool haveSecureRandom();
00162 
00194 QCA_EXPORT bool isSupported(const char *features, const QString &provider = QString());
00195 
00204 QCA_EXPORT bool isSupported(const QStringList &features, const QString &provider = QString());
00205 
00222 QCA_EXPORT QStringList supportedFeatures();
00223 
00241 QCA_EXPORT QStringList defaultFeatures();
00242 
00258 QCA_EXPORT bool insertProvider(Provider *p, int priority = 0);
00259 
00291 QCA_EXPORT void setProviderPriority(const QString &name, int priority);
00292 
00306 QCA_EXPORT int providerPriority(const QString &name);
00307 
00317 QCA_EXPORT ProviderList providers();
00318 
00324 QCA_EXPORT Provider *findProvider(const QString &name);
00325 
00329 QCA_EXPORT Provider *defaultProvider();
00330 
00334 QCA_EXPORT void scanForPlugins();
00335 
00339 QCA_EXPORT void unloadAllPlugins();
00340 
00344 QCA_EXPORT QString pluginDiagnosticText();
00345 
00349 QCA_EXPORT void clearPluginDiagnosticText();
00350 
00358 QCA_EXPORT void appendPluginDiagnosticText(const QString &text);
00359 
00368 QCA_EXPORT void setProperty(const QString &name, const QVariant &value);
00369 
00377 QCA_EXPORT QVariant getProperty(const QString &name);
00378 
00387 QCA_EXPORT void setProviderConfig(const QString &name, const QVariantMap &config);
00388 
00394 QCA_EXPORT QVariantMap getProviderConfig(const QString &name);
00395 
00401 QCA_EXPORT void saveProviderConfig(const QString &name);
00402 
00406 QCA_EXPORT QString globalRandomProvider();
00407 
00418 QCA_EXPORT void setGlobalRandomProvider(const QString &provider);
00419 
00426 QCA_EXPORT Logger *logger();
00427 
00438 #define QCA_logTextMessage(message, severity) \
00439     do { \
00440         register QCA::Logger::Severity s = severity; \
00441         register QCA::Logger *l = QCA::logger (); \
00442         if (s <= l->level ()) { \
00443             l->logTextMessage (message, s); \
00444         } \
00445     } while (false)
00446 
00457 #define QCA_logBinaryMessage(blob, severity) \
00458     do { \
00459         register QCA::Logger::Severity s = severity; \
00460         register QCA::Logger *l = QCA::logger (); \
00461         if (s <= l->level ()) { \
00462             l->logBinaryMessage (blob, s); \
00463         } \
00464     } while (false)
00465 
00474 QCA_EXPORT bool haveSystemStore();
00475 
00496 QCA_EXPORT CertificateCollection systemStore();
00497 
00505 QCA_EXPORT QString appName();
00506 
00516 QCA_EXPORT void setAppName(const QString &name);
00517 
00538 QCA_EXPORT QString arrayToHex(const QByteArray &array);
00539 
00565 QCA_EXPORT QByteArray hexToArray(const QString &hexString);
00566 
00578 class QCA_EXPORT Initializer
00579 {
00580 public:
00588     explicit Initializer(MemoryMode m = Practical, int prealloc = 64);
00589     ~Initializer();
00590 };
00591 
00616 class QCA_EXPORT KeyLength
00617 {
00618 public:
00627     KeyLength(int min, int max, int multiple)
00628         : _min( min ), _max(max), _multiple( multiple )
00629     { }
00630 
00634     int minimum() const { return _min; }
00635 
00639     int maximum() const { return _max; }
00640 
00647     int multiple() const { return _multiple; }
00648 
00649 private:
00650     const int _min, _max, _multiple;
00651 };
00652 
00668 class QCA_EXPORT Provider
00669 {
00670 public:
00671     virtual ~Provider();
00672 
00673     class Context;
00674 
00684     virtual void init();
00685 
00695     virtual void deinit();
00696 
00705     virtual int version() const;
00706 
00718     virtual int qcaVersion() const = 0;
00719 
00737     virtual QString name() const = 0;
00738 
00754     virtual QStringList features() const = 0;
00755 
00766     virtual QString credit() const;
00767 
00794     virtual Context *createContext(const QString &type) = 0;
00795 
00820     virtual QVariantMap defaultConfig() const;
00821 
00831     virtual void configChanged(const QVariantMap &config);
00832 };
00833 
00843 class QCA_EXPORT Provider::Context : public QObject
00844 {
00845     Q_OBJECT
00846 public:
00847     virtual ~Context();
00848 
00852     Provider *provider() const;
00853 
00857     QString type() const;
00858 
00862     virtual Context *clone() const = 0;
00863 
00872     bool sameProvider(const Context *c) const;
00873 
00874 protected:
00882     Context(Provider *parent, const QString &type);
00883 
00889     Context(const Context &from);
00890 
00891 private:
00892     // disable assignment
00893     Context & operator=(const Context &from);
00894 
00895     Provider *_provider;
00896     QString _type;
00897 };
00898 
00913 class QCA_EXPORT BasicContext : public Provider::Context
00914 {
00915     Q_OBJECT
00916 public:
00917     ~BasicContext();
00918 
00919 protected:
00927     BasicContext(Provider *parent, const QString &type);
00928 
00934     BasicContext(const BasicContext &from);
00935 
00936 private:
00937     // disable assignment
00938     BasicContext & operator=(const BasicContext &from);
00939 };
00940 
00955 class QCA_EXPORT BufferedComputation
00956 {
00957 public:
00958     virtual ~BufferedComputation();
00959 
00963     virtual void clear() = 0;
00964 
00971     virtual void update(const MemoryRegion &a) = 0;
00972 
00976     virtual MemoryRegion final() = 0;
00977 
00990     MemoryRegion process(const MemoryRegion &a);
00991 };
00992 
01011 class QCA_EXPORT Filter
01012 {
01013 public:
01014     virtual ~Filter();
01015 
01019     virtual void clear() = 0;
01020 
01027     virtual MemoryRegion update(const MemoryRegion &a) = 0;
01028 
01033     virtual MemoryRegion final() = 0;
01034 
01040     virtual bool ok() const = 0;
01041 
01054     MemoryRegion process(const MemoryRegion &a);
01055 };
01056 
01067 class QCA_EXPORT Algorithm
01068 {
01069 public:
01075     Algorithm(const Algorithm &from);
01076 
01077     virtual ~Algorithm();
01078 
01084     Algorithm & operator=(const Algorithm &from);
01085 
01089     QString type() const;
01090 
01097     Provider *provider() const;
01098 
01099     // Note: The next five functions are not public!
01100 
01106     Provider::Context *context();
01107 
01113     const Provider::Context *context() const;
01114 
01122     void change(Provider::Context *c);
01123 
01132     void change(const QString &type, const QString &provider);
01133 
01139     Provider::Context *takeContext();
01140 
01141 protected:
01145     Algorithm();
01146 
01153     Algorithm(const QString &type, const QString &provider);
01154 
01155 private:
01156     class Private;
01157     QSharedDataPointer<Private> d;
01158 };
01159 
01167 class QCA_EXPORT SymmetricKey : public SecureArray
01168 {
01169 public:
01173     SymmetricKey();
01174 
01182     SymmetricKey(int size);
01183 
01189     SymmetricKey(const SecureArray &a);
01190 
01196     SymmetricKey(const QByteArray &a);
01197 
01203     bool isWeakDESKey();
01204 };
01205 
01213 class QCA_EXPORT InitializationVector : public SecureArray
01214 {
01215 public:
01219     InitializationVector();
01220 
01226     InitializationVector(int size);
01227 
01233     InitializationVector(const SecureArray &a);
01234 
01240     InitializationVector(const QByteArray &a);
01241 };
01242 
01257 class QCA_EXPORT Event
01258 {
01259 public:
01265     enum Type
01266     {
01267         Password,   
01268         Token       
01269     };
01270 
01283     enum Source
01284     {
01285         KeyStore,   
01286         Data        
01287     };
01288 
01297     enum PasswordStyle
01298     {
01299         StylePassword,   
01300         StylePassphrase, 
01301         StylePIN         
01302     };
01303 
01307     Event();
01308 
01314     Event(const Event &from);
01315 
01319     ~Event();
01320 
01326     Event & operator=(const Event &from);
01327 
01331     bool isNull() const;
01332 
01336     Type type() const;
01337 
01341     Source source() const;
01342 
01350     PasswordStyle passwordStyle() const;
01351 
01357     KeyStoreInfo keyStoreInfo() const;
01358 
01364     KeyStoreEntry keyStoreEntry() const;
01365 
01372     QString fileName() const;
01373 
01377     void *ptr() const;
01378 
01392     void setPasswordKeyStore(PasswordStyle pstyle, const KeyStoreInfo &keyStoreInfo, const KeyStoreEntry &keyStoreEntry, void *ptr);
01393 
01405     void setPasswordData(PasswordStyle pstyle, const QString &fileName, void *ptr);
01406 
01418     void setToken(const KeyStoreInfo &keyStoreInfo, const KeyStoreEntry &keyStoreEntry, void *ptr);
01419 
01420 private:
01421     class Private;
01422     QSharedDataPointer<Private> d;
01423 };
01424 
01442 class QCA_EXPORT EventHandler : public QObject
01443 {
01444     Q_OBJECT
01445 public:
01451     EventHandler(QObject *parent = 0);
01452     ~EventHandler();
01453 
01459     void start();
01460 
01471     void submitPassword(int id, const SecureArray &password);
01472 
01482     void tokenOkay(int id);
01483 
01493     void reject(int id);
01494 
01495 Q_SIGNALS:
01505     void eventReady(int id, const QCA::Event &context);
01506 
01507 private:
01508     Q_DISABLE_COPY(EventHandler)
01509 
01510     class Private;
01511     friend class Private;
01512     Private *d;
01513 };
01514 
01524 class QCA_EXPORT PasswordAsker : public QObject
01525 {
01526     Q_OBJECT
01527 public:
01533     PasswordAsker(QObject *parent = 0);
01534     ~PasswordAsker();
01535 
01547     void ask(Event::PasswordStyle pstyle, const KeyStoreInfo &keyStoreInfo, const KeyStoreEntry &keyStoreEntry, void *ptr);
01548 
01558     void ask(Event::PasswordStyle pstyle, const QString &fileName, void *ptr);
01559 
01563     void cancel();
01564 
01572     void waitForResponse();
01573 
01582     bool accepted() const;
01583 
01588     SecureArray password() const;
01589 
01590 Q_SIGNALS:
01597     void responseReady();
01598 
01599 private:
01600     Q_DISABLE_COPY(PasswordAsker)
01601 
01602     class Private;
01603     friend class Private;
01604     Private *d;
01605 };
01606 
01616 class QCA_EXPORT TokenAsker : public QObject
01617 {
01618     Q_OBJECT
01619 public:
01625     TokenAsker(QObject *parent = 0);
01626     ~TokenAsker();
01627 
01637     void ask(const KeyStoreInfo &keyStoreInfo, const KeyStoreEntry &keyStoreEntry, void *ptr);
01638 
01642     void cancel();
01643 
01650     void waitForResponse();
01651 
01657     bool accepted() const;
01658 
01659 Q_SIGNALS:
01666     void responseReady();
01667 
01668 private:
01669     Q_DISABLE_COPY(TokenAsker)
01670 
01671     class Private;
01672     friend class Private;
01673     Private *d;
01674 };
01675 
01676 }
01677 
01678 #endif

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal