|
|
@ -259,7 +259,7 @@ void MD5Update( MD5Context_t *ctx, const byte *buf, uint len ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
memcpy( p, buf, t ); |
|
|
|
memcpy( p, buf, t ); |
|
|
|
MD5Transform( ctx->buf, (uint *)ctx->in ); |
|
|
|
MD5Transform( ctx->buf, ctx->in ); |
|
|
|
buf += t; |
|
|
|
buf += t; |
|
|
|
len -= t; |
|
|
|
len -= t; |
|
|
|
} |
|
|
|
} |
|
|
@ -268,7 +268,7 @@ void MD5Update( MD5Context_t *ctx, const byte *buf, uint len ) |
|
|
|
while( len >= 64 ) |
|
|
|
while( len >= 64 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy( ctx->in, buf, 64 ); |
|
|
|
memcpy( ctx->in, buf, 64 ); |
|
|
|
MD5Transform( ctx->buf, (uint *)ctx->in ); |
|
|
|
MD5Transform( ctx->buf, ctx->in ); |
|
|
|
buf += 64; |
|
|
|
buf += 64; |
|
|
|
len -= 64; |
|
|
|
len -= 64; |
|
|
|
} |
|
|
|
} |
|
|
@ -307,7 +307,7 @@ void MD5Final( byte digest[16], MD5Context_t *ctx ) |
|
|
|
|
|
|
|
|
|
|
|
// two lots of padding: pad the first block to 64 bytes
|
|
|
|
// two lots of padding: pad the first block to 64 bytes
|
|
|
|
memset( p, 0, count ); |
|
|
|
memset( p, 0, count ); |
|
|
|
MD5Transform( ctx->buf, (uint *)ctx->in ); |
|
|
|
MD5Transform( ctx->buf, ctx->in ); |
|
|
|
|
|
|
|
|
|
|
|
// now fill the next block with 56 bytes
|
|
|
|
// now fill the next block with 56 bytes
|
|
|
|
memset( ctx->in, 0, 56 ); |
|
|
|
memset( ctx->in, 0, 56 ); |
|
|
@ -319,10 +319,10 @@ void MD5Final( byte digest[16], MD5Context_t *ctx ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// append length in bits and transform
|
|
|
|
// append length in bits and transform
|
|
|
|
((uint *)ctx->in)[14] = ctx->bits[0]; |
|
|
|
ctx->in[14] = ctx->bits[0]; |
|
|
|
((uint *)ctx->in)[15] = ctx->bits[1]; |
|
|
|
ctx->in[15] = ctx->bits[1]; |
|
|
|
|
|
|
|
|
|
|
|
MD5Transform( ctx->buf, (uint *)ctx->in ); |
|
|
|
MD5Transform( ctx->buf, ctx->in ); |
|
|
|
memcpy( digest, ctx->buf, 16 ); |
|
|
|
memcpy( digest, ctx->buf, 16 ); |
|
|
|
memset( ctx, 0, sizeof( *ctx )); // in case it's sensitive
|
|
|
|
memset( ctx, 0, sizeof( *ctx )); // in case it's sensitive
|
|
|
|
} |
|
|
|
} |
|
|
|