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

Function cbm_sha256_final

src/foundation/sha256.c:92–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void cbm_sha256_final(cbm_sha256_ctx *c, uint8_t out[CBM_SHA256_DIGEST_LEN]) {
93 c->bitlen += (uint64_t)c->buflen * 8;
94
95 size_t i = c->buflen;
96 c->buf[i++] = 0x80; /* append the '1' bit + zero padding */
97 if (i > 56) {
98 while (i < 64) {
99 c->buf[i++] = 0;
100 }
101 sha256_transform(c, c->buf);
102 i = 0;
103 }
104 while (i < 56) {
105 c->buf[i++] = 0;
106 }
107 /* append the 64-bit big-endian message length */
108 for (int j = 0; j < 8; j++) {
109 c->buf[56 + j] = (uint8_t)(c->bitlen >> (56 - 8 * j));
110 }
111 sha256_transform(c, c->buf);
112
113 for (int j = 0; j < 8; j++) {
114 out[j * 4] = (uint8_t)(c->state[j] >> 24);
115 out[j * 4 + 1] = (uint8_t)(c->state[j] >> 16);
116 out[j * 4 + 2] = (uint8_t)(c->state[j] >> 8);
117 out[j * 4 + 3] = (uint8_t)(c->state[j]);
118 }
119}
120
121void cbm_sha256_hex(const void *data, size_t len, char out[CBM_SHA256_HEX_LEN + 1]) {
122 uint8_t digest[CBM_SHA256_DIGEST_LEN];

Callers 13

cov_failure_fingerprintFunction · 0.85
userconfig_source_digestFunction · 0.85
cbm_cli_sha256_fileFunction · 0.85
query_graph_params_hashFunction · 0.85
query_graph_cursor_sealFunction · 0.85
cbm_sha256_hexFunction · 0.85
cbm_hmac_sha256Function · 0.85

Calls 1

sha256_transformFunction · 0.85

Tested by

no test coverage detected