MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / sha_update

Function sha_update

src/common/sha.cpp:260–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258// update the SHA digest
259
260void sha_update(SHA_INFO *sha_info, const BYTE *buffer, size_t count)
261{
262 const Sha1::LONG clo = T32(sha_info->count_lo + ((Sha1::LONG) count << 3));
263 if (clo < sha_info->count_lo) {
264 ++sha_info->count_hi;
265 }
266 sha_info->count_lo = clo;
267 sha_info->count_hi += (Sha1::LONG) count >> 29;
268 if (sha_info->local)
269 {
270 size_t i = SHA_BLOCKSIZE - sha_info->local;
271 if (i > count) {
272 i = count;
273 }
274 memcpy(sha_info->data + sha_info->local, buffer, i);
275 count -= i;
276 buffer += i;
277 sha_info->local += i;
278 if (sha_info->local == SHA_BLOCKSIZE) {
279 sha_transform(sha_info);
280 }
281 else {
282 return;
283 }
284 }
285 while (count >= SHA_BLOCKSIZE)
286 {
287 memcpy(sha_info->data, buffer, SHA_BLOCKSIZE);
288 buffer += SHA_BLOCKSIZE;
289 count -= SHA_BLOCKSIZE;
290 sha_transform(sha_info);
291 }
292 memcpy(sha_info->data, buffer, count);
293 sha_info->local = count;
294}
295
296// finish computing the SHA digest
297

Callers 3

hashBased64Method · 0.85
processMethod · 0.85
processMethod · 0.85

Calls 1

sha_transformFunction · 0.85

Tested by

no test coverage detected