Chromium Code Reviews| Index: webrtc/base/sha1.cc |
| diff --git a/webrtc/base/sha1.cc b/webrtc/base/sha1.cc |
| index b2af313be71593f3d4a918af8e2fbd61a170fe80..90b0ba8d050b3ae2ee95a02f6a2ccbc9810a2d61 100644 |
| --- a/webrtc/base/sha1.cc |
| +++ b/webrtc/base/sha1.cc |
| @@ -75,9 +75,10 @@ |
| * ----------------- |
| * Modified 03/2012 |
| * By Ronghua Wu <ronghuawu@google.com> |
| - * Change the typedef of uint32(8)_t to uint32(8). We need this because in the |
| + * Change the typedef of uint32_t(8)_t to uint32_t(8). We need this because in |
|
Henrik Grunell WebRTC
2015/10/05 12:00:19
Don't change the change log. :)
pbos-webrtc
2015/10/05 12:23:23
Oops, thanks!
|
| + *the |
| * chromium android build, the stdio.h will include stdint.h which already |
| - * defined uint32(8)_t. |
| + * defined uint32_t(8)_t. |
| * |
| * ----------------- |
| * Modified 04/2012 |
| @@ -156,13 +157,13 @@ void SHAPrintContext(SHA1_CTX *context, char *msg) { |
| #endif /* VERBOSE */ |
| // Hash a single 512-bit block. This is the core of the algorithm. |
| -void SHA1Transform(uint32 state[5], const uint8 buffer[64]) { |
| +void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]) { |
| union CHAR64LONG16 { |
| - uint8 c[64]; |
| - uint32 l[16]; |
| + uint8_t c[64]; |
| + uint32_t l[16]; |
| }; |
| #ifdef SHA1HANDSOFF |
| - uint8 workspace[64]; |
| + uint8_t workspace[64]; |
| memcpy(workspace, buffer, 64); |
| CHAR64LONG16* block = reinterpret_cast<CHAR64LONG16*>(workspace); |
| #else |
| @@ -172,11 +173,11 @@ void SHA1Transform(uint32 state[5], const uint8 buffer[64]) { |
| #endif |
| // Copy context->state[] to working vars. |
| - uint32 a = state[0]; |
| - uint32 b = state[1]; |
| - uint32 c = state[2]; |
| - uint32 d = state[3]; |
| - uint32 e = state[4]; |
| + uint32_t a = state[0]; |
| + uint32_t b = state[1]; |
| + uint32_t c = state[2]; |
| + uint32_t d = state[3]; |
| + uint32_t e = state[4]; |
| // 4 rounds of 20 operations each. Loop unrolled. |
| // Note(fbarchard): The following has lint warnings for multiple ; on |
| @@ -225,7 +226,7 @@ void SHA1Init(SHA1_CTX* context) { |
| } |
| // Run your data through this. |
| -void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { |
| +void SHA1Update(SHA1_CTX* context, const uint8_t* data, size_t input_len) { |
| size_t i = 0; |
| #ifdef VERBOSE |
| @@ -236,15 +237,15 @@ void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { |
| size_t index = (context->count[0] >> 3) & 63; |
| // Update number of bits. |
| - // TODO: Use uint64 instead of 2 uint32 for count. |
| + // TODO: Use uint64_t instead of 2 uint32_t for count. |
| // count[0] has low 29 bits for byte count + 3 pad 0's making 32 bits for |
| // bit count. |
| - // Add bit count to low uint32 |
| - context->count[0] += static_cast<uint32>(input_len << 3); |
| - if (context->count[0] < static_cast<uint32>(input_len << 3)) { |
| + // Add bit count to low uint32_t |
| + context->count[0] += static_cast<uint32_t>(input_len << 3); |
| + if (context->count[0] < static_cast<uint32_t>(input_len << 3)) { |
| ++context->count[1]; // if overlow (carry), add one to high word |
| } |
| - context->count[1] += static_cast<uint32>(input_len >> 29); |
| + context->count[1] += static_cast<uint32_t>(input_len >> 29); |
| if ((index + input_len) > 63) { |
| i = 64 - index; |
| memcpy(&context->buffer[index], data, i); |
| @@ -262,21 +263,21 @@ void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { |
| } |
| // Add padding and return the message digest. |
| -void SHA1Final(SHA1_CTX* context, uint8 digest[SHA1_DIGEST_SIZE]) { |
| - uint8 finalcount[8]; |
| +void SHA1Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]) { |
| + uint8_t finalcount[8]; |
| for (int i = 0; i < 8; ++i) { |
| // Endian independent |
| - finalcount[i] = static_cast<uint8>( |
| - (context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8) ) & 255); |
| + finalcount[i] = static_cast<uint8_t>( |
| + (context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); |
| } |
| - SHA1Update(context, reinterpret_cast<const uint8*>("\200"), 1); |
| + SHA1Update(context, reinterpret_cast<const uint8_t*>("\200"), 1); |
| while ((context->count[0] & 504) != 448) { |
| - SHA1Update(context, reinterpret_cast<const uint8*>("\0"), 1); |
| + SHA1Update(context, reinterpret_cast<const uint8_t*>("\0"), 1); |
| } |
| SHA1Update(context, finalcount, 8); // Should cause a SHA1Transform(). |
| for (int i = 0; i < SHA1_DIGEST_SIZE; ++i) { |
| - digest[i] = static_cast<uint8>( |
| - (context->state[i >> 2] >> ((3 - (i & 3)) * 8) ) & 255); |
| + digest[i] = static_cast<uint8_t>( |
| + (context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); |
| } |
| // Wipe variables. |