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
00059
00060
00061
00062
00063 typedef int (*XrdCryptoKDFunLen_t)();
00064 typedef int (*XrdCryptoKDFun_t)(const char *pass, int plen,
00065 const char *salt, int slen,
00066 char *key, int klen);
00067
00068
00069 typedef bool (*XrdCryptoX509VerifyCert_t)(XrdCryptoX509 *c, XrdCryptoX509 *r);
00070
00071 typedef bool (*XrdCryptoX509VerifyChain_t)(XrdCryptoX509Chain *chain,
00072 int &errcode);
00073
00074 typedef XrdSutBucket *(*XrdCryptoX509ExportChain_t)(XrdCryptoX509Chain *, bool);
00075
00076
00077 typedef int (*XrdCryptoX509ChainToFile_t)(XrdCryptoX509Chain *, const char *);
00078
00079
00080 typedef int (*XrdCryptoX509ParseFile_t)(const char *fname,
00081 XrdCryptoX509Chain *);
00082
00083 typedef int (*XrdCryptoX509ParseBucket_t)(XrdSutBucket *,
00084 XrdCryptoX509Chain *);
00085
00086
00087 #define gsiProxyCertInfo_OLD_OID "1.3.6.1.4.1.3536.1.222"
00088 #define gsiProxyCertInfo_OID "1.3.6.1.5.5.7.1.14"
00089
00090 typedef bool (*XrdCryptoProxyCertInfo_t)(const void *, int &, bool *);
00091
00092 typedef void (*XrdCryptoSetPathLenConstraint_t)(void *, int);
00093
00094 typedef struct {
00095 int bits;
00096 int valid;
00097 int depthlen;
00098
00099
00100 } XrdProxyOpt_t;
00101 typedef int (*XrdCryptoX509CreateProxy_t)(const char *, const char *, XrdProxyOpt_t *,
00102 XrdCryptogsiX509Chain *, XrdCryptoRSA **, const char *);
00103
00104 typedef int (*XrdCryptoX509CreateProxyReq_t)(XrdCryptoX509 *,
00105 XrdCryptoX509Req **, XrdCryptoRSA **);
00106
00107 typedef int (*XrdCryptoX509SignProxyReq_t)(XrdCryptoX509 *, XrdCryptoRSA *,
00108 XrdCryptoX509Req *, XrdCryptoX509 **);
00109
00110 typedef int (*XrdCryptoX509CheckProxy3_t)(XrdCryptoX509 *, XrdOucString &);
00111
00112
00113 typedef int (*XrdCryptoX509GetVOMSAttr_t)(XrdCryptoX509 *, XrdOucString &);
00114
00115 class XrdCryptoFactory
00116 {
00117 private:
00118 char name[MAXFACTORYNAMELEN];
00119 int fID;
00120 public:
00121 XrdCryptoFactory(const char *n = "Unknown", int id = -1);
00122 virtual ~XrdCryptoFactory() { }
00123
00124
00125 virtual void SetTrace(kXR_int32 trace);
00126
00127
00128 char *Name() const { return (char *)&name[0]; }
00129 int ID() const { return fID; }
00130
00131
00132 static XrdCryptoFactory *GetCryptoFactory(const char *factoryname);
00133
00134
00135 virtual void Notify() { }
00136
00137
00138 virtual XrdCryptoKDFunLen_t KDFunLen();
00139 virtual XrdCryptoKDFun_t KDFun();
00140
00141
00142 virtual bool SupportedCipher(const char *t);
00143 virtual bool HasPaddingSupport();
00144 virtual XrdCryptoCipher *Cipher(const char *t, int l = 0);
00145 virtual XrdCryptoCipher *Cipher(const char *t, int l, const char *k,
00146 int liv, const char *iv);
00147 virtual XrdCryptoCipher *Cipher(XrdSutBucket *b);
00148 virtual XrdCryptoCipher *Cipher(int bits, char *pub, int lpub, const char *t = 0);
00149 virtual XrdCryptoCipher *Cipher(bool padded, int bits, char *pub, int lpub, const char *t);
00150 virtual XrdCryptoCipher *Cipher(const XrdCryptoCipher &c);
00151
00152
00153 virtual bool SupportedMsgDigest(const char *dgst);
00154 virtual XrdCryptoMsgDigest *MsgDigest(const char *dgst);
00155
00156
00157 virtual XrdCryptoRSA *RSA(int b = 0, int e = 0);
00158 virtual XrdCryptoRSA *RSA(const char *p, int l = 0);
00159 virtual XrdCryptoRSA *RSA(const XrdCryptoRSA &r);
00160
00161
00162 virtual XrdCryptoX509 *X509(const char *cf, const char *kf = 0);
00163 virtual XrdCryptoX509 *X509(XrdSutBucket *b);
00164
00165
00166 virtual XrdCryptoX509Crl *X509Crl(const char *crlfile, int opt = 0);
00167 virtual XrdCryptoX509Crl *X509Crl(XrdCryptoX509 *cacert);
00168
00169
00170 virtual XrdCryptoX509Req *X509Req(XrdSutBucket *bck);
00171
00172
00173 virtual XrdCryptoX509VerifyCert_t X509VerifyCert();
00174 virtual XrdCryptoX509VerifyChain_t X509VerifyChain();
00175 virtual XrdCryptoX509ParseFile_t X509ParseFile();
00176 virtual XrdCryptoX509ParseBucket_t X509ParseBucket();
00177 virtual XrdCryptoX509ExportChain_t X509ExportChain();
00178 virtual XrdCryptoX509ChainToFile_t X509ChainToFile();
00179
00180
00181 virtual XrdCryptoProxyCertInfo_t ProxyCertInfo();
00182 virtual XrdCryptoSetPathLenConstraint_t SetPathLenConstraint();
00183 virtual XrdCryptoX509CreateProxy_t X509CreateProxy();
00184 virtual XrdCryptoX509CreateProxyReq_t X509CreateProxyReq();
00185 virtual XrdCryptoX509SignProxyReq_t X509SignProxyReq();
00186 virtual XrdCryptoX509CheckProxy3_t X509CheckProxy3();
00187 virtual XrdCryptoX509GetVOMSAttr_t X509GetVOMSAttr();
00188
00189
00190 bool operator==(const XrdCryptoFactory factory);
00191 };
00192 #endif