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

Method sha_update

src/common/sha2/sha2.cpp:351–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void sha256_traits::sha_update(sha256_ctx* ctx, const unsigned char* message,
352 unsigned int len)
353{
354 const unsigned int tmp_len = SHA256_BLOCK_SIZE - ctx->len;
355 unsigned int rem_len = len < tmp_len ? len : tmp_len;
356
357 memcpy(&ctx->block[ctx->len], message, rem_len);
358
359 if (ctx->len + len < SHA256_BLOCK_SIZE)
360 {
361 ctx->len += len;
362 return;
363 }
364
365 const unsigned int new_len = len - rem_len;
366 const unsigned int block_nb = new_len / SHA256_BLOCK_SIZE;
367
368 const unsigned char* const shifted_message = message + rem_len;
369
370 ctx->transf(ctx->block, 1);
371 ctx->transf(shifted_message, block_nb);
372
373 rem_len = new_len % SHA256_BLOCK_SIZE;
374
375 memcpy(ctx->block, &shifted_message[block_nb << 6], rem_len);
376
377 ctx->len = rem_len;
378 ctx->tot_len += (block_nb + 1) << 6;
379}
380
381void sha256_traits::sha_final(sha256_ctx* ctx, unsigned char* digest)
382{

Callers

nothing calls this directly

Calls 1

transfMethod · 0.80

Tested by

no test coverage detected