MCPcopy Create free account
hub / github.com/ElementsProject/elements / sha256_finalize

Function sha256_finalize

src/simplicity/sha256.h:300–306  ·  view source on GitHub ↗

Finish the SHA-256 computation by consuming and digesting the SHA-256 padding. * The final result is stored in the original 'output' buffer that was given to 'sha256_init'. * * Returns false if the counter had overflowed. * * Precondition: NULL != ctx; */

Source from the content-addressed store, hash-verified

298 * Precondition: NULL != ctx;
299 */
300static inline bool sha256_finalize(sha256_context* ctx) {
301 bool result = !ctx->overflow;
302 uint_fast64_t length = ctx->counter * 8;
303 sha256_uchars(ctx, (const unsigned char[64]){0x80}, 1 + (64 + 56 - ctx->counter % 64 - 1) % 64);
304 sha256_u64be(ctx, length);
305 return result;
306}
307
308/* Add a 256-bit hash to be consumed by an ongoing SHA-256 evaluation.
309 *

Calls 2

sha256_ucharsFunction · 0.85
sha256_u64beFunction · 0.85

Tested by 1

hashintFunction · 0.68