ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
TMD5 Class Reference

This code implements the MD5 message-digest algorithm.

The algorithm is due to Ron Rivest. This code was written by Colin Plumb in 1993, no copyright is claimed. This code is in the public domain; do with it what you wish.

Equivalent code is available from RSA Data Security, Inc. This code has been tested against that, and is equivalent, except that you don't need to include two pages of legalese with every copy.

To compute the message digest of a chunk of bytes, create an TMD5 object, call Update() as needed on buffers full of bytes, and then call Final(), which will, optionally, fill a supplied 16-byte array with the digest.

Definition at line 46 of file TMD5.h.

Public Member Functions

 TMD5 ()
 
 TMD5 (const UChar_t *digest)
 Create finalized TMD5 object containing passed in 16 byte digest. More...
 
 TMD5 (const TMD5 &md5)
 MD5 copy ctor. More...
 
virtual ~TMD5 ()
 
TMD5operator= (const TMD5 &rhs)
 MD5 assignment operator. More...
 
void Update (const UChar_t *buf, UInt_t len)
 Update TMD5 object to reflect the concatenation of another buffer full of bytes. More...
 
void Final ()
 MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. More...
 
void Final (UChar_t digest[16])
 MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. More...
 
void Print () const
 Print digest in ascii hex form. More...
 
const char * AsString () const
 Return message digest as string. More...
 
Int_t SetDigest (const char *md5ascii)
 Set the digest from the ASCII representation 'md5ascii'. More...
 

Static Public Member Functions

static TMD5ReadChecksum (const char *file)
 Returns checksum stored in ASCII in specified file. More...
 
static Int_t WriteChecksum (const char *file, const TMD5 *md5)
 Writes checksum in ASCII format to specified file. More...
 
static TMD5FileChecksum (const char *file)
 Returns checksum of specified file. More...
 
static Int_t FileChecksum (const char *file, UChar_t digest[16])
 Returns checksum of specified file in digest argument. More...
 

Private Member Functions

void Transform (UInt_t buf[4], const UChar_t in[64])
 The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data. More...
 
void Encode (UChar_t *out, const UInt_t *in, UInt_t len)
 Encodes input into output. Assumes len is a multiple of 4. More...
 
void Decode (UInt_t *out, const UChar_t *in, UInt_t len)
 Decodes input into output. Assumes len is a multiple of 4. More...
 

Private Attributes

UInt_t fBuf [4]
 
UInt_t fBits [2]
 temp buffer More...
 
UChar_t fIn [64]
 temp buffer More...
 
Char_t fString [33]
 temp buffer More...
 
UChar_t fDigest [16]
 string representation of digest More...
 
Bool_t fFinalized
 

Friends

Bool_t operator== (const TMD5 &m1, const TMD5 &m2)
 Compare two message digests for equality. More...
 

#include <TMD5.h>

Constructor & Destructor Documentation

TMD5::TMD5 ( )

Referenced by FileChecksum(), and ReadChecksum().

TMD5::TMD5 ( const UChar_t digest)

Create finalized TMD5 object containing passed in 16 byte digest.

Definition at line 59 of file TMD5.cxx.

TMD5::TMD5 ( const TMD5 md5)

MD5 copy ctor.

Special copy ctor avoids copying unnecessary temp arrays when finalized.

Definition at line 74 of file TMD5.cxx.

virtual TMD5::~TMD5 ( )
inlinevirtual

Definition at line 66 of file TMD5.h.

Member Function Documentation

const char * TMD5::AsString ( ) const
void TMD5::Decode ( UInt_t out,
const UChar_t in,
UInt_t  len 
)
private

Decodes input into output. Assumes len is a multiple of 4.

Definition at line 254 of file TMD5.cxx.

Referenced by Transform().

void TMD5::Encode ( UChar_t out,
const UInt_t in,
UInt_t  len 
)
private

Encodes input into output. Assumes len is a multiple of 4.

Definition at line 239 of file TMD5.cxx.

Referenced by Final().

TMD5 * TMD5::FileChecksum ( const char *  file)
static

Returns checksum of specified file.

The returned TMD5 object must be deleted by the user. Returns 0 in case the file does not exists or in case of error. This function preserves the modtime of the file so it can be safely used in conjunction with methods that keep track of the file's modtime. Static utility function.

Definition at line 473 of file TMD5.cxx.

Referenced by TProof::BuildPackageOnClient(), TApplicationRemote::CheckFile(), TProof::CheckFile(), TDataSetManagerFile::CheckLocalCache(), TDataSetManagerFile::ChecksumDataSet(), TProofLite::CopyMacroToCache(), TDataSetManagerFile::CreateLsFile(), FileChecksum(), TXProofMgr::GetFile(), TProofServ::HandleCache(), TApplicationServer::HandleCheckFile(), TProofServ::HandleCheckFile(), TDataSetManagerFile::NotifyUpdate(), TSelEventGen::Process(), TXProofMgr::PutFile(), TProofPlayer::ReinitSelector(), TProof::UploadPackage(), and TDataSetManagerFile::WriteDataSet().

Int_t TMD5::FileChecksum ( const char *  file,
UChar_t  digest[16] 
)
static

Returns checksum of specified file in digest argument.

Returns -1 in case of error, 0 otherwise. This method preserves the modtime of the file so it can be safely used in conjunction with methods that keep track of the file's modtime. Static utility function.

Definition at line 537 of file TMD5.cxx.

void TMD5::Final ( )

MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing the context.

Definition at line 166 of file TMD5.cxx.

Referenced by Memstat::TMemStatMng::AddPointer(), TFilePrefetch::CheckBlockInCache(), TMacro::Checksum(), TMakeProject::ChopFileName(), FileChecksum(), Final(), TUUID::GetRandomInfo(), TAliEnFind::GetSearchId(), TString::MD5(), TFileInfo::Print(), and TFilePrefetch::SaveBlockInCache().

void TMD5::Final ( UChar_t  digest[16])

MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing the context.

Returns digest.

Definition at line 156 of file TMD5.cxx.

TMD5 & TMD5::operator= ( const TMD5 rhs)

MD5 assignment operator.

Special assignment operator avoids copying unnecessary temp arrays when finalized.

Definition at line 89 of file TMD5.cxx.

void TMD5::Print ( ) const

Print digest in ascii hex form.

Definition at line 205 of file TMD5.cxx.

TMD5 * TMD5::ReadChecksum ( const char *  file)
static

Returns checksum stored in ASCII in specified file.

Use to read files created via WriteChecksum(). The returned TMD5 object must be deleted by the user. Returns 0 in case the file cannot be opened or in case of error. Static utility function.

Definition at line 421 of file TMD5.cxx.

Referenced by TDataSetManagerFile::CheckLocalCache(), TDataSetManagerFile::GetDataSet(), TProofServ::HandleCheckFile(), and TProof::UploadPackageOnClient().

Int_t TMD5::SetDigest ( const char *  md5ascii)

Set the digest from the ASCII representation 'md5ascii'.

The caller is responsible to make sure that the 32 chars md5ascii are valid. Returns -1 if md5ascii is malformed, returns 0 otherwise.

Definition at line 394 of file TMD5.cxx.

Referenced by TFileInfo::ParseInput(), and ReadChecksum().

void TMD5::Transform ( UInt_t  buf[4],
const UChar_t  in[64] 
)
private

The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data.

Update() blocks the data and converts bytes into longwords for this routine.

Definition at line 280 of file TMD5.cxx.

Referenced by Update().

void TMD5::Update ( const UChar_t buf,
UInt_t  len 
)
Int_t TMD5::WriteChecksum ( const char *  file,
const TMD5 md5 
)
static

Writes checksum in ASCII format to specified file.

This file can directly be read by ReadChecksum(). The md5 must have been finalized. Returns -1 in case file cannot be opened or in case of error, 0 otherwise. Static utility function.

Definition at line 451 of file TMD5.cxx.

Referenced by TDataSetManagerFile::CheckLocalCache(), TDataSetManagerFile::ChecksumDataSet(), TProofServ::HandleCache(), TProofServ::HandleCheckFile(), and TProof::UploadPackageOnClient().

Friends And Related Function Documentation

Bool_t operator== ( const TMD5 m1,
const TMD5 m2 
)
friend

Compare two message digests for equality.

Definition at line 371 of file TMD5.cxx.

Member Data Documentation

UInt_t TMD5::fBits[2]
private

temp buffer

Definition at line 52 of file TMD5.h.

Referenced by Final(), operator=(), TMD5(), and Update().

UInt_t TMD5::fBuf[4]
private

Definition at line 51 of file TMD5.h.

Referenced by Final(), operator=(), TMD5(), and Update().

UChar_t TMD5::fDigest[16]
private

string representation of digest

Definition at line 55 of file TMD5.h.

Referenced by AsString(), FileChecksum(), Final(), operator=(), operator==(), SetDigest(), and TMD5().

Bool_t TMD5::fFinalized
private

Definition at line 56 of file TMD5.h.

Referenced by AsString(), Final(), operator=(), operator==(), Print(), SetDigest(), TMD5(), and Update().

UChar_t TMD5::fIn[64]
private

temp buffer

Definition at line 53 of file TMD5.h.

Referenced by Final(), operator=(), TMD5(), and Update().

Char_t TMD5::fString[33]
mutableprivate

temp buffer

Definition at line 54 of file TMD5.h.

Referenced by AsString(), and operator=().


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