Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/sha512.cpp
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | CSHA512 &CSHA512::Write(const uint8_t *data, size_t len) { | ||||
if (bufsize && bufsize + len >= 128) { | if (bufsize && bufsize + len >= 128) { | ||||
// Fill the buffer, and process it. | // Fill the buffer, and process it. | ||||
memcpy(buf + bufsize, data, 128 - bufsize); | memcpy(buf + bufsize, data, 128 - bufsize); | ||||
bytes += 128 - bufsize; | bytes += 128 - bufsize; | ||||
data += 128 - bufsize; | data += 128 - bufsize; | ||||
sha512::Transform(s, buf); | sha512::Transform(s, buf); | ||||
bufsize = 0; | bufsize = 0; | ||||
} | } | ||||
while (end >= data + 128) { | while (end - data >= 128) { | ||||
// Process full chunks directly from the source. | // Process full chunks directly from the source. | ||||
sha512::Transform(s, data); | sha512::Transform(s, data); | ||||
data += 128; | data += 128; | ||||
bytes += 128; | bytes += 128; | ||||
} | } | ||||
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 26 Lines |