mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 19:10:36 +00:00
Bug 803692 - Make SHA1Sum::update() take a void* instead of a uint8_t*. r=waldo
This commit is contained in:
parent
efef6128ad
commit
a6ab000fcb
@ -99,10 +99,12 @@ SHA1Sum::SHA1Sum()
|
||||
* SHA: Add data to context.
|
||||
*/
|
||||
void
|
||||
SHA1Sum::update(const uint8_t* dataIn, uint32_t len)
|
||||
SHA1Sum::update(const void* dataIn, uint32_t len)
|
||||
{
|
||||
MOZ_ASSERT(!mDone, "SHA1Sum can only be used to compute a single hash.");
|
||||
|
||||
const uint8_t* data = static_cast<const uint8_t*>(dataIn);
|
||||
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
@ -117,9 +119,9 @@ SHA1Sum::update(const uint8_t* dataIn, uint32_t len)
|
||||
togo = 64U - lenB;
|
||||
if (len < togo)
|
||||
togo = len;
|
||||
memcpy(u.b + lenB, dataIn, togo);
|
||||
memcpy(u.b + lenB, data, togo);
|
||||
len -= togo;
|
||||
dataIn += togo;
|
||||
data += togo;
|
||||
lenB = (lenB + togo) & 63U;
|
||||
if (!lenB)
|
||||
shaCompress(&H[H2X], u.w);
|
||||
@ -127,12 +129,12 @@ SHA1Sum::update(const uint8_t* dataIn, uint32_t len)
|
||||
|
||||
while (len >= 64U) {
|
||||
len -= 64U;
|
||||
shaCompress(&H[H2X], reinterpret_cast<const uint32_t*>(dataIn));
|
||||
dataIn += 64U;
|
||||
shaCompress(&H[H2X], reinterpret_cast<const uint32_t*>(data));
|
||||
data += 64U;
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
memcpy(u.b, dataIn, len);
|
||||
memcpy(u.b, data, len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ class SHA1Sum
|
||||
typedef uint8_t Hash[HashSize];
|
||||
|
||||
/* Add len bytes of dataIn to the data sequence being hashed. */
|
||||
void update(const uint8_t* dataIn, uint32_t len);
|
||||
void update(const void* dataIn, uint32_t len);
|
||||
|
||||
/* Compute the final hash of all data into hashOut. */
|
||||
void finish(SHA1Sum::Hash& hashOut);
|
||||
|
Loading…
x
Reference in New Issue
Block a user