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

Method sha_final

src/common/sha2/sha2.cpp:381–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381void sha256_traits::sha_final(sha256_ctx* ctx, unsigned char* digest)
382{
383 const unsigned int block_nb = (1 + ((SHA256_BLOCK_SIZE - 9) < (ctx->len % SHA256_BLOCK_SIZE)));
384
385 const unsigned int len_b = (ctx->tot_len + ctx->len) << 3;
386 const unsigned int pm_len = block_nb << 6;
387
388 memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
389 ctx->block[ctx->len] = 0x80;
390 UNPACK32(len_b, ctx->block + pm_len - 4);
391
392 ctx->transf(ctx->block, block_nb);
393
394#ifndef UNROLL_LOOPS
395 for (int i = 0 ; i < 8; i++)
396 {
397 UNPACK32(ctx->h[i], &digest[i << 2]);
398 }
399#else
400 UNPACK32(ctx->h[0], &digest[ 0]);
401 UNPACK32(ctx->h[1], &digest[ 4]);
402 UNPACK32(ctx->h[2], &digest[ 8]);
403 UNPACK32(ctx->h[3], &digest[12]);
404 UNPACK32(ctx->h[4], &digest[16]);
405 UNPACK32(ctx->h[5], &digest[20]);
406 UNPACK32(ctx->h[6], &digest[24]);
407 UNPACK32(ctx->h[7], &digest[28]);
408#endif /* !UNROLL_LOOPS */
409}
410
411/* SHA-512 context structure */
412

Callers

nothing calls this directly

Calls 1

transfMethod · 0.80

Tested by

no test coverage detected