Changeset 6496 for trunk/licq
- Timestamp:
- 08/24/08 22:40:12 (3 months ago)
- Location:
- trunk/licq
- Files:
-
- 2 modified
-
include/licq_md5.h (modified) (1 diff)
-
src/md5.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/licq/include/licq_md5.h
r6495 r6496 20 20 { 21 21 uint32_t buf[4]; 22 uint 32_t bytes[2];22 uint64_t bytes; 23 23 uint32_t in[16]; 24 24 }; -
trunk/licq/src/md5.cpp
r6495 r6496 54 54 ctx->buf[2] = 0x98badcfe; 55 55 ctx->buf[3] = 0x10325476; 56 ctx->bytes[0] = 0; 57 ctx->bytes[1] = 0; 56 ctx->bytes = 0; 58 57 } 59 58 … … 64 63 void MD5Update(struct MD5Context* ctx, uint8_t const* buf, size_t len) 65 64 { 65 /* Space available in ctx->in (at least 1) */ 66 uint32_t t = 64 - (ctx->bytes & 0x3f); 67 66 68 /* Update byte count */ 67 uint32_t t = ctx->bytes[0]; 68 if ((ctx->bytes[0] = t + len) < t) 69 ctx->bytes[1]++; /* Carry from low to high */ 70 71 t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ 69 ctx->bytes += len; 70 72 71 if (t > len) { 73 72 memcpy((uint8_t*)ctx->in + 64 - t, buf, len); … … 100 99 void MD5Final(uint8_t digest[16], struct MD5Context *ctx) 101 100 { 102 int count = ctx->bytes[0] & 0x3f;/* Number of bytes in ctx->in */101 int count = ctx->bytes & 0x3f; /* Number of bytes in ctx->in */ 103 102 uint8_t* p = (uint8_t*)ctx->in + count; 104 103 … … 120 119 121 120 /* Append length in bits and transform */ 122 ctx->in[14] = ctx->bytes[0]<< 3;123 ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0]>> 29;121 ctx->in[14] = ctx->bytes << 3; 122 ctx->in[15] = ctx->bytes >> 29; 124 123 MD5Transform(ctx->buf, ctx->in); 125 124
