File indexing completed on 2026-01-08 10:33:32
0001 #ifndef __CRYPTO_FACTORY_H__
0002 #define __CRYPTO_FACTORY_H__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #include "XrdCrypto/XrdCryptoAux.hh"
0040
0041 #define MAXFACTORYNAMELEN 10
0042
0043
0044
0045
0046
0047
0048 class XrdSutBucket;
0049 class XrdOucString;
0050 class XrdCryptoCipher;
0051 class XrdCryptoMsgDigest;
0052 class XrdCryptoRSA;
0053 class XrdCryptoX509;
0054 class XrdCryptoX509Chain;
0055 class XrdCryptogsiX509Chain;
0056 class XrdCryptoX509Crl;
0057 class XrdCryptoX509Req;
0058 class XrdTlsPeerCerts;
0059
0060
0061
0062
0063
0064 typedef int (*XrdCryptoKDFunLen_t)();
0065 typedef int (*XrdCryptoKDFun_t)(const char *pass, int plen,
0066 const char *salt, int slen,
0067 char *key, int klen);
0068
0069
0070 typedef bool (*XrdCryptoX509VerifyCert_t)(XrdCryptoX509 *c, XrdCryptoX509 *r);
0071
0072 typedef bool (*XrdCryptoX509VerifyChain_t)(XrdCryptoX509Chain *chain,
0073 int &errcode);
0074
0075 typedef XrdSutBucket *(*XrdCryptoX509ExportChain_t)(XrdCryptoX509Chain *, bool);
0076
0077
0078 typedef int (*XrdCryptoX509ChainToFile_t)(XrdCryptoX509Chain *, const char *);
0079
0080
0081 typedef int (*XrdCryptoX509ParseFile_t)(const char *fname,
0082 XrdCryptoX509Chain *, const char *);
0083
0084
0085 typedef int (*XrdCryptoX509ParseStack_t)(XrdTlsPeerCerts* pc,
0086 XrdCryptoX509Chain *c);
0087
0088
0089 typedef int (*XrdCryptoX509ParseBucket_t)(XrdSutBucket *,
0090 XrdCryptoX509Chain *);
0091
0092
0093 #define gsiProxyCertInfo_OLD_OID "1.3.6.1.4.1.3536.1.222"
0094 #define gsiProxyCertInfo_OID "1.3.6.1.5.5.7.1.14"
0095
0096 typedef bool (*XrdCryptoProxyCertInfo_t)(const void *, int &, bool *);
0097
0098 typedef void (*XrdCryptoSetPathLenConstraint_t)(void *, int);
0099
0100 typedef struct {
0101 int bits;
0102 int valid;
0103 int depthlen;
0104
0105
0106 } XrdProxyOpt_t;
0107 typedef int (*XrdCryptoX509CreateProxy_t)(const char *, const char *, XrdProxyOpt_t *,
0108 XrdCryptogsiX509Chain *, XrdCryptoRSA **, const char *);
0109
0110 typedef int (*XrdCryptoX509CreateProxyReq_t)(XrdCryptoX509 *,
0111 XrdCryptoX509Req **, XrdCryptoRSA **);
0112
0113 typedef int (*XrdCryptoX509SignProxyReq_t)(XrdCryptoX509 *, XrdCryptoRSA *,
0114 XrdCryptoX509Req *, XrdCryptoX509 **);
0115
0116 typedef int (*XrdCryptoX509CheckProxy3_t)(XrdCryptoX509 *, XrdOucString &);
0117
0118
0119 typedef int (*XrdCryptoX509GetVOMSAttr_t)(XrdCryptoX509 *, XrdOucString &);
0120
0121 class XrdCryptoFactory
0122 {
0123 private:
0124 char name[MAXFACTORYNAMELEN];
0125 int fID;
0126 public:
0127 XrdCryptoFactory(const char *n = "Unknown", int id = -1);
0128 virtual ~XrdCryptoFactory() { }
0129
0130
0131 virtual void SetTrace(kXR_int32 trace);
0132
0133
0134 char *Name() const { return (char *)&name[0]; }
0135 int ID() const { return fID; }
0136
0137
0138 static XrdCryptoFactory *GetCryptoFactory(const char *factoryname);
0139
0140
0141 virtual void Notify() { }
0142
0143
0144 virtual XrdCryptoKDFunLen_t KDFunLen();
0145 virtual XrdCryptoKDFun_t KDFun();
0146
0147
0148 virtual bool SupportedCipher(const char *t);
0149 virtual bool HasPaddingSupport();
0150 virtual XrdCryptoCipher *Cipher(const char *t, int l = 0);
0151 virtual XrdCryptoCipher *Cipher(const char *t, int l, const char *k,
0152 int liv, const char *iv);
0153 virtual XrdCryptoCipher *Cipher(XrdSutBucket *b);
0154 virtual XrdCryptoCipher *Cipher(int bits, char *pub, int lpub, const char *t = 0);
0155 virtual XrdCryptoCipher *Cipher(bool padded, int bits, char *pub, int lpub, const char *t);
0156 virtual XrdCryptoCipher *Cipher(const XrdCryptoCipher &c);
0157
0158
0159 virtual bool SupportedMsgDigest(const char *dgst);
0160 virtual XrdCryptoMsgDigest *MsgDigest(const char *dgst);
0161
0162
0163 virtual XrdCryptoRSA *RSA(int b = 0, int e = 0);
0164 virtual XrdCryptoRSA *RSA(const char *p, int l = 0);
0165 virtual XrdCryptoRSA *RSA(const XrdCryptoRSA &r);
0166
0167
0168 virtual XrdCryptoX509 *X509(const char *cf, const char *kf = 0);
0169 virtual XrdCryptoX509 *X509(XrdSutBucket *b);
0170
0171
0172 virtual XrdCryptoX509Crl *X509Crl(const char *crlfile, int opt = 0);
0173 virtual XrdCryptoX509Crl *X509Crl(XrdCryptoX509 *cacert);
0174
0175
0176 virtual XrdCryptoX509Req *X509Req(XrdSutBucket *bck);
0177
0178
0179 virtual XrdCryptoX509VerifyCert_t X509VerifyCert();
0180 virtual XrdCryptoX509VerifyChain_t X509VerifyChain();
0181 virtual XrdCryptoX509ParseFile_t X509ParseFile();
0182 virtual XrdCryptoX509ParseStack_t X509ParseStack();
0183 virtual XrdCryptoX509ParseBucket_t X509ParseBucket();
0184 virtual XrdCryptoX509ExportChain_t X509ExportChain();
0185 virtual XrdCryptoX509ChainToFile_t X509ChainToFile();
0186
0187
0188 virtual XrdCryptoProxyCertInfo_t ProxyCertInfo();
0189 virtual XrdCryptoSetPathLenConstraint_t SetPathLenConstraint();
0190 virtual XrdCryptoX509CreateProxy_t X509CreateProxy();
0191 virtual XrdCryptoX509CreateProxyReq_t X509CreateProxyReq();
0192 virtual XrdCryptoX509SignProxyReq_t X509SignProxyReq();
0193 virtual XrdCryptoX509CheckProxy3_t X509CheckProxy3();
0194 virtual XrdCryptoX509GetVOMSAttr_t X509GetVOMSAttr();
0195
0196
0197 bool operator==(const XrdCryptoFactory factory);
0198 };
0199 #endif