xrootd
XrdCryptoBasic.hh
Go to the documentation of this file.
00001 #ifndef __CRYPTO_BASIC_H__
00002 #define __CRYPTO_BASIC_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                     X r d C r y p t o B a s i c. h h                       */
00006 /*                                                                            */
00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*   Produced by Geri Ganis for CERN                                          */
00009 /*                                                                            */
00010 /* This file is part of the XRootD software suite.                            */
00011 /*                                                                            */
00012 /* XRootD is free software: you can redistribute it and/or modify it under    */
00013 /* the terms of the GNU Lesser General Public License as published by the     */
00014 /* Free Software Foundation, either version 3 of the License, or (at your     */
00015 /* option) any later version.                                                 */
00016 /*                                                                            */
00017 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00018 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00019 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00020 /* License for more details.                                                  */
00021 /*                                                                            */
00022 /* You should have received a copy of the GNU Lesser General Public License   */
00023 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00024 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00025 /*                                                                            */
00026 /* The copyright holder's institutional names and contributor's names may not */
00027 /* be used to endorse or promote products derived from this software without  */
00028 /* specific prior written permission of the institution or contributor.       */
00029 /******************************************************************************/
00030 
00031 
00032 /* ************************************************************************** */
00033 /*                                                                            */
00034 /* Generic buffer for crypto functions needed in XrdCrypto                    */
00035 /* Different crypto implementation (OpenSSL, Botan, ...) available as plug-in */
00036 /*                                                                            */
00037 /* ************************************************************************** */
00038 
00039 #include "XProtocol/XProtocol.hh"
00040 #include "XrdSut/XrdSutBucket.hh"
00041 
00042 // ---------------------------------------------------------------------------//
00043 //
00044 // Basic buffer
00045 //
00046 // ---------------------------------------------------------------------------//
00047 class XrdCryptoBasic
00048 {
00049 public:
00050    // ctor
00051    XrdCryptoBasic(const char *t = 0, int l = 0, const char *b = 0);
00052    // dtor
00053    virtual ~XrdCryptoBasic() 
00054           { if (type) delete[] type; if (membuf) delete[] membuf; }
00055    // getters
00056    virtual XrdSutBucket *AsBucket();
00057    char *AsHexString();
00058    virtual int   Length() const { return lenbuf; }
00059    virtual char *Buffer() const { return membuf; }
00060    virtual char *Type() const { return type; }
00061    // setters
00062    virtual int   FromHex(const char *hex);
00063    virtual int   SetLength(int l);
00064    virtual int   SetBuffer(int l, const char *b);
00065    virtual int   SetType(const char *t);
00066    // special setter to avoid buffer re-allocation
00067    virtual void  UseBuffer(int l, const char *b)
00068           { if (membuf) delete[] membuf; membuf = (char *)b; lenbuf = l; }
00069 
00070 private:
00071    kXR_int32  lenbuf;
00072    char      *membuf;
00073    char      *type;
00074 };
00075 
00076 #endif