Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/sha1.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | CSHA1 &CSHA1::Write(const uint8_t *data, size_t len) { | ||||
if (bufsize && bufsize + len >= 64) { | if (bufsize && bufsize + len >= 64) { | ||||
// Fill the buffer, and process it. | // Fill the buffer, and process it. | ||||
memcpy(buf + bufsize, data, 64 - bufsize); | memcpy(buf + bufsize, data, 64 - bufsize); | ||||
bytes += 64 - bufsize; | bytes += 64 - bufsize; | ||||
data += 64 - bufsize; | data += 64 - bufsize; | ||||
sha1::Transform(s, buf); | sha1::Transform(s, buf); | ||||
bufsize = 0; | bufsize = 0; | ||||
} | } | ||||
while (end >= data + 64) { | while (end - data >= 64) { | ||||
// Process full chunks directly from the source. | // Process full chunks directly from the source. | ||||
sha1::Transform(s, data); | sha1::Transform(s, data); | ||||
bytes += 64; | bytes += 64; | ||||
data += 64; | data += 64; | ||||
} | } | ||||
if (end > data) { | if (end > data) { | ||||
// Fill the buffer with what remains. | // Fill the buffer with what remains. | ||||
memcpy(buf + bufsize, data, end - data); | memcpy(buf + bufsize, data, end - data); | ||||
Show All 23 Lines |