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

Function SHA512_Pad

freebsd/crypto/sha2/sha512c.c:229–255  ·  view source on GitHub ↗

Add padding and terminating bit-count. */

Source from the content-addressed store, hash-verified

227
228/* Add padding and terminating bit-count. */
229static void
230SHA512_Pad(SHA512_CTX * ctx)
231{
232 size_t r;
233
234 /* Figure out how many bytes we have buffered. */
235 r = (ctx->count[1] >> 3) & 0x7f;
236
237 /* Pad to 112 mod 128, transforming if we finish a block en route. */
238 if (r < 112) {
239 /* Pad to 112 mod 128. */
240 memcpy(&ctx->buf[r], PAD, 112 - r);
241 } else {
242 /* Finish the current block and mix. */
243 memcpy(&ctx->buf[r], PAD, 128 - r);
244 SHA512_Transform(ctx->state, ctx->buf);
245
246 /* The start of the final block is all zeroes. */
247 memset(&ctx->buf[0], 0, 112);
248 }
249
250 /* Add the terminating bit-count. */
251 be64enc_vect(&ctx->buf[112], ctx->count, 16);
252
253 /* Mix in the final block. */
254 SHA512_Transform(ctx->state, ctx->buf);
255}
256
257/* SHA-512 initialization. Begins a SHA-512 operation. */
258void

Callers 4

SHA512_FinalFunction · 0.70
SHA512_224_FinalFunction · 0.70
SHA512_256_FinalFunction · 0.70
SHA384_FinalFunction · 0.70

Calls 4

memsetFunction · 0.85
SHA512_TransformFunction · 0.70
be64enc_vectFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected