MD5: fix compiler warnings and code style nits
This commit is contained in:
parent
57d6d253a1
commit
0d41c3e46b
62
lib/md5.c
62
lib/md5.c
@ -358,7 +358,7 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
|
||||
d += saved_d;
|
||||
|
||||
ptr += 64;
|
||||
} while (size -= 64);
|
||||
} while(size -= 64);
|
||||
|
||||
ctx->a = a;
|
||||
ctx->b = b;
|
||||
@ -385,16 +385,16 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
|
||||
unsigned long used, available;
|
||||
|
||||
saved_lo = ctx->lo;
|
||||
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
|
||||
if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
|
||||
ctx->hi++;
|
||||
ctx->hi += size >> 29;
|
||||
ctx->hi += (MD5_u32plus)size >> 29;
|
||||
|
||||
used = saved_lo & 0x3f;
|
||||
|
||||
if (used) {
|
||||
if(used) {
|
||||
available = 64 - used;
|
||||
|
||||
if (size < available) {
|
||||
if(size < available) {
|
||||
memcpy(&ctx->buffer[used], data, size);
|
||||
return;
|
||||
}
|
||||
@ -405,7 +405,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
|
||||
body(ctx, ctx->buffer, 64);
|
||||
}
|
||||
|
||||
if (size >= 64) {
|
||||
if(size >= 64) {
|
||||
data = body(ctx, data, size & ~(unsigned long)0x3f);
|
||||
size &= 0x3f;
|
||||
}
|
||||
@ -423,7 +423,7 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
|
||||
|
||||
available = 64 - used;
|
||||
|
||||
if (available < 8) {
|
||||
if(available < 8) {
|
||||
memset(&ctx->buffer[used], 0, available);
|
||||
body(ctx, ctx->buffer, 64);
|
||||
used = 0;
|
||||
@ -433,33 +433,33 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
|
||||
memset(&ctx->buffer[used], 0, available - 8);
|
||||
|
||||
ctx->lo <<= 3;
|
||||
ctx->buffer[56] = ctx->lo;
|
||||
ctx->buffer[57] = ctx->lo >> 8;
|
||||
ctx->buffer[58] = ctx->lo >> 16;
|
||||
ctx->buffer[59] = ctx->lo >> 24;
|
||||
ctx->buffer[60] = ctx->hi;
|
||||
ctx->buffer[61] = ctx->hi >> 8;
|
||||
ctx->buffer[62] = ctx->hi >> 16;
|
||||
ctx->buffer[63] = ctx->hi >> 24;
|
||||
ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
|
||||
ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
|
||||
ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
|
||||
ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24);
|
||||
ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
|
||||
ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
|
||||
ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
|
||||
ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
|
||||
|
||||
body(ctx, ctx->buffer, 64);
|
||||
|
||||
result[0] = ctx->a;
|
||||
result[1] = ctx->a >> 8;
|
||||
result[2] = ctx->a >> 16;
|
||||
result[3] = ctx->a >> 24;
|
||||
result[4] = ctx->b;
|
||||
result[5] = ctx->b >> 8;
|
||||
result[6] = ctx->b >> 16;
|
||||
result[7] = ctx->b >> 24;
|
||||
result[8] = ctx->c;
|
||||
result[9] = ctx->c >> 8;
|
||||
result[10] = ctx->c >> 16;
|
||||
result[11] = ctx->c >> 24;
|
||||
result[12] = ctx->d;
|
||||
result[13] = ctx->d >> 8;
|
||||
result[14] = ctx->d >> 16;
|
||||
result[15] = ctx->d >> 24;
|
||||
result[0] = curlx_ultouc((ctx->a)&0xff);
|
||||
result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
|
||||
result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
|
||||
result[3] = curlx_ultouc(ctx->a >> 24);
|
||||
result[4] = curlx_ultouc((ctx->b)&0xff);
|
||||
result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
|
||||
result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
|
||||
result[7] = curlx_ultouc(ctx->b >> 24);
|
||||
result[8] = curlx_ultouc((ctx->c)&0xff);
|
||||
result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
|
||||
result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
|
||||
result[11] = curlx_ultouc(ctx->c >> 24);
|
||||
result[12] = curlx_ultouc((ctx->d)&0xff);
|
||||
result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
|
||||
result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
|
||||
result[15] = curlx_ultouc(ctx->d >> 24);
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user