Loading...
Searching...
No Matches
XrdCryptoFactory.hh
Go to the documentation of this file.
#ifndef __CRYPTO_FACTORY_H__
#define __CRYPTO_FACTORY_H__
/******************************************************************************/
/* */
/* X r d C r y p t o F a c t o r y . h h */
/* */
/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
/* Produced by Gerri Ganis for CERN */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
/* ************************************************************************** */
/* */
/* Abstract interface for a crypto factory */
/* Allows to plug-in modules based on different crypto implementation */
/* (OpenSSL, Botan, ...) */
/* */
/* ************************************************************************** */
#include "XrdCrypto/XrdCryptoAux.hh"
#define MAXFACTORYNAMELEN 10
// ---------------------------------------------------------------------------//
//
// Abstract Crypto Factory
//
// ---------------------------------------------------------------------------//
class XrdSutBucket;
class XrdOucString;
class XrdCryptoCipher;
class XrdCryptoMsgDigest;
class XrdCryptoRSA;
class XrdCryptoX509;
class XrdCryptoX509Chain;
class XrdCryptogsiX509Chain;
class XrdCryptoX509Crl;
class XrdCryptoX509Req;
class XrdTlsPeerCerts;
//
// Prototypes for some Utility Functions
// Key derivation function
typedef int (*XrdCryptoKDFunLen_t)();
typedef int (*XrdCryptoKDFun_t)(const char *pass, int plen,
const char *salt, int slen,
char *key, int klen);
// X509 manipulation: certificate verification
typedef bool (*XrdCryptoX509VerifyCert_t)(XrdCryptoX509 *c, XrdCryptoX509 *r);
// chain verification
typedef bool (*XrdCryptoX509VerifyChain_t)(XrdCryptoX509Chain *chain,
int &errcode);
// chain export
typedef XrdSutBucket *(*XrdCryptoX509ExportChain_t)(XrdCryptoX509Chain *, bool);
// chain to file
typedef int (*XrdCryptoX509ChainToFile_t)(XrdCryptoX509Chain *, const char *);
// certificates from file parsing
typedef int (*XrdCryptoX509ParseFile_t)(const char *fname,
XrdCryptoX509Chain *, const char *);
// certificates from STACK_OF(X509*)
typedef int (*XrdCryptoX509ParseStack_t)(XrdTlsPeerCerts* pc,
XrdCryptoX509Chain *c);
// certificates from bucket parsing
typedef int (*XrdCryptoX509ParseBucket_t)(XrdSutBucket *,
XrdCryptoX509Chain *);
// Proxies
// The OID of the extension
#define gsiProxyCertInfo_OLD_OID "1.3.6.1.4.1.3536.1.222"
#define gsiProxyCertInfo_OID "1.3.6.1.5.5.7.1.14"
// check presence of proxyCertInfo extension (RFC 3820)
typedef bool (*XrdCryptoProxyCertInfo_t)(const void *, int &, bool *);
// set path length constraint
typedef void (*XrdCryptoSetPathLenConstraint_t)(void *, int);
// create a proxy certificate
typedef struct {
int bits; // Number of bits in the RSA key [2048]
int valid; // Duration validity in secs [43200 (12 hours)]
int depthlen; // Maximum depth of the path of proxy certificates
// that can signed by this proxy certificates
// [-1 (== unlimited)]
} XrdProxyOpt_t;
typedef int (*XrdCryptoX509CreateProxy_t)(const char *, const char *, XrdProxyOpt_t *,
XrdCryptogsiX509Chain *, XrdCryptoRSA **, const char *);
// create a proxy certificate request
typedef int (*XrdCryptoX509CreateProxyReq_t)(XrdCryptoX509 *,
XrdCryptoX509Req **, XrdCryptoRSA **);
// sign a proxy certificate request
typedef int (*XrdCryptoX509SignProxyReq_t)(XrdCryptoX509 *, XrdCryptoRSA *,
XrdCryptoX509Req *, XrdCryptoX509 **);
// check consistency of a GSI 3 compliant proxy
typedef int (*XrdCryptoX509CheckProxy3_t)(XrdCryptoX509 *, XrdOucString &);
// get VOMS attributes
typedef int (*XrdCryptoX509GetVOMSAttr_t)(XrdCryptoX509 *, XrdOucString &);
class XrdCryptoFactory
{
private:
char name[MAXFACTORYNAMELEN];
int fID;
public:
XrdCryptoFactory(const char *n = "Unknown", int id = -1);
virtual ~XrdCryptoFactory() { }
// Set trace flags
virtual void SetTrace(kXR_int32 trace);
// Get the factory name
char *Name() const { return (char *)&name[0]; }
int ID() const { return fID; }
// Get the right factory
static XrdCryptoFactory *GetCryptoFactory(const char *factoryname);
// Any possible notification
virtual void Notify() { }
// Hook to a Key Derivation Function (PBKDF2 when possible)
virtual XrdCryptoKDFunLen_t KDFunLen(); // Length of buffer
virtual XrdCryptoKDFun_t KDFun();
// Cipher constructors
virtual bool SupportedCipher(const char *t);
virtual bool HasPaddingSupport();
virtual XrdCryptoCipher *Cipher(const char *t, int l = 0);
virtual XrdCryptoCipher *Cipher(const char *t, int l, const char *k,
int liv, const char *iv);
virtual XrdCryptoCipher *Cipher(XrdSutBucket *b);
virtual XrdCryptoCipher *Cipher(int bits, char *pub, int lpub, const char *t = 0);
virtual XrdCryptoCipher *Cipher(bool padded, int bits, char *pub, int lpub, const char *t);
virtual XrdCryptoCipher *Cipher(const XrdCryptoCipher &c);
// MsgDigest constructors
virtual bool SupportedMsgDigest(const char *dgst);
virtual XrdCryptoMsgDigest *MsgDigest(const char *dgst);
// RSA constructors
virtual XrdCryptoRSA *RSA(int b = 0, int e = 0);
virtual XrdCryptoRSA *RSA(const char *p, int l = 0);
virtual XrdCryptoRSA *RSA(const XrdCryptoRSA &r);
// X509 constructors
virtual XrdCryptoX509 *X509(const char *cf, const char *kf = 0);
virtual XrdCryptoX509 *X509(XrdSutBucket *b);
// X509 CRL constructors
virtual XrdCryptoX509Crl *X509Crl(const char *crlfile, int opt = 0);
virtual XrdCryptoX509Crl *X509Crl(XrdCryptoX509 *cacert);
// X509 REQ constructors
virtual XrdCryptoX509Req *X509Req(XrdSutBucket *bck);
// Hooks to handle X509 certificates
virtual XrdCryptoX509VerifyCert_t X509VerifyCert();
virtual XrdCryptoX509VerifyChain_t X509VerifyChain();
virtual XrdCryptoX509ParseFile_t X509ParseFile();
virtual XrdCryptoX509ParseStack_t X509ParseStack();
virtual XrdCryptoX509ParseBucket_t X509ParseBucket();
virtual XrdCryptoX509ExportChain_t X509ExportChain();
virtual XrdCryptoX509ChainToFile_t X509ChainToFile();
// Hooks to handle X509 proxy certificates
virtual XrdCryptoProxyCertInfo_t ProxyCertInfo();
virtual XrdCryptoSetPathLenConstraint_t SetPathLenConstraint();
virtual XrdCryptoX509CreateProxy_t X509CreateProxy();
virtual XrdCryptoX509CreateProxyReq_t X509CreateProxyReq();
virtual XrdCryptoX509SignProxyReq_t X509SignProxyReq();
virtual XrdCryptoX509CheckProxy3_t X509CheckProxy3();
virtual XrdCryptoX509GetVOMSAttr_t X509GetVOMSAttr();
// Equality operator
bool operator==(const XrdCryptoFactory factory);
};
#endif
kXR_int32
int kXR_int32
Definition XPtypes.hh:89
XrdCryptoAux.hh
XrdCryptoKDFunLen_t
int(* XrdCryptoKDFunLen_t)()
Definition XrdCryptoAux.hh:59
XrdCryptoKDFun_t
int(* XrdCryptoKDFun_t)(const char *pass, int plen, const char *salt, int slen, char *key, int klen)
Definition XrdCryptoAux.hh:60
XrdCryptoX509ChainToFile_t
int(* XrdCryptoX509ChainToFile_t)(XrdCryptoX509Chain *, const char *)
Definition XrdCryptoFactory.hh:78
XrdProxyOpt_t::bits
int bits
Definition XrdCryptoFactory.hh:101
XrdCryptoX509CreateProxy_t
int(* XrdCryptoX509CreateProxy_t)(const char *, const char *, XrdProxyOpt_t *, XrdCryptogsiX509Chain *, XrdCryptoRSA **, const char *)
Definition XrdCryptoFactory.hh:107
XrdProxyOpt_t::depthlen
int depthlen
Definition XrdCryptoFactory.hh:103
XrdCryptoX509SignProxyReq_t
int(* XrdCryptoX509SignProxyReq_t)(XrdCryptoX509 *, XrdCryptoRSA *, XrdCryptoX509Req *, XrdCryptoX509 **)
Definition XrdCryptoFactory.hh:113
XrdCryptoX509VerifyChain_t
bool(* XrdCryptoX509VerifyChain_t)(XrdCryptoX509Chain *chain, int &errcode)
Definition XrdCryptoFactory.hh:72
XrdProxyOpt_t::valid
int valid
Definition XrdCryptoFactory.hh:102
XrdCryptoX509ExportChain_t
XrdSutBucket *(* XrdCryptoX509ExportChain_t)(XrdCryptoX509Chain *, bool)
Definition XrdCryptoFactory.hh:75
XrdCryptoX509ParseBucket_t
int(* XrdCryptoX509ParseBucket_t)(XrdSutBucket *, XrdCryptoX509Chain *)
Definition XrdCryptoFactory.hh:89
XrdCryptoX509VerifyCert_t
bool(* XrdCryptoX509VerifyCert_t)(XrdCryptoX509 *c, XrdCryptoX509 *r)
Definition XrdCryptoFactory.hh:70
XrdCryptoX509GetVOMSAttr_t
int(* XrdCryptoX509GetVOMSAttr_t)(XrdCryptoX509 *, XrdOucString &)
Definition XrdCryptoFactory.hh:119
XrdCryptoSetPathLenConstraint_t
void(* XrdCryptoSetPathLenConstraint_t)(void *, int)
Definition XrdCryptoFactory.hh:98
XrdCryptoX509ParseStack_t
int(* XrdCryptoX509ParseStack_t)(XrdTlsPeerCerts *pc, XrdCryptoX509Chain *c)
Definition XrdCryptoFactory.hh:85
XrdCryptoX509ParseFile_t
int(* XrdCryptoX509ParseFile_t)(const char *fname, XrdCryptoX509Chain *, const char *)
Definition XrdCryptoFactory.hh:81
XrdCryptoX509CreateProxyReq_t
int(* XrdCryptoX509CreateProxyReq_t)(XrdCryptoX509 *, XrdCryptoX509Req **, XrdCryptoRSA **)
Definition XrdCryptoFactory.hh:110
XrdCryptoProxyCertInfo_t
bool(* XrdCryptoProxyCertInfo_t)(const void *, int &, bool *)
Definition XrdCryptoFactory.hh:96
XrdCryptoX509CheckProxy3_t
int(* XrdCryptoX509CheckProxy3_t)(XrdCryptoX509 *, XrdOucString &)
Definition XrdCryptoFactory.hh:116
MAXFACTORYNAMELEN
#define MAXFACTORYNAMELEN
Definition XrdCryptoFactory.hh:41
XrdProxyOpt_t
Definition XrdCryptoFactory.hh:100
XrdCryptoCipher
Definition XrdCryptoCipher.hh:48
XrdCryptoFactory
Definition XrdCryptoFactory.hh:122
XrdCryptoFactory::HasPaddingSupport
virtual bool HasPaddingSupport()
Definition XrdCryptoFactory.cc:114
XrdCryptoFactory::X509VerifyChain
virtual XrdCryptoX509VerifyChain_t X509VerifyChain()
Definition XrdCryptoFactory.cc:279
XrdCryptoFactory::X509ParseBucket
virtual XrdCryptoX509ParseBucket_t X509ParseBucket()
Definition XrdCryptoFactory.cc:329
XrdCryptoFactory::X509CreateProxyReq
virtual XrdCryptoX509CreateProxyReq_t X509CreateProxyReq()
Definition XrdCryptoFactory.cc:366
XrdCryptoFactory::X509
virtual XrdCryptoX509 * X509(const char *cf, const char *kf=0)
Definition XrdCryptoFactory.cc:224
XrdCryptoFactory::SetTrace
virtual void SetTrace(kXR_int32 trace)
Definition XrdCryptoFactory.cc:69
XrdCryptoFactory::X509ParseFile
virtual XrdCryptoX509ParseFile_t X509ParseFile()
Definition XrdCryptoFactory.cc:309
XrdCryptoFactory::X509CreateProxy
virtual XrdCryptoX509CreateProxy_t X509CreateProxy()
Definition XrdCryptoFactory.cc:357
XrdCryptoFactory::KDFun
virtual XrdCryptoKDFun_t KDFun()
Definition XrdCryptoFactory.cc:96
XrdCryptoFactory::operator==
bool operator==(const XrdCryptoFactory factory)
Definition XrdCryptoFactory.cc:77
XrdCryptoFactory::Name
char * Name() const
Definition XrdCryptoFactory.hh:134
XrdCryptoFactory::X509ParseStack
virtual XrdCryptoX509ParseStack_t X509ParseStack()
Definition XrdCryptoFactory.cc:319
XrdCryptoFactory::X509GetVOMSAttr
virtual XrdCryptoX509GetVOMSAttr_t X509GetVOMSAttr()
Definition XrdCryptoFactory.cc:393
XrdCryptoFactory::X509ChainToFile
virtual XrdCryptoX509ChainToFile_t X509ChainToFile()
Definition XrdCryptoFactory.cc:299
XrdCryptoFactory::Cipher
virtual XrdCryptoCipher * Cipher(const char *t, int l=0)
Definition XrdCryptoFactory.cc:123
XrdCryptoFactory::~XrdCryptoFactory
virtual ~XrdCryptoFactory()
Definition XrdCryptoFactory.hh:128
XrdCryptoFactory::X509CheckProxy3
virtual XrdCryptoX509CheckProxy3_t X509CheckProxy3()
Definition XrdCryptoFactory.cc:384
XrdCryptoFactory::RSA
virtual XrdCryptoRSA * RSA(int b=0, int e=0)
Definition XrdCryptoFactory.cc:196
XrdCryptoFactory::SupportedMsgDigest
virtual bool SupportedMsgDigest(const char *dgst)
Definition XrdCryptoFactory.cc:178
XrdCryptoFactory::XrdCryptoFactory
XrdCryptoFactory(const char *n="Unknown", int id=-1)
Definition XrdCryptoFactory.cc:55
XrdCryptoFactory::SetPathLenConstraint
virtual XrdCryptoSetPathLenConstraint_t SetPathLenConstraint()
Definition XrdCryptoFactory.cc:348
XrdCryptoFactory::MsgDigest
virtual XrdCryptoMsgDigest * MsgDigest(const char *dgst)
Definition XrdCryptoFactory.cc:187
XrdCryptoFactory::ID
int ID() const
Definition XrdCryptoFactory.hh:135
XrdCryptoFactory::X509Crl
virtual XrdCryptoX509Crl * X509Crl(const char *crlfile, int opt=0)
Definition XrdCryptoFactory.cc:242
XrdCryptoFactory::KDFunLen
virtual XrdCryptoKDFunLen_t KDFunLen()
Definition XrdCryptoFactory.cc:87
XrdCryptoFactory::ProxyCertInfo
virtual XrdCryptoProxyCertInfo_t ProxyCertInfo()
Definition XrdCryptoFactory.cc:339
XrdCryptoFactory::GetCryptoFactory
static XrdCryptoFactory * GetCryptoFactory(const char *factoryname)
Definition XrdCryptoFactory.cc:417
XrdCryptoFactory::SupportedCipher
virtual bool SupportedCipher(const char *t)
Definition XrdCryptoFactory.cc:105
XrdCryptoFactory::X509Req
virtual XrdCryptoX509Req * X509Req(XrdSutBucket *bck)
Definition XrdCryptoFactory.cc:260
XrdCryptoFactory::X509SignProxyReq
virtual XrdCryptoX509SignProxyReq_t X509SignProxyReq()
Definition XrdCryptoFactory.cc:375
XrdCryptoFactory::X509ExportChain
virtual XrdCryptoX509ExportChain_t X509ExportChain()
Definition XrdCryptoFactory.cc:289
XrdCryptoFactory::X509VerifyCert
virtual XrdCryptoX509VerifyCert_t X509VerifyCert()
Definition XrdCryptoFactory.cc:269
XrdCryptoFactory::Notify
virtual void Notify()
Definition XrdCryptoFactory.hh:141
XrdCryptoMsgDigest
Definition XrdCryptoMsgDigest.hh:47
XrdCryptoRSA
Definition XrdCryptoRSA.hh:51
XrdCryptoX509Chain
Definition XrdCryptoX509Chain.hh:80
XrdCryptoX509Crl
Definition XrdCryptoX509Crl.hh:49
XrdCryptoX509Req
Definition XrdCryptoX509Req.hh:50
XrdCryptoX509
Definition XrdCryptoX509.hh:51
XrdCryptogsiX509Chain
Definition XrdCryptogsiX509Chain.hh:50
XrdOucString
Definition XrdOucString.hh:252
XrdSutBucket
Definition XrdSutBucket.hh:44
XrdTlsPeerCerts
Definition XrdTlsPeerCerts.hh:35