Add padding and terminating bit-count. */
| 227 | |
| 228 | /* Add padding and terminating bit-count. */ |
| 229 | static void |
| 230 | SHA512_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. */ |
| 258 | void |
no test coverage detected