OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 * | 6 * |
7 * The following code is based on the description in RFC 1321. | 7 * The following code is based on the description in RFC 1321. |
8 * http://www.ietf.org/rfc/rfc1321.txt | 8 * http://www.ietf.org/rfc/rfc1321.txt |
9 */ | 9 */ |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 | 73 |
74 // Pad out to 56 mod 64. | 74 // Pad out to 56 mod 64. |
75 unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F); | 75 unsigned int bufferIndex = (unsigned int)(this->byteCount & 0x3F); |
76 unsigned int paddingLength = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex); | 76 unsigned int paddingLength = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex); |
77 static uint8_t PADDING[64] = { | 77 static uint8_t PADDING[64] = { |
78 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 78 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
80 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 80 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
82 }; | 82 }; |
83 this->update(PADDING, paddingLength); | 83 (void)this->write(PADDING, paddingLength); |
84 | 84 |
85 // Append length (length before padding, will cause final update). | 85 // Append length (length before padding, will cause final update). |
86 this->update(bits, 8); | 86 (void)this->write(bits, 8); |
tomhudson
2016/04/22 20:49:55
Having to cast void return. :(
| |
87 | 87 |
88 // Write out digest. | 88 // Write out digest. |
89 encode(digest.data, this->state); | 89 encode(digest.data, this->state); |
90 | 90 |
91 #if defined(SK_MD5_CLEAR_DATA) | 91 #if defined(SK_MD5_CLEAR_DATA) |
92 // Clear state. | 92 // Clear state. |
93 memset(this, 0, sizeof(*this)); | 93 memset(this, 0, sizeof(*this)); |
94 #endif | 94 #endif |
95 } | 95 } |
96 | 96 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 #endif | 249 #endif |
250 for (size_t i = 0, j = 0; j < 64; i++, j += 4) { | 250 for (size_t i = 0, j = 0; j < 64; i++, j += 4) { |
251 storage[i] = ((uint32_t)input[j ]) | | 251 storage[i] = ((uint32_t)input[j ]) | |
252 (((uint32_t)input[j+1]) << 8) | | 252 (((uint32_t)input[j+1]) << 8) | |
253 (((uint32_t)input[j+2]) << 16) | | 253 (((uint32_t)input[j+2]) << 16) | |
254 (((uint32_t)input[j+3]) << 24); | 254 (((uint32_t)input[j+3]) << 24); |
255 } | 255 } |
256 return storage; | 256 return storage; |
257 #endif | 257 #endif |
258 } | 258 } |
OLD | NEW |