XrdCryptoLite.hh

Go to the documentation of this file.
00001 #ifndef __XRDCRYPTOLITE_H__
00002 #define __XRDCRYPTOLITE_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                      X r d C r y p t o L i t e . h h                       */
00006 /*                                                                            */
00007 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //       $Id: XrdCryptoLite.hh 26376 2008-11-22 11:07:11Z ganis $
00014 
00015 // This abstract class defines a very simple interface to encryption methods.
00016 // CryptoLite provides a naive interface to stream cryptographic algorithms
00017 // that include decryption validation. Use XrdCryptoBasic and it's derived 
00018 // classes for full-featured cryptogrophy.
00019 //
00020 
00021 class XrdCryptoLite
00022 {
00023 public:
00024 
00025 // Create()  creates a new CryptoLite object that implements the specified
00026 //           cryptography (see below). It returns a pointer to the object or a
00027 //           null pointer if not successful (e.g., unsupported). When creating a
00028 //           crypto object you may associate an arbitrary type code with an
00029 //           instance of that object which Type() will simply echo back.
00030 
00031 //           Supported names:
00032 //           bf32      Blowfish with CRC32 validation.
00033 //
00034 static XrdCryptoLite *
00035              Create(int        &rc,        // errno when Create(...) == 0
00036                     const char *Name,      // Crypto name
00037                     const char Type='\0'); // Crypto type (assigned)
00038 
00039 // Decrypt() decrypts src and, if successful, returns the number of bytes
00040 //           placed in dst. Otherwise, -errno is returned (which may be 0).
00041 //           Requirements: srclen >= dstlen > 0
00042 //
00043 virtual int  Decrypt(const char *key,      // Decryption key
00044                      int         keyLen,   // Decryption key byte length
00045                      const char *src,      // Buffer to be decrypted
00046                      int         srcLen,   // Bytes length of src  buffer
00047                      char       *dst,      // Buffer to hold decrypted result
00048                      int         dstLen)=0;// Bytes length of dst  buffer
00049 
00050 // Encrypt() encrypts src and, if successful, returns the number of bytes
00051 //           placed in dst. Otherwise, -errno is returned (which may be 0).
00052 //           Requirements: 0 < srclen <= (dstlen + Overhead())
00053 //
00054 virtual int  Encrypt(const char *key,      // Encryption key
00055                      int         keyLen,   // Encryption key byte length
00056                      const char *src,      // Buffer to be encrypted
00057                      int         srcLen,   // Bytes length of src  buffer
00058                      char       *dst,      // Buffer to hold encrypted result
00059                      int         dstLen)=0;// Bytes length of dst  buffer
00060 
00061 // Overhead() returns the number of *extra* bytes required for the dst buffer,
00062 //            as specified when the actual implementation was instantiated.
00063 //            Hence, we can provide an implementation for this method.
00064 //
00065 virtual int  Overhead() {return Extra;}
00066 
00067 // Type() simply returns the encyption type code assigned to this object when
00068 //        its actual implementation was instantiated. Hence, we can provide an
00069 //        implementation for this method.
00070 //
00071 virtual char Type() {return myType;}
00072 
00073          XrdCryptoLite(char deType, int ovhd=8) : Extra(ovhd),myType(deType) {}
00074 virtual ~XrdCryptoLite() {}
00075 
00076 protected:
00077 
00078 int  Extra;
00079 char myType;
00080 };
00081 #endif

Generated on Tue Jul 5 14:46:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1