Index: base/md5.cc |
diff --git a/base/md5.cc b/base/md5.cc |
index 6227ee66042212dfaf2e28dba7197d7e2bbfb2dc..48c1a97effd7860b2a7449d30fc98c0ae5b1ca41 100644 |
--- a/base/md5.cc |
+++ b/base/md5.cc |
@@ -23,13 +23,14 @@ |
#include "base/md5.h" |
-#include "base/basictypes.h" |
+#include <stddef.h> |
+#include <stdint.h> |
namespace { |
struct Context { |
- uint32 buf[4]; |
- uint32 bits[2]; |
+ uint32_t buf[4]; |
+ uint32_t bits[2]; |
unsigned char in[64]; |
}; |
@@ -37,12 +38,12 @@ struct Context { |
* Note: this code is harmless on little-endian machines. |
*/ |
void byteReverse(unsigned char *buf, unsigned longs) { |
- uint32 t; |
+ uint32_t t; |
do { |
- t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 | |
- ((unsigned)buf[1]<<8 | buf[0]); |
- *(uint32 *)buf = t; |
- buf += 4; |
+ t = (uint32_t)((unsigned)buf[3] << 8 | buf[2]) << 16 | |
Nico
2015/04/01 17:38:40
Hm, running clang-format on files that aren't clan
tfarina
2015/04/01 17:57:48
I'm open to do anything you prefer. I think we hav
|
+ ((unsigned)buf[1] << 8 | buf[0]); |
+ *(uint32_t*)buf = t; |
+ buf += 4; |
} while (--longs); |
} |
@@ -63,8 +64,8 @@ void byteReverse(unsigned char *buf, unsigned longs) { |
* reflect the addition of 16 longwords of new data. MD5Update blocks |
* the data and converts bytes into longwords for this routine. |
*/ |
-void MD5Transform(uint32 buf[4], const uint32 in[16]) { |
- register uint32 a, b, c, d; |
+void MD5Transform(uint32_t buf[4], const uint32_t in[16]) { |
+ uint32_t a, b, c, d; |
a = buf[0]; |
b = buf[1]; |
@@ -172,14 +173,14 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
size_t len = data.size(); |
struct Context *ctx = (struct Context *)context; |
const unsigned char* buf = (const unsigned char*)inbuf; |
- uint32 t; |
+ uint32_t t; |
/* Update bitcount */ |
t = ctx->bits[0]; |
- if ((ctx->bits[0] = t + ((uint32)len << 3)) < t) |
+ if ((ctx->bits[0] = t + ((uint32_t)len << 3)) < t) |
ctx->bits[1]++; /* Carry from low to high */ |
- ctx->bits[1] += static_cast<uint32>(len >> 29); |
+ ctx->bits[1] += static_cast<uint32_t>(len >> 29); |
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ |
@@ -195,7 +196,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
} |
memcpy(p, buf, t); |
byteReverse(ctx->in, 16); |
- MD5Transform(ctx->buf, (uint32 *)ctx->in); |
+ MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
buf += t; |
len -= t; |
} |
@@ -205,7 +206,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) { |
while (len >= 64) { |
memcpy(ctx->in, buf, 64); |
byteReverse(ctx->in, 16); |
- MD5Transform(ctx->buf, (uint32 *)ctx->in); |
+ MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
buf += 64; |
len -= 64; |
} |
@@ -240,7 +241,7 @@ void MD5Final(MD5Digest* digest, MD5Context* context) { |
/* Two lots of padding: Pad the first block to 64 bytes */ |
memset(p, 0, count); |
byteReverse(ctx->in, 16); |
- MD5Transform(ctx->buf, (uint32 *)ctx->in); |
+ MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
/* Now fill the next block with 56 bytes */ |
memset(ctx->in, 0, 56); |
@@ -258,7 +259,7 @@ void MD5Final(MD5Digest* digest, MD5Context* context) { |
&ctx->bits[1], |
sizeof(ctx->bits[1])); |
- MD5Transform(ctx->buf, (uint32 *)ctx->in); |
+ MD5Transform(ctx->buf, (uint32_t *)ctx->in); |
byteReverse((unsigned char *)ctx->buf, 4); |
memcpy(digest->a, ctx->buf, 16); |
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ |