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

Function SHA256_Pad

freebsd/crypto/sha2/sha256c.c:199–225  ·  view source on GitHub ↗

Add padding and terminating bit-count. */

Source from the content-addressed store, hash-verified

197
198/* Add padding and terminating bit-count. */
199static void
200SHA256_Pad(SHA256_CTX * ctx)
201{
202 size_t r;
203
204 /* Figure out how many bytes we have buffered. */
205 r = (ctx->count >> 3) & 0x3f;
206
207 /* Pad to 56 mod 64, transforming if we finish a block en route. */
208 if (r < 56) {
209 /* Pad to 56 mod 64. */
210 memcpy(&ctx->buf[r], PAD, 56 - r);
211 } else {
212 /* Finish the current block and mix. */
213 memcpy(&ctx->buf[r], PAD, 64 - r);
214 SHA256_Transform(ctx->state, ctx->buf);
215
216 /* The start of the final block is all zeroes. */
217 memset(&ctx->buf[0], 0, 56);
218 }
219
220 /* Add the terminating bit-count. */
221 be64enc(&ctx->buf[56], ctx->count);
222
223 /* Mix in the final block. */
224 SHA256_Transform(ctx->state, ctx->buf);
225}
226
227/* SHA-256 initialization. Begins a SHA-256 operation. */
228void

Callers 2

SHA256_FinalFunction · 0.70
SHA224_FinalFunction · 0.70

Calls 4

memsetFunction · 0.85
be64encFunction · 0.85
SHA256_TransformFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected