MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sha256_chunked_hex

Function sha256_chunked_hex

tests/test_cli.c:17581–17597  ·  view source on GitHub ↗

Hash `len` bytes fed in `chunk`-sized pieces (0 = one update) to hex. */

Source from the content-addressed store, hash-verified

17579
17580/* Hash `len` bytes fed in `chunk`-sized pieces (0 = one update) to hex. */
17581static void sha256_chunked_hex(const uint8_t *data, size_t len, size_t chunk,
17582 char out[CBM_SHA256_HEX_LEN + 1]) {
17583 static const char hex[] = "0123456789abcdef";
17584 cbm_sha256_ctx ctx;
17585 cbm_sha256_init(&ctx);
17586 size_t step = chunk == 0 ? len : chunk;
17587 for (size_t off = 0; off < len; off += step) {
17588 cbm_sha256_update(&ctx, data + off, len - off < step ? len - off : step);
17589 }
17590 uint8_t digest[CBM_SHA256_DIGEST_LEN];
17591 cbm_sha256_final(&ctx, digest);
17592 for (int i = 0; i < CBM_SHA256_DIGEST_LEN; i++) {
17593 out[i * 2] = hex[digest[i] >> 4];
17594 out[i * 2 + 1] = hex[digest[i] & 0x0f];
17595 }
17596 out[CBM_SHA256_HEX_LEN] = '\0';
17597}
17598
17599/* #2441: block compression runs on ARMv8 SHA2 / x86 SHA-NI when the CPU has
17600 * them. The hardware path must agree with the portable transform bit for bit

Callers 1

test_cli.cFile · 0.85

Calls 3

cbm_sha256_initFunction · 0.85
cbm_sha256_updateFunction · 0.85
cbm_sha256_finalFunction · 0.85

Tested by

no test coverage detected