xrootd
XrdCryptoBasic.hh
Go to the documentation of this file.
1 // $Id$
2 #ifndef __CRYPTO_BASIC_H__
3 #define __CRYPTO_BASIC_H__
4 /******************************************************************************/
5 /* */
6 /* X r d C r y p t o B a s i c. h h */
7 /* */
8 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
9 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */
10 /* Produced by Andrew Hanushevsky for Stanford University under contract */
11 /* DE-AC03-76-SFO0515 with the Department of Energy */
12 /******************************************************************************/
13 
14 
15 /* ************************************************************************** */
16 /* */
17 /* Generic buffer for crypto functions needed in XrdCrypto */
18 /* Different crypto implementation (OpenSSL, Botan, ...) available as plug-in */
19 /* */
20 /* ************************************************************************** */
21 
22 #include <XProtocol/XProtocol.hh>
23 #include <XrdSut/XrdSutBucket.hh>
24 
25 // ---------------------------------------------------------------------------//
26 //
27 // Basic buffer
28 //
29 // ---------------------------------------------------------------------------//
31 {
32 public:
33  // ctor
34  XrdCryptoBasic(const char *t = 0, int l = 0, const char *b = 0);
35  // dtor
36  virtual ~XrdCryptoBasic()
37  { if (type) delete[] type; if (membuf) delete[] membuf; }
38  // getters
39  virtual XrdSutBucket *AsBucket();
40  char *AsHexString();
41  virtual int Length() const { return lenbuf; }
42  virtual char *Buffer() const { return membuf; }
43  virtual char *Type() const { return type; }
44  // setters
45  virtual int FromHex(const char *hex);
46  virtual int SetLength(int l);
47  virtual int SetBuffer(int l, const char *b);
48  virtual int SetType(const char *t);
49  // special setter to avoid buffer re-allocation
50  virtual void UseBuffer(int l, const char *b)
51  { if (membuf) delete[] membuf; membuf = (char *)b; lenbuf = l; }
52 
53 private:
55  char *membuf;
56  char *type;
57 };
58 
59 #endif