xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCrypto
XrdCryptoFactory.hh
Go to the documentation of this file.
1
#ifndef __CRYPTO_FACTORY_H__
2
#define __CRYPTO_FACTORY_H__
3
/******************************************************************************/
4
/* */
5
/* X r d C r y p t o F a c t o r y . h h */
6
/* */
7
/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* Produced by Gerri Ganis for CERN */
9
/* */
10
/* This file is part of the XRootD software suite. */
11
/* */
12
/* XRootD is free software: you can redistribute it and/or modify it under */
13
/* the terms of the GNU Lesser General Public License as published by the */
14
/* Free Software Foundation, either version 3 of the License, or (at your */
15
/* option) any later version. */
16
/* */
17
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20
/* License for more details. */
21
/* */
22
/* You should have received a copy of the GNU Lesser General Public License */
23
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25
/* */
26
/* The copyright holder's institutional names and contributor's names may not */
27
/* be used to endorse or promote products derived from this software without */
28
/* specific prior written permission of the institution or contributor. */
29
/******************************************************************************/
30
31
/* ************************************************************************** */
32
/* */
33
/* Abstract interface for a crypto factory */
34
/* Allows to plug-in modules based on different crypto implementation */
35
/* (OpenSSL, Botan, ...) */
36
/* */
37
/* ************************************************************************** */
38
39
#include "
XrdCrypto/XrdCryptoAux.hh
"
40
41
#define MAXFACTORYNAMELEN 10
42
// ---------------------------------------------------------------------------//
43
//
44
// Abstract Crypto Factory
45
//
46
// ---------------------------------------------------------------------------//
47
48
class
XrdSutBucket
;
49
class
XrdCryptoCipher
;
50
class
XrdCryptoMsgDigest
;
51
class
XrdCryptoRSA
;
52
class
XrdCryptoX509
;
53
class
XrdCryptoX509Chain
;
54
class
XrdCryptoX509Crl
;
55
class
XrdCryptoX509Req
;
56
57
//
58
// Prototypes for some Utility Functions
59
60
// Key derivation function
61
typedef
int (*
XrdCryptoKDFunLen_t
)();
62
typedef
int (*
XrdCryptoKDFun_t
)(
const
char
*pass,
int
plen,
63
const
char
*salt,
int
slen,
64
char
*key,
int
klen);
65
66
// X509 manipulation: certificate verification
67
typedef
bool (*
XrdCryptoX509VerifyCert_t
)(
XrdCryptoX509
*c,
XrdCryptoX509
*r);
68
// chain verification
69
typedef
bool (*
XrdCryptoX509VerifyChain_t
)(
XrdCryptoX509Chain
*chain,
70
int
&errcode);
71
// chain export
72
typedef
XrdSutBucket
*(*XrdCryptoX509ExportChain_t)(
XrdCryptoX509Chain
*, bool);
73
74
// chain to file
75
typedef
int (*
XrdCryptoX509ChainToFile_t
)(
XrdCryptoX509Chain
*,
const
char
*);
76
77
// certificates from file parsing
78
typedef
int (*
XrdCryptoX509ParseFile_t
)(
const
char
*fname,
79
XrdCryptoX509Chain
*);
80
// certificates from bucket parsing
81
typedef
int (*
XrdCryptoX509ParseBucket_t
)(
XrdSutBucket
*,
82
XrdCryptoX509Chain
*);
83
84
class
XrdCryptoFactory
85
{
86
private
:
87
char
name
[
MAXFACTORYNAMELEN
];
88
int
fID
;
89
public
:
90
XrdCryptoFactory
(
const
char
*n =
"Unknown"
,
int
id
= -1);
91
virtual
~XrdCryptoFactory
() { }
92
93
// Set trace flags
94
virtual
void
SetTrace
(
kXR_int32
trace);
95
96
// Get the factory name
97
char
*
Name
()
const
{
return
(
char
*)&
name
[0]; }
98
int
ID
()
const
{
return
fID
; }
99
100
// Get the right factory
101
static
XrdCryptoFactory
*
GetCryptoFactory
(
const
char
*factoryname);
102
103
// Any possible notification
104
virtual
void
Notify
() { }
105
106
// Hook to a Key Derivation Function (PBKDF2 when possible)
107
virtual
XrdCryptoKDFunLen_t
KDFunLen
();
// Length of buffer
108
virtual
XrdCryptoKDFun_t
KDFun
();
109
110
// Cipher constructors
111
virtual
bool
SupportedCipher
(
const
char
*t);
112
virtual
XrdCryptoCipher
*
Cipher
(
const
char
*t,
int
l = 0);
113
virtual
XrdCryptoCipher
*
Cipher
(
const
char
*t,
int
l,
const
char
*k,
114
int
liv,
const
char
*iv);
115
virtual
XrdCryptoCipher
*
Cipher
(
XrdSutBucket
*b);
116
virtual
XrdCryptoCipher
*
Cipher
(
int
bits,
char
*pub,
int
lpub,
const
char
*t = 0);
117
virtual
XrdCryptoCipher
*
Cipher
(
const
XrdCryptoCipher
&c);
118
119
// MsgDigest constructors
120
virtual
bool
SupportedMsgDigest
(
const
char
*dgst);
121
virtual
XrdCryptoMsgDigest
*
MsgDigest
(
const
char
*dgst);
122
123
// RSA constructors
124
virtual
XrdCryptoRSA
*
RSA
(
int
b = 0,
int
e = 0);
125
virtual
XrdCryptoRSA
*
RSA
(
const
char
*p,
int
l = 0);
126
virtual
XrdCryptoRSA
*
RSA
(
const
XrdCryptoRSA
&r);
127
128
// X509 constructors
129
virtual
XrdCryptoX509
*
X509
(
const
char
*cf,
const
char
*kf = 0);
130
virtual
XrdCryptoX509
*
X509
(
XrdSutBucket
*b);
131
132
// X509 CRL constructors
133
virtual
XrdCryptoX509Crl
*
X509Crl
(
const
char
*crlfile,
int
opt = 0);
134
virtual
XrdCryptoX509Crl
*
X509Crl
(
XrdCryptoX509
*cacert);
135
136
// X509 REQ constructors
137
virtual
XrdCryptoX509Req
*
X509Req
(
XrdSutBucket
*bck);
138
139
// Hooks to handle X509 certificates
140
virtual
XrdCryptoX509VerifyCert_t
X509VerifyCert
();
141
virtual
XrdCryptoX509VerifyChain_t
X509VerifyChain
();
142
virtual
XrdCryptoX509ParseFile_t
X509ParseFile
();
143
virtual
XrdCryptoX509ParseBucket_t
X509ParseBucket
();
144
virtual
XrdCryptoX509ExportChain_t
X509ExportChain
();
145
virtual
XrdCryptoX509ChainToFile_t
X509ChainToFile
();
146
147
// Equality operator
148
bool
operator==
(
const
XrdCryptoFactory
factory);
149
};
150
#endif
Generated by
1.8.3.1