| 78 | } |
| 79 | |
| 80 | void cbm_sha256_update(cbm_sha256_ctx *c, const void *data, size_t len) { |
| 81 | const uint8_t *p = (const uint8_t *)data; |
| 82 | for (size_t i = 0; i < len; i++) { |
| 83 | c->buf[c->buflen++] = p[i]; |
| 84 | if (c->buflen == 64) { |
| 85 | sha256_transform(c, c->buf); |
| 86 | c->bitlen += 512; |
| 87 | c->buflen = 0; |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | void cbm_sha256_final(cbm_sha256_ctx *c, uint8_t out[CBM_SHA256_DIGEST_LEN]) { |
| 93 | c->bitlen += (uint64_t)c->buflen * 8; |
no test coverage detected