|
xrootd
|
00001 #ifndef __XRDCKSCALCMD2_HH__ 00002 #define __XRDCKSCALCMD5_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C k s C a l c m d 5 . h h */ 00006 /* */ 00007 /* (c) 2011 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 #include <stdio.h> 00014 00015 #include "XrdCks/XrdCksCalc.hh" 00016 00017 class XrdCksCalcmd5 : public XrdCksCalc 00018 { 00019 public: 00020 00021 char *Current() 00022 {MD5Context saveCTX = myContext; 00023 char *md5P = Final(); 00024 myContext = saveCTX; 00025 return (char *)md5P; 00026 } 00027 00028 void Init(); 00029 00030 XrdCksCalc *New() {return (XrdCksCalc *)new XrdCksCalcmd5;} 00031 00032 char *Final(); 00033 00034 void Update(const char *Buff, int BLen) 00035 {MD5Update((unsigned char *)Buff,(unsigned)BLen);} 00036 00037 const char *Type(int &csSz) {csSz = sizeof(myDigest); return "md5";} 00038 00039 XrdCksCalcmd5() {Init();} 00040 ~XrdCksCalcmd5() {} 00041 00042 private: 00043 00044 struct MD5Context 00045 {unsigned int buf[4]; 00046 unsigned int bits[2]; 00047 unsigned char in[64]; 00048 }; 00049 00050 MD5Context myContext; 00051 unsigned char myDigest[16]; 00052 00053 void byteReverse(unsigned char *buf, unsigned longs); 00054 void MD5Update(unsigned char const *buf, unsigned int len); 00055 00056 #ifndef ASM_MD5 00057 void MD5Transform(unsigned int buf[4], unsigned int const in[16]); 00058 #endif 00059 }; 00060 #endif
1.7.5