xrootd
XrdCksCalcmd5.hh
Go to the documentation of this file.
1 #ifndef __XRDCKSCALCMD2_HH__
2 #define __XRDCKSCALCMD5_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C k s C a l c m d 5 . h h */
6 /* */
7 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <stdio.h>
14 
15 #include "XrdCks/XrdCksCalc.hh"
16 
17 class XrdCksCalcmd5 : public XrdCksCalc
18 {
19 public:
20 
21 char *Current()
22  {MD5Context saveCTX = myContext;
23  char *md5P = Final();
24  myContext = saveCTX;
25  return (char *)md5P;
26  }
27 
28 void Init();
29 
31 
32 char *Final();
33 
34 void Update(const char *Buff, int BLen)
35  {MD5Update((unsigned char *)Buff,(unsigned)BLen);}
36 
37 const char *Type(int &csSz) {csSz = sizeof(myDigest); return "md5";}
38 
41 
42 private:
43 
44 struct MD5Context
45  {unsigned int buf[4];
46  unsigned int bits[2];
47  unsigned char in[64];
48  };
49 
51 unsigned char myDigest[16];
52 
53 void byteReverse(unsigned char *buf, unsigned longs);
54 void MD5Update(unsigned char const *buf, unsigned int len);
55 
56 #ifndef ASM_MD5
57 void MD5Transform(unsigned int buf[4], unsigned int const in[16]);
58 #endif
59 };
60 #endif