XRootD
XrdCksCalcmd5 Class Reference

#include <XrdCksCalcmd5.hh>

+ Inheritance diagram for XrdCksCalcmd5:
+ Collaboration diagram for XrdCksCalcmd5:

Classes

union  MD5Context.__unnamed25__
 
union  MD5Context.__unnamed27__
 

Public Member Functions

 XrdCksCalcmd5 ()
 
 ~XrdCksCalcmd5 ()
 
char * Current ()
 
char * Final ()
 
void Init ()
 
XrdCksCalcNew ()
 
const char * Type (int &csSz)
 
void Update (const char *Buff, int BLen)
 
- Public Member Functions inherited from XrdCksCalc
 XrdCksCalc ()
 Constructor. More...
 
virtual ~XrdCksCalc ()
 Destructor. More...
 
virtual char * Calc (const char *Buff, int BLen)
 
virtual void Recycle ()
 Recycle the checksum object as it is no longer needed. A default is given. More...
 

Detailed Description

Definition at line 37 of file XrdCksCalcmd5.hh.


Class Documentation

◆ XrdCksCalcmd5::MD5Context.__unnamed25__

union XrdCksCalcmd5::MD5Context.__unnamed25__

Definition at line 66 of file XrdCksCalcmd5.hh.

+ Collaboration diagram for XrdCksCalcmd5::MD5Context.__unnamed25__:
Class Members
long long b64
unsigned int bits[2]

◆ XrdCksCalcmd5::MD5Context.__unnamed27__

union XrdCksCalcmd5::MD5Context.__unnamed27__

Definition at line 69 of file XrdCksCalcmd5.hh.

+ Collaboration diagram for XrdCksCalcmd5::MD5Context.__unnamed27__:
Class Members
long long i64[8]
unsigned char in[64]

Constructor & Destructor Documentation

◆ XrdCksCalcmd5()

XrdCksCalcmd5::XrdCksCalcmd5 ( )
inline

Definition at line 59 of file XrdCksCalcmd5.hh.

59 {Init();}

References Init().

Referenced by New().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~XrdCksCalcmd5()

XrdCksCalcmd5::~XrdCksCalcmd5 ( )
inline

Definition at line 60 of file XrdCksCalcmd5.hh.

60 {}

Member Function Documentation

◆ Current()

char* XrdCksCalcmd5::Current ( )
inlinevirtual

Get the current binary checksum value (defaults to final). However, the final checksum result is not affected.

Returns
the checksum value in binary format. The pointer to the value becomes invalid once the associated object is deleted.

Reimplemented from XrdCksCalc.

Definition at line 41 of file XrdCksCalcmd5.hh.

42  {MD5Context saveCTX = myContext;
43  char *md5P = Final();
44  myContext = saveCTX;
45  return (char *)md5P;
46  }

References Final().

+ Here is the call graph for this function:

◆ Final()

char * XrdCksCalcmd5::Final ( )
virtual

Get the actual checksum in binary format.

Returns
the checksum value in binary format. The pointer to the value becomes invalid once the associated object is deleted.

Implements XrdCksCalc.

Definition at line 153 of file XrdCksCalcmd5.cc.

154 {
155  unsigned count;
156  unsigned char *p;
157 
158 // Compute number of bytes mod 64
159 //
160  count = (myContext.bits[0] >> 3) & 0x3F;
161 
162 // Set the first char of padding to 0x80. This is safe since there is
163 // always at least one byte free.
164 //
165  p = myContext.in + count;
166  *p++ = 0x80;
167 
168 // Bytes of padding needed to make 64 bytes
169 //
170  count = 64 - 1 - count;
171 
172 // Pad out to 56 mod 64
173 //
174  if (count < 8) // Two lots of padding: Pad the first block to 64 bytes
175  {memset(p, 0, count);
176  byteReverse(myContext.in, 16);
177  MD5Transform(myContext.buf, (unsigned int *) myContext.in);
178  memset(myContext.in, 0, 56); // Now fill the next block with 56 bytes
179  } else memset(p, 0, count - 8); // Else pad block to 56 bytes
180 
181  byteReverse(myContext.in, 14);
182 
183 // Append length in bits and transform (original code in comments)
184 //
185 // ((unsigned int *) myContext.in)[14] = myContext.bits[0];
186 // ((unsigned int *) myContext.in)[15] = myContext.bits[1];
187  myContext.i64[7] = myContext.b64;
188 
189  MD5Transform(myContext.buf, (unsigned int *) myContext.in);
190  byteReverse((unsigned char *) myContext.buf, 4);
191 
192 // Copy to a separate buffer and return ASCII value if so wanted
193 //
194  memcpy(myDigest, myContext.buf, 16);
195  return (char *)myDigest;
196 }

Referenced by Current().

+ Here is the caller graph for this function:

◆ Init()

void XrdCksCalcmd5::Init ( )
virtual

Initializes data structures (must be called by constructor). This is always called to reuse the object for a new checksum.

Implements XrdCksCalc.

Definition at line 84 of file XrdCksCalcmd5.cc.

85 {
86  myContext.buf[0] = 0x67452301;
87  myContext.buf[1] = 0xefcdab89;
88  myContext.buf[2] = 0x98badcfe;
89  myContext.buf[3] = 0x10325476;
90 
91  myContext.bits[0] = 0;
92  myContext.bits[1] = 0;
93 }

Referenced by XrdCksCalcmd5().

+ Here is the caller graph for this function:

◆ New()

XrdCksCalc* XrdCksCalcmd5::New ( )
inlinevirtual

Get a new instance of the underlying checksum calculation object.

Returns
the checksum calculation object.

Implements XrdCksCalc.

Definition at line 50 of file XrdCksCalcmd5.hh.

50 {return (XrdCksCalc *)new XrdCksCalcmd5;}

References XrdCksCalcmd5().

+ Here is the call graph for this function:

◆ Type()

const char* XrdCksCalcmd5::Type ( int &  csSize)
inlinevirtual

Get the checksum object algorithm name and the number bytes (i.e. size) required for the checksum value.

Parameters
csSize-> Parameter to hold the size of the checksum value.
Returns
the checksum algorithm's name. The name persists event after the checksum object is deleted.

Implements XrdCksCalc.

Definition at line 57 of file XrdCksCalcmd5.hh.

57 {csSz = sizeof(myDigest); return "md5";}

◆ Update()

void XrdCksCalcmd5::Update ( const char *  Buff,
int  BLen 
)
inlinevirtual

Compute a running checksum. This method may be called repeatedly for data segments; with Final() returning the full checksum.

Parameters
Buff-> Data to be checksummed.
BLen-> Length of the data in Buff.

Implements XrdCksCalc.

Definition at line 54 of file XrdCksCalcmd5.hh.

55  {MD5Update((unsigned char *)Buff,(unsigned)BLen);}

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