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

Function sha256_end

src/simplicity/sha256.c:140–149  ·  view source on GitHub ↗

Given a SHA-256 midstate, 'h', of 'len / 512' blocks, and * a 'block' with 'len % 512' bits set and with the remaining bits set to 0, * finalize the SHA-256 computation by adding SHA-256 padding and set 'h' to the resulting SHA-256 hash. * * Precondition: uint32_t h[8]; * uint32_t block[16]; */

Source from the content-addressed store, hash-verified

138 * uint32_t block[16];
139 */
140static void sha256_end(uint32_t* h, uint32_t* block, const uint_fast64_t len) {
141 block[len / 32 % 16] |= (uint32_t)1 << (31 - len % 32);
142 if (448 <= len % 512) {
143 simplicity_sha256_compression(h, block);
144 memset(block, 0, sizeof(uint32_t[14]));
145 }
146 block[14] = (uint32_t)(len >> 32);
147 block[15] = (uint32_t)len;
148 simplicity_sha256_compression(h, block);
149}
150
151/* Compute the SHA-256 hash, 'h', of the bitstring represented by 's'.
152 *

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected