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

Function sha256_uchars

src/simplicity/sha256.h:223–240  ·  view source on GitHub ↗

Add an array of bytes to be consumed by an ongoing SHA-256 evaluation. * Returns false if the counter overflows. * * Precondition: NULL != ctx; * if 0 < len then unsigned char arr[len]; */

Source from the content-addressed store, hash-verified

221 * if 0 < len then unsigned char arr[len];
222 */
223static inline bool sha256_uchars(sha256_context* ctx, const unsigned char* arr, size_t len) {
224 size_t delta = 64 - ctx->counter % 64;
225 unsigned char *block = ctx->block + ctx->counter % 64;
226 ctx->overflow = ctx->overflow || sha256_max_counter - ctx->counter <= len;
227 ctx->counter += len;
228
229 while (delta <= len) {
230 memcpy(block, arr, delta);
231 arr += delta;
232 len -= delta;
233 sha256_compression_uchar(ctx->output, ctx->block);
234 block = ctx->block;
235 delta = 64;
236 }
237
238 if (len) memcpy(block, arr, len);
239 return !ctx->overflow;
240}
241
242/* Add one byte to be consumed by an ongoing SHA-256 evaluation.
243 *

Callers 15

sha_256_ctx_8_add_nFunction · 0.85
simplicity_tapdata_initFunction · 0.85
sha256_ucharFunction · 0.85
sha256_u64beFunction · 0.85
sha256_u32leFunction · 0.85
sha256_u32beFunction · 0.85
sha256_finalizeFunction · 0.85
sha256_hashFunction · 0.85

Calls 1

sha256_compression_ucharFunction · 0.85

Tested by

no test coverage detected