|
Line 0
Link Here
|
|
|
1 |
/* |
| 2 |
* qcaprovider.h - QCA Plugin API |
| 3 |
* Copyright (C) 2003 Justin Karneges |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef QCAPROVIDER_H |
| 22 |
#define QCAPROVIDER_H |
| 23 |
|
| 24 |
#include<tqglobal.h> |
| 25 |
#include<tqstring.h> |
| 26 |
#include<tqdatetime.h> |
| 27 |
#include<tqobject.h> |
| 28 |
#include<tqhostaddress.h> |
| 29 |
#include"qca.h" |
| 30 |
|
| 31 |
#define QCA_PLUGIN_VERSION 1 |
| 32 |
|
| 33 |
class QCAProvider |
| 34 |
{ |
| 35 |
public: |
| 36 |
QCAProvider() {} |
| 37 |
virtual ~QCAProvider() {} |
| 38 |
|
| 39 |
virtual void init()=0; |
| 40 |
virtual int qcaVersion() const=0; |
| 41 |
virtual int capabilities() const=0; |
| 42 |
virtual void *context(int cap)=0; |
| 43 |
}; |
| 44 |
|
| 45 |
class QCA_HashContext |
| 46 |
{ |
| 47 |
public: |
| 48 |
virtual ~QCA_HashContext() {} |
| 49 |
|
| 50 |
virtual QCA_HashContext *clone()=0; |
| 51 |
virtual void reset()=0; |
| 52 |
virtual void update(const char *in, unsigned int len)=0; |
| 53 |
virtual void final(TQByteArray *out)=0; |
| 54 |
}; |
| 55 |
|
| 56 |
class QCA_CipherContext |
| 57 |
{ |
| 58 |
public: |
| 59 |
virtual ~QCA_CipherContext() {} |
| 60 |
|
| 61 |
virtual QCA_CipherContext *clone()=0; |
| 62 |
virtual int keySize()=0; |
| 63 |
virtual int blockSize()=0; |
| 64 |
virtual bool generateKey(char *out, int keysize=-1)=0; |
| 65 |
virtual bool generateIV(char *out)=0; |
| 66 |
|
| 67 |
virtual bool setup(int dir, int mode, const char *key, int keysize, const char *iv, bool pad)=0; |
| 68 |
virtual bool update(const char *in, unsigned int len)=0; |
| 69 |
virtual bool final(TQByteArray *out)=0; |
| 70 |
}; |
| 71 |
|
| 72 |
class QCA_RSAKeyContext |
| 73 |
{ |
| 74 |
public: |
| 75 |
virtual ~QCA_RSAKeyContext() {} |
| 76 |
|
| 77 |
virtual QCA_RSAKeyContext *clone() const=0; |
| 78 |
virtual bool isNull() const=0; |
| 79 |
virtual bool havePublic() const=0; |
| 80 |
virtual bool havePrivate() const=0; |
| 81 |
virtual bool createFromDER(const char *in, unsigned int len)=0; |
| 82 |
virtual bool createFromPEM(const char *in, unsigned int len)=0; |
| 83 |
virtual bool createFromNative(void *in)=0; |
| 84 |
virtual bool generate(unsigned int bits)=0; |
| 85 |
virtual bool toDER(TQByteArray *out, bool publicOnly)=0; |
| 86 |
virtual bool toPEM(TQByteArray *out, bool publicOnly)=0; |
| 87 |
|
| 88 |
virtual bool encrypt(const TQByteArray &in, TQByteArray *out, bool oaep)=0; |
| 89 |
virtual bool decrypt(const TQByteArray &in, TQByteArray *out, bool oaep)=0; |
| 90 |
}; |
| 91 |
|
| 92 |
struct QCA_CertProperty |
| 93 |
{ |
| 94 |
TQString var; |
| 95 |
TQString val; |
| 96 |
}; |
| 97 |
|
| 98 |
class QCA_CertContext |
| 99 |
{ |
| 100 |
public: |
| 101 |
virtual ~QCA_CertContext() {} |
| 102 |
|
| 103 |
virtual QCA_CertContext *clone() const=0; |
| 104 |
virtual bool isNull() const=0; |
| 105 |
virtual bool createFromDER(const char *in, unsigned int len)=0; |
| 106 |
virtual bool createFromPEM(const char *in, unsigned int len)=0; |
| 107 |
virtual bool toDER(TQByteArray *out)=0; |
| 108 |
virtual bool toPEM(TQByteArray *out)=0; |
| 109 |
|
| 110 |
virtual TQString serialNumber() const=0; |
| 111 |
virtual TQString subjectString() const=0; |
| 112 |
virtual TQString issuerString() const=0; |
| 113 |
virtual TQValueList<QCA_CertProperty> subject() const=0; |
| 114 |
virtual TQValueList<QCA_CertProperty> issuer() const=0; |
| 115 |
virtual TQDateTime notBefore() const=0; |
| 116 |
virtual TQDateTime notAfter() const=0; |
| 117 |
virtual bool matchesAddress(const TQString &realHost) const=0; |
| 118 |
}; |
| 119 |
|
| 120 |
class QCA_TLSContext |
| 121 |
{ |
| 122 |
public: |
| 123 |
enum Result { Success, Error, Continue }; |
| 124 |
virtual ~QCA_TLSContext() {} |
| 125 |
|
| 126 |
virtual void reset()=0; |
| 127 |
virtual bool startClient(const TQPtrList<QCA_CertContext> &store, const QCA_CertContext &cert, const QCA_RSAKeyContext &key)=0; |
| 128 |
virtual bool startServer(const TQPtrList<QCA_CertContext> &store, const QCA_CertContext &cert, const QCA_RSAKeyContext &key)=0; |
| 129 |
|
| 130 |
virtual int handshake(const TQByteArray &in, TQByteArray *out)=0; |
| 131 |
virtual int shutdown(const TQByteArray &in, TQByteArray *out)=0; |
| 132 |
virtual bool encode(const TQByteArray &plain, TQByteArray *to_net, int *encoded)=0; |
| 133 |
virtual bool decode(const TQByteArray &from_net, TQByteArray *plain, TQByteArray *to_net)=0; |
| 134 |
virtual bool eof() const=0; |
| 135 |
virtual TQByteArray unprocessed()=0; |
| 136 |
|
| 137 |
virtual QCA_CertContext *peerCertificate() const=0; |
| 138 |
virtual int validityResult() const=0; |
| 139 |
}; |
| 140 |
|
| 141 |
struct QCA_SASLHostPort |
| 142 |
{ |
| 143 |
TQHostAddress addr; |
| 144 |
TQ_UINT16 port; |
| 145 |
}; |
| 146 |
|
| 147 |
struct QCA_SASLNeedParams |
| 148 |
{ |
| 149 |
bool user, authzid, pass, realm; |
| 150 |
}; |
| 151 |
|
| 152 |
class QCA_SASLContext |
| 153 |
{ |
| 154 |
public: |
| 155 |
enum Result { Success, Error, NeedParams, AuthCheck, Continue }; |
| 156 |
virtual ~QCA_SASLContext() {} |
| 157 |
|
| 158 |
// common |
| 159 |
virtual void reset()=0; |
| 160 |
virtual void setCoreProps(const TQString &service, const TQString &host, QCA_SASLHostPort *local, QCA_SASLHostPort *remote)=0; |
| 161 |
virtual void setSecurityProps(bool noPlain, bool noActive, bool noDict, bool noAnon, bool reqForward, bool reqCreds, bool reqMutual, int ssfMin, int ssfMax, const TQString &_ext_authid, int _ext_ssf)=0; |
| 162 |
virtual int security() const=0; |
| 163 |
virtual int errorCond() const=0; |
| 164 |
|
| 165 |
// init / first step |
| 166 |
virtual bool clientStart(const TQStringList &mechlist)=0; |
| 167 |
virtual int clientFirstStep(bool allowClientSendFirst)=0; |
| 168 |
virtual bool serverStart(const TQString &realm, TQStringList *mechlist, const TQString &name)=0; |
| 169 |
virtual int serverFirstStep(const TQString &mech, const TQByteArray *in)=0; |
| 170 |
|
| 171 |
// get / set params |
| 172 |
virtual QCA_SASLNeedParams clientParamsNeeded() const=0; |
| 173 |
virtual void setClientParams(const TQString *user, const TQString *authzid, const TQString *pass, const TQString *realm)=0; |
| 174 |
virtual TQString username() const=0; |
| 175 |
virtual TQString authzid() const=0; |
| 176 |
|
| 177 |
// continue steps |
| 178 |
virtual int nextStep(const TQByteArray &in)=0; |
| 179 |
virtual int tryAgain()=0; |
| 180 |
|
| 181 |
// results |
| 182 |
virtual TQString mech() const=0; |
| 183 |
virtual const TQByteArray *clientInit() const=0; |
| 184 |
virtual TQByteArray result() const=0; |
| 185 |
|
| 186 |
// security layer |
| 187 |
virtual bool encode(const TQByteArray &in, TQByteArray *out)=0; |
| 188 |
virtual bool decode(const TQByteArray &in, TQByteArray *out)=0; |
| 189 |
}; |
| 190 |
|
| 191 |
#endif |