summaryrefslogtreecommitdiffstats
path: root/base/md5.cc
diff options
context:
space:
mode:
authortfarina <tfarina@chromium.org>2015-04-01 10:36:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-01 17:36:55 +0000
commit66e103df9bce01de86298644ef4572dbf9635276 (patch)
tree05b111b03af4ff21fcb0a3857088101868501c10 /base/md5.cc
parent26d78d9e386f44a9c1509d27d6fb0f0dbbb5b100 (diff)
downloadchromium_src-66e103df9bce01de86298644ef4572dbf9635276.zip
chromium_src-66e103df9bce01de86298644ef4572dbf9635276.tar.gz
chromium_src-66e103df9bce01de86298644ef4572dbf9635276.tar.bz2
Use the types from stdint.h in MD5 API.
BUG=138542 TEST=base_unittests --gtest_filter=MD5* R=thakis@chromium.org Review URL: https://codereview.chromium.org/1051703002 Cr-Commit-Position: refs/heads/master@{#323277}
Diffstat (limited to 'base/md5.cc')
-rw-r--r--base/md5.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/base/md5.cc b/base/md5.cc
index 6227ee6..48c1a97 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 |
+ ((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 */