Changeset 40722 in vbox for trunk/src/VBox/Runtime/common/checksum
- Timestamp:
- Mar 30, 2012 10:10:34 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77187
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/checksum/md5.cpp
r28800 r40722 94 94 /* This is the central step in the MD5 algorithm. */ 95 95 #define MD5STEP(f, w, x, y, z, data, s) \ 96 96 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) 97 97 98 98 … … 194 194 { 195 195 uint32_t t; 196 do { 197 t = *buf; 196 do 197 { 198 t = *buf; 198 199 t = RT_LE2H_U32(t); 199 200 200 *buf = t; 201 buf++; 201 202 } while (--longs); 202 203 } … … 236 237 t = ctx->bits[0]; 237 238 if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) 238 ctx->bits[1]++;/* Carry from low to high */239 ctx->bits[1]++; /* Carry from low to high */ 239 240 ctx->bits[1] += (uint32_t)(len >> 29); 240 241 … … 242 243 243 244 /* Handle any leading odd-sized chunks */ 244 if (t) { 245 uint8_t *p = (uint8_t *) ctx->in + t; 246 247 t = 64 - t; 248 if (len < t) { 249 memcpy(p, buf, len); 250 return; 251 } 252 memcpy(p, buf, t); 253 rtMd5ByteReverse(ctx->in, 16); 254 rtMd5Transform(ctx->buf, ctx->in); 255 buf += t; 256 len -= t; 245 if (t) 246 { 247 uint8_t *p = (uint8_t *) ctx->in + t; 248 249 t = 64 - t; 250 if (len < t) 251 { 252 memcpy(p, buf, len); 253 return; 254 } 255 memcpy(p, buf, t); 256 rtMd5ByteReverse(ctx->in, 16); 257 rtMd5Transform(ctx->buf, ctx->in); 258 buf += t; 259 len -= t; 257 260 } 258 261 … … 306 309 307 310 /* Pad out to 56 mod 64 */ 308 if (count < 8) { 309 /* Two lots of padding: Pad the first block to 64 bytes */ 310 memset(p, 0, count); 311 rtMd5ByteReverse(ctx->in, 16); 312 rtMd5Transform(ctx->buf, ctx->in); 313 314 /* Now fill the next block with 56 bytes */ 315 memset(ctx->in, 0, 56); 316 } else { 317 /* Pad block to 56 bytes */ 318 memset(p, 0, count - 8); 311 if (count < 8) 312 { 313 /* Two lots of padding: Pad the first block to 64 bytes */ 314 memset(p, 0, count); 315 rtMd5ByteReverse(ctx->in, 16); 316 rtMd5Transform(ctx->buf, ctx->in); 317 318 /* Now fill the next block with 56 bytes */ 319 memset(ctx->in, 0, 56); 320 } 321 else 322 { 323 /* Pad block to 56 bytes */ 324 memset(p, 0, count - 8); 319 325 } 320 326 rtMd5ByteReverse(ctx->in, 14); … … 327 333 rtMd5ByteReverse(ctx->buf, 4); 328 334 memcpy(digest, ctx->buf, 16); 329 memset(ctx, 0, sizeof( ctx)); /* In case it's sensitive */335 memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ 330 336 } 331 337 RT_EXPORT_SYMBOL(RTMd5Final);
Note:
See TracChangeset
for help on using the changeset viewer.