Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Unified Diff: base/md5.cc

Issue 1062673003: Cleanup: Use uint8_t type throughout in the MD5 API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/md5.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/md5.cc
diff --git a/base/md5.cc b/base/md5.cc
index 55f945b1f9450c810f1639be6efdd9d5e420e285..737c7c47b0fd7d7b4faa561404634d201f03649e 100644
--- a/base/md5.cc
+++ b/base/md5.cc
@@ -24,20 +24,19 @@
#include "base/md5.h"
#include <stddef.h>
-#include <stdint.h>
namespace {
struct Context {
uint32_t buf[4];
uint32_t bits[2];
- unsigned char in[64];
+ uint8_t in[64];
};
/*
* Note: this code is harmless on little-endian machines.
*/
-void byteReverse(unsigned char *buf, unsigned longs) {
+void byteReverse(uint8_t* buf, unsigned longs) {
uint32_t t;
do {
t = (uint32_t)((unsigned)buf[3] << 8 | buf[2]) << 16 |
@@ -169,10 +168,10 @@ void MD5Init(MD5Context* context) {
* of bytes.
*/
void MD5Update(MD5Context* context, const StringPiece& data) {
- const unsigned char* inbuf = (const unsigned char*)data.data();
+ const uint8_t* inbuf = (const uint8_t*)data.data();
size_t len = data.size();
struct Context* ctx = (struct Context*)context;
- const unsigned char* buf = (const unsigned char*)inbuf;
+ const uint8_t* buf = (const uint8_t*)inbuf;
uint32_t t;
/* Update bitcount */
@@ -187,7 +186,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) {
/* Handle any leading odd-sized chunks */
if (t) {
- unsigned char* p = (unsigned char*)ctx->in + t;
+ uint8_t* p = (uint8_t*)ctx->in + t;
t = 64 - t;
if (len < t) {
@@ -223,7 +222,7 @@ void MD5Update(MD5Context* context, const StringPiece& data) {
void MD5Final(MD5Digest* digest, MD5Context* context) {
struct Context* ctx = (struct Context*)context;
unsigned count;
- unsigned char* p;
+ uint8_t* p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
@@ -258,7 +257,7 @@ void MD5Final(MD5Digest* digest, MD5Context* context) {
sizeof(ctx->bits[1]));
MD5Transform(ctx->buf, (uint32_t*)ctx->in);
- byteReverse((unsigned char*)ctx->buf, 4);
+ byteReverse((uint8_t*)ctx->buf, 4);
memcpy(digest->a, ctx->buf, 16);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
« no previous file with comments | « base/md5.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698