00001 #ifndef __CRYPTO_FACTORY_H__
00002 #define __CRYPTO_FACTORY_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "XrdCrypto/XrdCryptoAux.hh"
00040
00041 #define MAXFACTORYNAMELEN 10
00042
00043
00044
00045
00046
00047
00048 class XrdSutBucket;
00049 class XrdOucString;
00050 class XrdCryptoCipher;
00051 class XrdCryptoMsgDigest;
00052 class XrdCryptoRSA;
00053 class XrdCryptoX509;
00054 class XrdCryptoX509Chain;
00055 class XrdCryptogsiX509Chain;
00056 class XrdCryptoX509Crl;
00057 class XrdCryptoX509Req;
00058 class XrdTlsPeerCerts;
00059
00060
00061
00062
00063
00064 typedef int (*XrdCryptoKDFunLen_t)();
00065 typedef int (*XrdCryptoKDFun_t)(const char *pass, int plen,
00066 const char *salt, int slen,
00067 char *key, int klen);
00068
00069
00070 typedef bool (*XrdCryptoX509VerifyCert_t)(XrdCryptoX509 *c, XrdCryptoX509 *r);
00071
00072 typedef bool (*XrdCryptoX509VerifyChain_t)(XrdCryptoX509Chain *chain,
00073 int &errcode);
00074
00075 typedef XrdSutBucket *(*XrdCryptoX509ExportChain_t)(XrdCryptoX509Chain *, bool);
00076
00077
00078 typedef int (*XrdCryptoX509ChainToFile_t)(XrdCryptoX509Chain *, const char *);
00079
00080
00081 typedef int (*XrdCryptoX509ParseFile_t)(const char *fname,
00082 XrdCryptoX509Chain *);
00083
00084
00085 typedef int (*XrdCryptoX509ParseStack_t)(void* ssl_conn,
00086 XrdCryptoX509Chain *c);
00087
00088
00089 typedef int (*XrdCryptoX509ParseBucket_t)(XrdSutBucket *,
00090 XrdCryptoX509Chain *);
00091
00092
00093 #define gsiProxyCertInfo_OLD_OID "1.3.6.1.4.1.3536.1.222"
00094 #define gsiProxyCertInfo_OID "1.3.6.1.5.5.7.1.14"
00095
00096 typedef bool (*XrdCryptoProxyCertInfo_t)(const void *, int &, bool *);
00097
00098 typedef void (*XrdCryptoSetPathLenConstraint_t)(void *, int);
00099
00100 typedef struct {
00101 int bits;
00102 int valid;
00103 int depthlen;
00104
00105
00106 } XrdProxyOpt_t;
00107 typedef int (*XrdCryptoX509CreateProxy_t)(const char *, const char *, XrdProxyOpt_t *,
00108 XrdCryptogsiX509Chain *, XrdCryptoRSA **, const char *);
00109
00110 typedef int (*XrdCryptoX509CreateProxyReq_t)(XrdCryptoX509 *,
00111 XrdCryptoX509Req **, XrdCryptoRSA **);
00112
00113 typedef int (*XrdCryptoX509SignProxyReq_t)(XrdCryptoX509 *, XrdCryptoRSA *,
00114 XrdCryptoX509Req *, XrdCryptoX509 **);
00115
00116 typedef int (*XrdCryptoX509CheckProxy3_t)(XrdCryptoX509 *, XrdOucString &);
00117
00118
00119 typedef int (*XrdCryptoX509GetVOMSAttr_t)(XrdCryptoX509 *, XrdOucString &);
00120
00121 class XrdCryptoFactory
00122 {
00123 private:
00124 char name[MAXFACTORYNAMELEN];
00125 int fID;
00126 public:
00127 XrdCryptoFactory(const char *n = "Unknown", int id = -1);
00128 virtual ~XrdCryptoFactory() { }
00129
00130
00131 virtual void SetTrace(kXR_int32 trace);
00132
00133
00134 char *Name() const { return (char *)&name[0]; }
00135 int ID() const { return fID; }
00136
00137
00138 static XrdCryptoFactory *GetCryptoFactory(const char *factoryname);
00139
00140
00141 virtual void Notify() { }
00142
00143
00144 virtual XrdCryptoKDFunLen_t KDFunLen();
00145 virtual XrdCryptoKDFun_t KDFun();
00146
00147
00148 virtual bool SupportedCipher(const char *t);
00149 virtual bool HasPaddingSupport();
00150 virtual XrdCryptoCipher *Cipher(const char *t, int l = 0);
00151 virtual XrdCryptoCipher *Cipher(const char *t, int l, const char *k,
00152 int liv, const char *iv);
00153 virtual XrdCryptoCipher *Cipher(XrdSutBucket *b);
00154 virtual XrdCryptoCipher *Cipher(int bits, char *pub, int lpub, const char *t = 0);
00155 virtual XrdCryptoCipher *Cipher(bool padded, int bits, char *pub, int lpub, const char *t);
00156 virtual XrdCryptoCipher *Cipher(const XrdCryptoCipher &c);
00157
00158
00159 virtual bool SupportedMsgDigest(const char *dgst);
00160 virtual XrdCryptoMsgDigest *MsgDigest(const char *dgst);
00161
00162
00163 virtual XrdCryptoRSA *RSA(int b = 0, int e = 0);
00164 virtual XrdCryptoRSA *RSA(const char *p, int l = 0);
00165 virtual XrdCryptoRSA *RSA(const XrdCryptoRSA &r);
00166
00167
00168 virtual XrdCryptoX509 *X509(const char *cf, const char *kf = 0);
00169 virtual XrdCryptoX509 *X509(XrdSutBucket *b);
00170
00171
00172 virtual XrdCryptoX509Crl *X509Crl(const char *crlfile, int opt = 0);
00173 virtual XrdCryptoX509Crl *X509Crl(XrdCryptoX509 *cacert);
00174
00175
00176 virtual XrdCryptoX509Req *X509Req(XrdSutBucket *bck);
00177
00178
00179 virtual XrdCryptoX509VerifyCert_t X509VerifyCert();
00180 virtual XrdCryptoX509VerifyChain_t X509VerifyChain();
00181 virtual XrdCryptoX509ParseFile_t X509ParseFile();
00182 virtual XrdCryptoX509ParseStack_t X509ParseStack();
00183 virtual XrdCryptoX509ParseBucket_t X509ParseBucket();
00184 virtual XrdCryptoX509ExportChain_t X509ExportChain();
00185 virtual XrdCryptoX509ChainToFile_t X509ChainToFile();
00186
00187
00188 virtual XrdCryptoProxyCertInfo_t ProxyCertInfo();
00189 virtual XrdCryptoSetPathLenConstraint_t SetPathLenConstraint();
00190 virtual XrdCryptoX509CreateProxy_t X509CreateProxy();
00191 virtual XrdCryptoX509CreateProxyReq_t X509CreateProxyReq();
00192 virtual XrdCryptoX509SignProxyReq_t X509SignProxyReq();
00193 virtual XrdCryptoX509CheckProxy3_t X509CheckProxy3();
00194 virtual XrdCryptoX509GetVOMSAttr_t X509GetVOMSAttr();
00195
00196
00197 bool operator==(const XrdCryptoFactory factory);
00198 };
00199 #endif