MCPcopy Create free account
hub / github.com/F-Stack/f-stack / SHA256_Update

Function SHA256_Update

freebsd/crypto/sha2/sha256c.c:247–284  ·  view source on GitHub ↗

Add bytes into the hash */

Source from the content-addressed store, hash-verified

245
246/* Add bytes into the hash */
247void
248SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len)
249{
250 uint64_t bitlen;
251 uint32_t r;
252 const unsigned char *src = in;
253
254 /* Number of bytes left in the buffer from previous updates */
255 r = (ctx->count >> 3) & 0x3f;
256
257 /* Convert the length into a number of bits */
258 bitlen = len << 3;
259
260 /* Update number of bits */
261 ctx->count += bitlen;
262
263 /* Handle the case where we don't need to perform any transforms */
264 if (len < 64 - r) {
265 memcpy(&ctx->buf[r], src, len);
266 return;
267 }
268
269 /* Finish the current block */
270 memcpy(&ctx->buf[r], src, 64 - r);
271 SHA256_Transform(ctx->state, ctx->buf);
272 src += 64 - r;
273 len -= 64 - r;
274
275 /* Perform complete blocks */
276 while (len >= 64) {
277 SHA256_Transform(ctx->state, src);
278 src += 64;
279 len -= 64;
280 }
281
282 /* Copy left over data into buffer */
283 memcpy(ctx->buf, src, len);
284}
285
286/*
287 * SHA-256 finalization. Pads the input data, exports the hash value,

Callers 5

SHA224_UpdateFunction · 0.70
verify_digestFunction · 0.50
arc4random.cFile · 0.50
kerneldumpcrypto_initFunction · 0.50
SHA256Update_intFunction · 0.50

Calls 2

SHA256_TransformFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected