XrdCryptoCipher.cc

Go to the documentation of this file.
00001 // $Id: XrdCryptoCipher.cc 30949 2009-11-02 16:37:58Z ganis $
00002 
00003 const char *XrdCryptoCipherCVSID = "$Id: XrdCryptoCipher.cc 30949 2009-11-02 16:37:58Z ganis $";
00004 /******************************************************************************/
00005 /*                                                                            */
00006 /*                   X r d C r y p t o C i p h e r . c c                      */
00007 /*                                                                            */
00008 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00009 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00010 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00011 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00012 /******************************************************************************/
00013 
00014 /* ************************************************************************** */
00015 /*                                                                            */
00016 /* Generic interface to a cipher class                                        */
00017 /* Allows to plug-in modules based on different crypto implementation         */
00018 /* (OpenSSL, Botan, ...)                                                      */
00019 /*                                                                            */
00020 /* ************************************************************************** */
00021 
00022 #include <string.h>
00023 
00024 #include <XrdCrypto/XrdCryptoAux.hh>
00025 #include <XrdCrypto/XrdCryptoCipher.hh>
00026 
00027 //_____________________________________________________________________________
00028 bool XrdCryptoCipher::Finalize(char *, int, const char *)
00029 {
00030    // Finalize key computation (key agreement)
00031    ABSTRACTMETHOD("XrdCryptoCipher::Finalize");
00032    return 0;
00033 }
00034 
00035 //_____________________________________________________________________________
00036 bool XrdCryptoCipher::IsValid()
00037 {
00038    // Check key validity
00039    ABSTRACTMETHOD("XrdCryptoCipher::IsValid");
00040    return 0;
00041 }
00042 
00043 //____________________________________________________________________________
00044 void XrdCryptoCipher::SetIV(int l, const char *iv)
00045 {
00046    // Set IV from l bytes at iv
00047 
00048    ABSTRACTMETHOD("XrdCryptoCipher::SetIV");
00049 }
00050 
00051 //____________________________________________________________________________
00052 char *XrdCryptoCipher::RefreshIV(int &l)
00053 {
00054    // Regenerate IV and return it
00055 
00056    ABSTRACTMETHOD("XrdCryptoCipher::RefreshIV");
00057    return 0;
00058 }
00059 
00060 //____________________________________________________________________________
00061 char *XrdCryptoCipher::IV(int &l) const
00062 {
00063    // Get IV
00064 
00065    ABSTRACTMETHOD("XrdCryptoCipher::IV");
00066    return 0;
00067 }
00068 
00069 //____________________________________________________________________________
00070 char *XrdCryptoCipher::Public(int &lpub)
00071 {
00072    // Getter for public part during key agreement
00073 
00074    ABSTRACTMETHOD("XrdCryptoCipher::Public");
00075    return 0;
00076 }
00077 
00078 //_____________________________________________________________________________
00079 XrdSutBucket *XrdCryptoCipher::AsBucket()
00080 {
00081    // Return pointer to a bucket created using the internal information
00082    // serialized
00083  
00084    ABSTRACTMETHOD("XrdCryptoCipher::AsBucket");
00085    return 0;
00086 }
00087 //____________________________________________________________________________
00088 int XrdCryptoCipher::Encrypt(const char *, int, char *)
00089 {
00090    // Encrypt lin bytes at in with local cipher.
00091 
00092    ABSTRACTMETHOD("XrdCryptoCipher::Encrypt");
00093    return 0;
00094 }
00095 
00096 //____________________________________________________________________________
00097 int XrdCryptoCipher::Decrypt(const char *, int, char *)
00098 {
00099    // Decrypt lin bytes at in with local cipher.
00100 
00101    ABSTRACTMETHOD("XrdCryptoCipher::Decrypt");
00102    return 0;
00103 }
00104 
00105 //____________________________________________________________________________
00106 int XrdCryptoCipher::EncOutLength(int)
00107 {
00108    // Required buffer size for encrypting l bytes
00109 
00110    ABSTRACTMETHOD("XrdCryptoCipher::EncOutLength");
00111    return 0;
00112 }
00113 
00114 //____________________________________________________________________________
00115 int XrdCryptoCipher::DecOutLength(int)
00116 {
00117    // Required buffer size for decrypting l bytes
00118 
00119    ABSTRACTMETHOD("XrdCryptoCipher::DecOutLength");
00120    return 0;
00121 }
00122 
00123 //____________________________________________________________________________
00124 bool XrdCryptoCipher::IsDefaultLength() const
00125 {
00126    // Test if cipher length is the default one
00127 
00128    ABSTRACTMETHOD("XrdCryptoCipher::IsDefaultLength");
00129    return 0;
00130 }
00131 
00132 //____________________________________________________________________________
00133 int XrdCryptoCipher::Encrypt(XrdSutBucket &bck)
00134 {
00135    // Encrypt bucket bck with local cipher
00136    // Return size of encoded bucket or -1 in case of error
00137    int snew = -1;
00138 
00139    int sz = EncOutLength(bck.size);
00140    char *newbck = new char[sz];
00141    if (newbck) {
00142       memset(newbck, 0, sz);
00143       snew = Encrypt(bck.buffer,bck.size,newbck);
00144       if (snew > -1)
00145          bck.Update(newbck,snew);
00146    }
00147    return snew;
00148 }
00149 
00150 //____________________________________________________________________________
00151 int XrdCryptoCipher::Decrypt(XrdSutBucket &bck)
00152 {
00153    // Decrypt bucket bck with local cipher
00154    // Return size of encoded bucket or -1 in case of error
00155    int snew = -1;
00156 
00157    int sz = DecOutLength(bck.size);
00158    char *newbck = new char[sz];
00159    if (newbck) {
00160       memset(newbck, 0, sz);
00161       snew = Decrypt(bck.buffer,bck.size,newbck);
00162       if (snew > -1)
00163          bck.Update(newbck,snew);
00164    }
00165    return snew;
00166 }

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