47 fBits(), fIn(), fString(), fDigest(), fFinalized(
kFALSE)
59 fBuf(), fBits(), fIn(), fString(), fFinalized(
kTRUE)
65 Error(
"TMD5::TMD5",
"digest is 0");
109 Error(
"TMD5::Update",
"Final() has already been called");
117 if ((
fBits[0] = t + (len << 3)) < t)
119 fBits[1] += len >> 29;
140 memcpy(
fIn, buf, 64);
147 memcpy(
fIn, buf, len);
174 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
183 count = (
fBits[0] >> 3) & 0x3f;
184 padLen = (count < 56) ? (56 - count) : (120 - count);
207 Error(
"TMD5::Print",
"Final() has not yet been called");
221 Error(
"TMD5::AsString",
"Final() has not yet been called");
226 static const char hexdig[] =
"0123456789abcdef";
227 for (
int i = 0; i < 16; ++i) {
229 fString[i * 2 + 1] = hexdig[fDigest[i] % 16];
242 for (i = 0, j = 0; j < len; i++, j += 4) {
243 out[j] = (
UChar_t)(in[i] & 0xff);
244 out[j+1] = (
UChar_t)((in[i] >> 8) & 0xff);
245 out[j+2] = (
UChar_t)((in[i] >> 16) & 0xff);
246 out[j+3] = (
UChar_t)((in[i] >> 24) & 0xff);
257 for (i = 0, j = 0; j < len; i++, j += 4)
265 #define F1(x, y, z) (z ^ (x & (y ^ z)))
266 #define F2(x, y, z) F1(z, x, y)
267 #define F3(x, y, z) (x ^ y ^ z)
268 #define F4(x, y, z) (y ^ (x | ~z))
271 #define MD5STEP(f, w, x, y, z, data, s) \
272 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
290 MD5STEP(
F1, a, b, c, d, x[0] + 0xd76aa478, 7);
291 MD5STEP(
F1, d, a, b, c, x[1] + 0xe8c7b756, 12);
292 MD5STEP(
F1, c, d, a, b, x[2] + 0x242070db, 17);
293 MD5STEP(
F1, b, c, d, a, x[3] + 0xc1bdceee, 22);
294 MD5STEP(
F1, a, b, c, d, x[4] + 0xf57c0faf, 7);
295 MD5STEP(
F1, d, a, b, c, x[5] + 0x4787c62a, 12);
296 MD5STEP(
F1, c, d, a, b, x[6] + 0xa8304613, 17);
297 MD5STEP(
F1, b, c, d, a, x[7] + 0xfd469501, 22);
298 MD5STEP(
F1, a, b, c, d, x[8] + 0x698098d8, 7);
299 MD5STEP(
F1, d, a, b, c, x[9] + 0x8b44f7af, 12);
300 MD5STEP(
F1, c, d, a, b, x[10] + 0xffff5bb1, 17);
301 MD5STEP(
F1, b, c, d, a, x[11] + 0x895cd7be, 22);
302 MD5STEP(
F1, a, b, c, d, x[12] + 0x6b901122, 7);
303 MD5STEP(
F1, d, a, b, c, x[13] + 0xfd987193, 12);
304 MD5STEP(
F1, c, d, a, b, x[14] + 0xa679438e, 17);
305 MD5STEP(
F1, b, c, d, a, x[15] + 0x49b40821, 22);
307 MD5STEP(
F2, a, b, c, d, x[1] + 0xf61e2562, 5);
308 MD5STEP(
F2, d, a, b, c, x[6] + 0xc040b340, 9);
309 MD5STEP(
F2, c, d, a, b, x[11] + 0x265e5a51, 14);
310 MD5STEP(
F2, b, c, d, a, x[0] + 0xe9b6c7aa, 20);
311 MD5STEP(
F2, a, b, c, d, x[5] + 0xd62f105d, 5);
312 MD5STEP(
F2, d, a, b, c, x[10] + 0x02441453, 9);
313 MD5STEP(
F2, c, d, a, b, x[15] + 0xd8a1e681, 14);
314 MD5STEP(
F2, b, c, d, a, x[4] + 0xe7d3fbc8, 20);
315 MD5STEP(
F2, a, b, c, d, x[9] + 0x21e1cde6, 5);
316 MD5STEP(
F2, d, a, b, c, x[14] + 0xc33707d6, 9);
317 MD5STEP(
F2, c, d, a, b, x[3] + 0xf4d50d87, 14);
318 MD5STEP(
F2, b, c, d, a, x[8] + 0x455a14ed, 20);
319 MD5STEP(
F2, a, b, c, d, x[13] + 0xa9e3e905, 5);
320 MD5STEP(
F2, d, a, b, c, x[2] + 0xfcefa3f8, 9);
321 MD5STEP(
F2, c, d, a, b, x[7] + 0x676f02d9, 14);
322 MD5STEP(
F2, b, c, d, a, x[12] + 0x8d2a4c8a, 20);
324 MD5STEP(
F3, a, b, c, d, x[5] + 0xfffa3942, 4);
325 MD5STEP(
F3, d, a, b, c, x[8] + 0x8771f681, 11);
326 MD5STEP(
F3, c, d, a, b, x[11] + 0x6d9d6122, 16);
327 MD5STEP(
F3, b, c, d, a, x[14] + 0xfde5380c, 23);
328 MD5STEP(
F3, a, b, c, d, x[1] + 0xa4beea44, 4);
329 MD5STEP(
F3, d, a, b, c, x[4] + 0x4bdecfa9, 11);
330 MD5STEP(
F3, c, d, a, b, x[7] + 0xf6bb4b60, 16);
331 MD5STEP(
F3, b, c, d, a, x[10] + 0xbebfbc70, 23);
332 MD5STEP(
F3, a, b, c, d, x[13] + 0x289b7ec6, 4);
333 MD5STEP(
F3, d, a, b, c, x[0] + 0xeaa127fa, 11);
334 MD5STEP(
F3, c, d, a, b, x[3] + 0xd4ef3085, 16);
335 MD5STEP(
F3, b, c, d, a, x[6] + 0x04881d05, 23);
336 MD5STEP(
F3, a, b, c, d, x[9] + 0xd9d4d039, 4);
337 MD5STEP(
F3, d, a, b, c, x[12] + 0xe6db99e5, 11);
338 MD5STEP(
F3, c, d, a, b, x[15] + 0x1fa27cf8, 16);
339 MD5STEP(
F3, b, c, d, a, x[2] + 0xc4ac5665, 23);
341 MD5STEP(
F4, a, b, c, d, x[0] + 0xf4292244, 6);
342 MD5STEP(
F4, d, a, b, c, x[7] + 0x432aff97, 10);
343 MD5STEP(
F4, c, d, a, b, x[14] + 0xab9423a7, 15);
344 MD5STEP(
F4, b, c, d, a, x[5] + 0xfc93a039, 21);
345 MD5STEP(
F4, a, b, c, d, x[12] + 0x655b59c3, 6);
346 MD5STEP(
F4, d, a, b, c, x[3] + 0x8f0ccc92, 10);
347 MD5STEP(
F4, c, d, a, b, x[10] + 0xffeff47d, 15);
348 MD5STEP(
F4, b, c, d, a, x[1] + 0x85845dd1, 21);
349 MD5STEP(
F4, a, b, c, d, x[8] + 0x6fa87e4f, 6);
350 MD5STEP(
F4, d, a, b, c, x[15] + 0xfe2ce6e0, 10);
351 MD5STEP(
F4, c, d, a, b, x[6] + 0xa3014314, 15);
352 MD5STEP(
F4, b, c, d, a, x[13] + 0x4e0811a1, 21);
353 MD5STEP(
F4, a, b, c, d, x[4] + 0xf7537e82, 6);
354 MD5STEP(
F4, d, a, b, c, x[11] + 0xbd3af235, 10);
355 MD5STEP(
F4, c, d, a, b, x[2] + 0x2ad7d2bb, 15);
356 MD5STEP(
F4, b, c, d, a, x[9] + 0xeb86d391, 21);
364 memset(x, 0,
sizeof(x));
375 Error(
"TMD5::operator==(const TMD5&, const TMD5&)",
"arg1.Final() not yet called");
377 Error(
"TMD5::operator==(const TMD5&, const TMD5&)",
"arg2.Final() not yet called");
381 for (
int i = 0; i < 16; i++)
395 if (!md5ascii || strlen(md5ascii) < 32) {
400 char *buf = (
char *) md5ascii;
401 for (
int i = 0; i < 16; i++) {
405 sscanf(buf+2*i,
"%hx", &d);
422 FILE *fid = fopen(file,
"r");
430 if (!fgets(buf, 33, fid)) {
431 SysError(
"TMD5::ReadChecksum",
"error reading checksum from %s", file);
452 FILE *fid = fopen(file,
"w");
478 Error(
"TMD5::FileChecksum",
"%s not a regular file (%ld)", file, flags);
492 Error(
"TMD5::FileChecksum",
"cannot open %s in read mode", file);
499 const Int_t bufSize = 8192;
509 if (siz < 0 || siz != left) {
510 Error(
"TMD5::FileChecksum",
"error reading from file %s", file);
540 memcpy(digest, md5->
fDigest, 16);
544 memset(digest, 0, 16);
556 const_cast<TMD5&
>(uuid).Streamer(buf);
void Print() const
Print digest in ascii hex form.
double read(const std::string &file_name)
reading
static TMD5 * FileChecksum(const char *file)
Returns checksum of specified file.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
void Encode(UChar_t *out, const UInt_t *in, UInt_t len)
Encodes input into output. Assumes len is a multiple of 4.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Buffer base class used for serializing objects.
TMD5 & operator=(const TMD5 &rhs)
MD5 assignment operator.
void SysError(const char *location, const char *msgfmt,...)
static Int_t GetErrno()
Static function returning system error number.
void Decode(UInt_t *out, const UChar_t *in, UInt_t len)
Decodes input into output. Assumes len is a multiple of 4.
const char * AsString() const
Return message digest as string.
This code implements the MD5 message-digest algorithm.
void Error(const char *location, const char *msgfmt,...)
Char_t fString[33]
temp buffer
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
R__EXTERN TSystem * gSystem
static Int_t WriteChecksum(const char *file, const TMD5 *md5)
Writes checksum in ASCII format to specified file.
UChar_t fIn[64]
temp buffer
virtual int Utime(const char *file, Long_t modtime, Long_t actime)
Set the a files modification and access times.
#define MD5STEP(f, w, x, y, z, data, s)
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
Int_t SetDigest(const char *md5ascii)
Set the digest from the ASCII representation 'md5ascii'.
Bool_t operator==(const TMD5 &m1, const TMD5 &m2)
Compare two message digests for equality.
static void ResetErrno()
Static function resetting system error number.
static TMD5 * ReadChecksum(const char *file)
Returns checksum stored in ASCII in specified file.
UChar_t fDigest[16]
string representation of digest
ClassImp(TMD5) TMD5
Create TMD5 object.
UInt_t fBits[2]
temp buffer
TBuffer & operator<<(TBuffer &buf, const TMD5 &uuid)
Input operator. Delegate to Streamer.
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 longwor...