XRootD
Loading...
Searching...
No Matches
XrdCryptoRSA Class Reference

#include <XrdCryptoRSA.hh>

+ Inheritance diagram for XrdCryptoRSA:
+ Collaboration diagram for XrdCryptoRSA:

Public Types

enum  ERSAStatus {
  kInvalid = 0 ,
  kPublic = 1 ,
  kComplete = 2
}
 

Public Member Functions

 XrdCryptoRSA ()
 
virtual ~XrdCryptoRSA ()
 
virtual int DecryptPrivate (const char *in, int lin, char *out, int lout)
 
int DecryptPrivate (XrdSutBucket &buck)
 
virtual int DecryptPublic (const char *in, int lin, char *out, int lout)
 
int DecryptPublic (XrdSutBucket &buck)
 
virtual void Dump ()
 
virtual int EncryptPrivate (const char *in, int lin, char *out, int lout)
 
int EncryptPrivate (XrdSutBucket &buck)
 
virtual int EncryptPublic (const char *in, int lin, char *out, int lout)
 
int EncryptPublic (XrdSutBucket &buck)
 
virtual int ExportPrivate (char *out, int lout)
 
int ExportPrivate (XrdOucString &exp)
 
virtual int ExportPublic (char *out, int lout)
 
int ExportPublic (XrdOucString &exp)
 
virtual int GetOutlen (int lin)
 
virtual int GetPrilen ()
 
virtual int GetPublen ()
 
virtual int ImportPrivate (const char *in, int lin)
 
virtual int ImportPublic (const char *in, int lin)
 
bool IsValid ()
 
virtual XrdCryptoRSAdata Opaque ()
 
const char * Status (ERSAStatus t=kInvalid) const
 

Public Attributes

ERSAStatus status
 

Detailed Description

Definition at line 50 of file XrdCryptoRSA.hh.

Member Enumeration Documentation

◆ ERSAStatus

Enumerator
kInvalid 
kPublic 
kComplete 

Definition at line 57 of file XrdCryptoRSA.hh.

Constructor & Destructor Documentation

◆ XrdCryptoRSA()

XrdCryptoRSA::XrdCryptoRSA ( )
inline

Definition at line 53 of file XrdCryptoRSA.hh.

53{ status = kInvalid; }
ERSAStatus status

References kInvalid, and status.

◆ ~XrdCryptoRSA()

virtual XrdCryptoRSA::~XrdCryptoRSA ( )
inlinevirtual

Definition at line 54 of file XrdCryptoRSA.hh.

54{}

Member Function Documentation

◆ DecryptPrivate() [1/2]

int XrdCryptoRSA::DecryptPrivate ( const char *  in,
int  lin,
char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 173 of file XrdCryptoRSA.cc.

174{
175 // Abstract method to decrypt using the private key
176 ABSTRACTMETHOD("XrdCryptoRSA::DecryptPrivate");
177 return -1;
178}
#define ABSTRACTMETHOD(x)

References ABSTRACTMETHOD.

Referenced by DecryptPrivate(), and main().

+ Here is the caller graph for this function:

◆ DecryptPrivate() [2/2]

int XrdCryptoRSA::DecryptPrivate ( XrdSutBucket buck)

Definition at line 229 of file XrdCryptoRSA.cc.

230{
231 // Decrypt bucket bck using the private key
232 // Return new bucket size, or -1 in case of error
233 int snew = -1;
234
235 int sz = GetOutlen(bck.size);
236 char *newbuf = new char[sz];
237 if (newbuf) {
238 memset(newbuf, 0, sz);
239 snew = DecryptPrivate(bck.buffer,bck.size,newbuf,sz);
240 if (snew > -1)
241 bck.Update(newbuf,snew);
242 else
243 delete[] newbuf;
244 }
245 return snew;
246}
virtual int GetOutlen(int lin)
virtual int DecryptPrivate(const char *in, int lin, char *out, int lout)

References XrdSutBucket::buffer, DecryptPrivate(), GetOutlen(), XrdSutBucket::size, and XrdSutBucket::Update().

+ Here is the call graph for this function:

◆ DecryptPublic() [1/2]

int XrdCryptoRSA::DecryptPublic ( const char *  in,
int  lin,
char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 181 of file XrdCryptoRSA.cc.

182{
183 // Abstract method to decrypt using the public key
184 ABSTRACTMETHOD("XrdCryptoRSA::DecryptPublic");
185 return -1;
186}

References ABSTRACTMETHOD.

Referenced by DecryptPublic(), main(), and XrdSecProtocolgsi::Verify().

+ Here is the caller graph for this function:

◆ DecryptPublic() [2/2]

int XrdCryptoRSA::DecryptPublic ( XrdSutBucket buck)

Definition at line 249 of file XrdCryptoRSA.cc.

250{
251 // Decrypt bucket bck using the public key
252 // Return new bucket size, or -1 in case of error
253 int snew = -1;
254
255 int sz = GetOutlen(bck.size);
256 char *newbuf = new char[sz];
257 if (newbuf) {
258 memset(newbuf, 0, sz);
259 snew = DecryptPublic(bck.buffer,bck.size,newbuf,sz);
260 if (snew > -1)
261 bck.Update(newbuf,snew);
262 else
263 delete[] newbuf;
264 }
265 return snew;
266}
virtual int DecryptPublic(const char *in, int lin, char *out, int lout)

References XrdSutBucket::buffer, DecryptPublic(), GetOutlen(), XrdSutBucket::size, and XrdSutBucket::Update().

+ Here is the call graph for this function:

◆ Dump()

void XrdCryptoRSA::Dump ( )
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 44 of file XrdCryptoRSA.cc.

45{
46 // Check key validity
47 ABSTRACTMETHOD("XrdCryptoRSA::Dump");
48}

References ABSTRACTMETHOD.

Referenced by main().

+ Here is the caller graph for this function:

◆ EncryptPrivate() [1/2]

int XrdCryptoRSA::EncryptPrivate ( const char *  in,
int  lin,
char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 157 of file XrdCryptoRSA.cc.

158{
159 // Abstract method to encrypt using the private key
160 ABSTRACTMETHOD("XrdCryptoRSA::EncryptPrivate");
161 return -1;
162}

References ABSTRACTMETHOD.

Referenced by XrdSecProtocolgsi::Authenticate(), EncryptPrivate(), XrdSecProtocolgsi::getCredentials(), main(), and XrdSecProtocolgsi::Sign().

+ Here is the caller graph for this function:

◆ EncryptPrivate() [2/2]

int XrdCryptoRSA::EncryptPrivate ( XrdSutBucket buck)

Definition at line 189 of file XrdCryptoRSA.cc.

190{
191 // Encrypt bucket bck using the private key
192 // Return new bucket size, or -1 in case of error
193 int snew = -1;
194
195 int sz = GetOutlen(bck.size);
196 char *newbuf = new char[sz];
197 if (newbuf) {
198 memset(newbuf, 0, sz);
199 snew = EncryptPrivate(bck.buffer,bck.size,newbuf,sz);
200 if (snew > -1)
201 bck.Update(newbuf,snew);
202 else
203 delete[] newbuf;
204 }
205 return snew;
206}
virtual int EncryptPrivate(const char *in, int lin, char *out, int lout)

References XrdSutBucket::buffer, EncryptPrivate(), GetOutlen(), XrdSutBucket::size, and XrdSutBucket::Update().

+ Here is the call graph for this function:

◆ EncryptPublic() [1/2]

int XrdCryptoRSA::EncryptPublic ( const char *  in,
int  lin,
char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 165 of file XrdCryptoRSA.cc.

166{
167 // Abstract method to encrypt using the public key
168 ABSTRACTMETHOD("XrdCryptoRSA::EncryptPublic");
169 return -1;
170}

References ABSTRACTMETHOD.

Referenced by EncryptPublic(), and main().

+ Here is the caller graph for this function:

◆ EncryptPublic() [2/2]

int XrdCryptoRSA::EncryptPublic ( XrdSutBucket buck)

Definition at line 209 of file XrdCryptoRSA.cc.

210{
211 // Encrypt bucket bck using the public key
212 // Return new bucket size, or -1 in case of error
213 int snew = -1;
214
215 int sz = GetOutlen(bck.size);
216 char *newbuf = new char[sz];
217 if (newbuf) {
218 memset(newbuf, 0, sz);
219 snew = EncryptPublic(bck.buffer,bck.size,newbuf,sz);
220 if (snew > -1)
221 bck.Update(newbuf,snew);
222 else
223 delete[] newbuf;
224 }
225 return snew;
226}
virtual int EncryptPublic(const char *in, int lin, char *out, int lout)

References XrdSutBucket::buffer, EncryptPublic(), GetOutlen(), XrdSutBucket::size, and XrdSutBucket::Update().

+ Here is the call graph for this function:

◆ ExportPrivate() [1/2]

int XrdCryptoRSA::ExportPrivate ( char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 107 of file XrdCryptoRSA.cc.

108{
109 // Abstract method to export the private key
110 ABSTRACTMETHOD("XrdCryptoRSA::ExportPrivate");
111 return -1;
112}

References ABSTRACTMETHOD.

Referenced by ExportPrivate(), and main().

+ Here is the caller graph for this function:

◆ ExportPrivate() [2/2]

int XrdCryptoRSA::ExportPrivate ( XrdOucString exp)

Definition at line 136 of file XrdCryptoRSA.cc.

137{
138 // Export the private key into string s
139
140 int newlen = GetPrilen();
141 if (newlen > 0) {
142 char *newbuf = new char[newlen+1];
143 if (newbuf) {
144 memset(newbuf, 0, newlen+1);
145 if (ExportPrivate(newbuf,newlen+1) > -1) {
146 s = (const char *)newbuf;
147 delete[] newbuf;
148 return 0;
149 }
150 delete[] newbuf;
151 }
152 }
153 return -1;
154}
virtual int ExportPrivate(char *out, int lout)
virtual int GetPrilen()

References ExportPrivate(), and GetPrilen().

+ Here is the call graph for this function:

◆ ExportPublic() [1/2]

int XrdCryptoRSA::ExportPublic ( char *  out,
int  lout 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 91 of file XrdCryptoRSA.cc.

92{
93 // Abstract method to export the public key
94 ABSTRACTMETHOD("XrdCryptoRSA::ExportPublic");
95 return -1;
96}

References ABSTRACTMETHOD.

Referenced by ExportPublic(), XrdSecProtocolgsi::getCredentials(), and main().

+ Here is the caller graph for this function:

◆ ExportPublic() [2/2]

int XrdCryptoRSA::ExportPublic ( XrdOucString exp)

Definition at line 115 of file XrdCryptoRSA.cc.

116{
117 // Export the public key into string s
118
119 int newlen = GetPublen();
120 if (newlen > 0) {
121 char *newbuf = new char[newlen+1];
122 if (newbuf) {
123 memset(newbuf, 0, newlen+1);
124 if (ExportPublic(newbuf,newlen+1) > -1) {
125 s = (const char *)newbuf;
126 delete[] newbuf;
127 return 0;
128 }
129 delete[] newbuf;
130 }
131 }
132 return -1;
133}
virtual int GetPublen()
virtual int ExportPublic(char *out, int lout)

References ExportPublic(), and GetPublen().

+ Here is the call graph for this function:

◆ GetOutlen()

int XrdCryptoRSA::GetOutlen ( int  lin)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 59 of file XrdCryptoRSA.cc.

60{
61 // Get length of output
62 ABSTRACTMETHOD("XrdCryptoRSA::GetOutlen");
63 return 0;
64}

References ABSTRACTMETHOD.

Referenced by DecryptPrivate(), DecryptPublic(), EncryptPrivate(), EncryptPublic(), XrdSecProtocolgsi::Sign(), and XrdSecProtocolgsi::Verify().

+ Here is the caller graph for this function:

◆ GetPrilen()

int XrdCryptoRSA::GetPrilen ( )
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 75 of file XrdCryptoRSA.cc.

76{
77 // Get length of private key export form
78 ABSTRACTMETHOD("XrdCryptoRSA::GetPrilen");
79 return 0;
80}

References ABSTRACTMETHOD.

Referenced by ExportPrivate(), and main().

+ Here is the caller graph for this function:

◆ GetPublen()

int XrdCryptoRSA::GetPublen ( )
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 67 of file XrdCryptoRSA.cc.

68{
69 // Get length of public key export form
70 ABSTRACTMETHOD("XrdCryptoRSA::GetPublen");
71 return 0;
72}

References ABSTRACTMETHOD.

Referenced by ExportPublic(), and main().

+ Here is the caller graph for this function:

◆ ImportPrivate()

int XrdCryptoRSA::ImportPrivate ( const char *  in,
int  lin 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 99 of file XrdCryptoRSA.cc.

100{
101 // Abstract method to import a private key
102 ABSTRACTMETHOD("XrdCryptoRSA::ImportPrivate");
103 return -1;
104}

References ABSTRACTMETHOD.

Referenced by main().

+ Here is the caller graph for this function:

◆ ImportPublic()

int XrdCryptoRSA::ImportPublic ( const char *  in,
int  lin 
)
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 83 of file XrdCryptoRSA.cc.

84{
85 // Abstract method to import a public key
86 ABSTRACTMETHOD("XrdCryptoRSA::ImportPublic");
87 return -1;
88}

References ABSTRACTMETHOD.

Referenced by main().

+ Here is the caller graph for this function:

◆ IsValid()

bool XrdCryptoRSA::IsValid ( )
inline

Definition at line 69 of file XrdCryptoRSA.hh.

69{ return (status != kInvalid); }

References kInvalid, and status.

Referenced by XrdCryptosslRSA::Dump(), XrdCryptosslRSA::ExportPrivate(), XrdCryptosslRSA::ExportPublic(), XrdCryptosslFactory::RSA(), XrdCryptosslFactory::RSA(), and XrdCryptosslFactory::RSA().

+ Here is the caller graph for this function:

◆ Opaque()

XrdCryptoRSAdata XrdCryptoRSA::Opaque ( )
virtual

Reimplemented in XrdCryptosslRSA.

Definition at line 51 of file XrdCryptoRSA.cc.

52{
53 // Return underlying key in raw format
54 ABSTRACTMETHOD("XrdCryptoRSA::Opaque");
55 return (XrdCryptoRSAdata)0;
56}
void * XrdCryptoRSAdata

References ABSTRACTMETHOD.

Referenced by main(), XrdCryptosslX509ChainToFile(), and XrdCryptosslX509ExportChain().

+ Here is the caller graph for this function:

◆ Status()

const char * XrdCryptoRSA::Status ( ERSAStatus  t = kInvalid) const
inline

Definition at line 59 of file XrdCryptoRSA.hh.

60 { return ((t == kInvalid) ? cstatus[status] : cstatus[t]); }

References kInvalid, and status.

Member Data Documentation

◆ status


The documentation for this class was generated from the following files: