48 fBits(), fIn(), fString(), fDigest(), fFinalized(
kFALSE)
60 fBuf(), fBits(), fIn(), fString(), fFinalized(
kTRUE)
66 Error(
"TMD5::TMD5",
"digest is 0");
110 Error(
"TMD5::Update",
"Final() has already been called");
118 if ((
fBits[0] = t + (len << 3)) < t)
120 fBits[1] += len >> 29;
141 memcpy(
fIn, buf, 64);
148 memcpy(
fIn, buf, len);
175 0x80, 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, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
184 count = (
fBits[0] >> 3) & 0x3f;
185 padLen = (count < 56) ? (56 - count) : (120 - count);
208 Error(
"TMD5::Print",
"Final() has not yet been called");
222 Error(
"TMD5::AsString",
"Final() has not yet been called");
227 static const char hexdig[] =
"0123456789abcdef";
228 for (
int i = 0; i < 16; ++i) {
230 fString[i * 2 + 1] = hexdig[fDigest[i] % 16];
243 for (i = 0, j = 0; j < len; i++, j += 4) {
244 out[j] = (
UChar_t)(in[i] & 0xff);
245 out[j+1] = (
UChar_t)((in[i] >> 8) & 0xff);
246 out[j+2] = (
UChar_t)((in[i] >> 16) & 0xff);
247 out[j+3] = (
UChar_t)((in[i] >> 24) & 0xff);
258 for (i = 0, j = 0; j < len; i++, j += 4)
266 #define F1(x, y, z) (z ^ (x & (y ^ z)))
267 #define F2(x, y, z) F1(z, x, y)
268 #define F3(x, y, z) (x ^ y ^ z)
269 #define F4(x, y, z) (y ^ (x | ~z))
272 #define MD5STEP(f, w, x, y, z, data, s) \
273 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
291 MD5STEP(
F1, a, b, c, d, x[0] + 0xd76aa478, 7);
292 MD5STEP(
F1, d, a, b, c, x[1] + 0xe8c7b756, 12);
293 MD5STEP(
F1, c, d, a, b, x[2] + 0x242070db, 17);
294 MD5STEP(
F1, b, c, d, a, x[3] + 0xc1bdceee, 22);
295 MD5STEP(
F1, a, b, c, d, x[4] + 0xf57c0faf, 7);
296 MD5STEP(
F1, d, a, b, c, x[5] + 0x4787c62a, 12);
297 MD5STEP(
F1, c, d, a, b, x[6] + 0xa8304613, 17);
298 MD5STEP(
F1, b, c, d, a, x[7] + 0xfd469501, 22);
299 MD5STEP(
F1, a, b, c, d, x[8] + 0x698098d8, 7);
300 MD5STEP(
F1, d, a, b, c, x[9] + 0x8b44f7af, 12);
301 MD5STEP(
F1, c, d, a, b, x[10] + 0xffff5bb1, 17);
302 MD5STEP(
F1, b, c, d, a, x[11] + 0x895cd7be, 22);
303 MD5STEP(
F1, a, b, c, d, x[12] + 0x6b901122, 7);
304 MD5STEP(
F1, d, a, b, c, x[13] + 0xfd987193, 12);
305 MD5STEP(
F1, c, d, a, b, x[14] + 0xa679438e, 17);
306 MD5STEP(
F1, b, c, d, a, x[15] + 0x49b40821, 22);
308 MD5STEP(
F2, a, b, c, d, x[1] + 0xf61e2562, 5);
309 MD5STEP(
F2, d, a, b, c, x[6] + 0xc040b340, 9);
310 MD5STEP(
F2, c, d, a, b, x[11] + 0x265e5a51, 14);
311 MD5STEP(
F2, b, c, d, a, x[0] + 0xe9b6c7aa, 20);
312 MD5STEP(
F2, a, b, c, d, x[5] + 0xd62f105d, 5);
313 MD5STEP(
F2, d, a, b, c, x[10] + 0x02441453, 9);
314 MD5STEP(
F2, c, d, a, b, x[15] + 0xd8a1e681, 14);
315 MD5STEP(
F2, b, c, d, a, x[4] + 0xe7d3fbc8, 20);
316 MD5STEP(
F2, a, b, c, d, x[9] + 0x21e1cde6, 5);
317 MD5STEP(
F2, d, a, b, c, x[14] + 0xc33707d6, 9);
318 MD5STEP(
F2, c, d, a, b, x[3] + 0xf4d50d87, 14);
319 MD5STEP(
F2, b, c, d, a, x[8] + 0x455a14ed, 20);
320 MD5STEP(
F2, a, b, c, d, x[13] + 0xa9e3e905, 5);
321 MD5STEP(
F2, d, a, b, c, x[2] + 0xfcefa3f8, 9);
322 MD5STEP(
F2, c, d, a, b, x[7] + 0x676f02d9, 14);
323 MD5STEP(
F2, b, c, d, a, x[12] + 0x8d2a4c8a, 20);
325 MD5STEP(
F3, a, b, c, d, x[5] + 0xfffa3942, 4);
326 MD5STEP(
F3, d, a, b, c, x[8] + 0x8771f681, 11);
327 MD5STEP(
F3, c, d, a, b, x[11] + 0x6d9d6122, 16);
328 MD5STEP(
F3, b, c, d, a, x[14] + 0xfde5380c, 23);
329 MD5STEP(
F3, a, b, c, d, x[1] + 0xa4beea44, 4);
330 MD5STEP(
F3, d, a, b, c, x[4] + 0x4bdecfa9, 11);
331 MD5STEP(
F3, c, d, a, b, x[7] + 0xf6bb4b60, 16);
332 MD5STEP(
F3, b, c, d, a, x[10] + 0xbebfbc70, 23);
333 MD5STEP(
F3, a, b, c, d, x[13] + 0x289b7ec6, 4);
334 MD5STEP(
F3, d, a, b, c, x[0] + 0xeaa127fa, 11);
335 MD5STEP(
F3, c, d, a, b, x[3] + 0xd4ef3085, 16);
336 MD5STEP(
F3, b, c, d, a, x[6] + 0x04881d05, 23);
337 MD5STEP(
F3, a, b, c, d, x[9] + 0xd9d4d039, 4);
338 MD5STEP(
F3, d, a, b, c, x[12] + 0xe6db99e5, 11);
339 MD5STEP(
F3, c, d, a, b, x[15] + 0x1fa27cf8, 16);
340 MD5STEP(
F3, b, c, d, a, x[2] + 0xc4ac5665, 23);
342 MD5STEP(
F4, a, b, c, d, x[0] + 0xf4292244, 6);
343 MD5STEP(
F4, d, a, b, c, x[7] + 0x432aff97, 10);
344 MD5STEP(
F4, c, d, a, b, x[14] + 0xab9423a7, 15);
345 MD5STEP(
F4, b, c, d, a, x[5] + 0xfc93a039, 21);
346 MD5STEP(
F4, a, b, c, d, x[12] + 0x655b59c3, 6);
347 MD5STEP(
F4, d, a, b, c, x[3] + 0x8f0ccc92, 10);
348 MD5STEP(
F4, c, d, a, b, x[10] + 0xffeff47d, 15);
349 MD5STEP(
F4, b, c, d, a, x[1] + 0x85845dd1, 21);
350 MD5STEP(
F4, a, b, c, d, x[8] + 0x6fa87e4f, 6);
351 MD5STEP(
F4, d, a, b, c, x[15] + 0xfe2ce6e0, 10);
352 MD5STEP(
F4, c, d, a, b, x[6] + 0xa3014314, 15);
353 MD5STEP(
F4, b, c, d, a, x[13] + 0x4e0811a1, 21);
354 MD5STEP(
F4, a, b, c, d, x[4] + 0xf7537e82, 6);
355 MD5STEP(
F4, d, a, b, c, x[11] + 0xbd3af235, 10);
356 MD5STEP(
F4, c, d, a, b, x[2] + 0x2ad7d2bb, 15);
357 MD5STEP(
F4, b, c, d, a, x[9] + 0xeb86d391, 21);
365 memset(x, 0,
sizeof(x));
376 Error(
"TMD5::operator==(const TMD5&, const TMD5&)",
"arg1.Final() not yet called");
378 Error(
"TMD5::operator==(const TMD5&, const TMD5&)",
"arg2.Final() not yet called");
382 for (
int i = 0; i < 16; i++)
396 if (!md5ascii || strlen(md5ascii) < 32) {
401 char *buf = (
char *) md5ascii;
402 for (
int i = 0; i < 16; i++) {
406 sscanf(buf+2*i,
"%hx", &d);
423 FILE *fid = fopen(file,
"r");
431 if (!fgets(buf, 33, fid)) {
432 SysError(
"TMD5::ReadChecksum",
"error reading checksum from %s", file);
453 FILE *fid = fopen(file,
"w");
479 Error(
"TMD5::FileChecksum",
"%s not a regular file (%ld)", file, flags);
493 Error(
"TMD5::FileChecksum",
"cannot open %s in read mode", file);
500 const Int_t bufSize = 8192;
510 if (siz < 0 || siz != left) {
511 Error(
"TMD5::FileChecksum",
"error reading from file %s", file);
541 memcpy(digest, md5->
fDigest, 16);
545 memset(digest, 0, 16);
557 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...