Finish the SHA-256 computation by consuming and digesting the SHA-256 padding. * The final result is stored in the original 'output' buffer that was given to 'sha256_init'. * * Returns false if the counter had overflowed. * * Precondition: NULL != ctx; */
| 298 | * Precondition: NULL != ctx; |
| 299 | */ |
| 300 | static inline bool sha256_finalize(sha256_context* ctx) { |
| 301 | bool result = !ctx->overflow; |
| 302 | uint_fast64_t length = ctx->counter * 8; |
| 303 | sha256_uchars(ctx, (const unsigned char[64]){0x80}, 1 + (64 + 56 - ctx->counter % 64 - 1) % 64); |
| 304 | sha256_u64be(ctx, length); |
| 305 | return result; |
| 306 | } |
| 307 | |
| 308 | /* Add a 256-bit hash to be consumed by an ongoing SHA-256 evaluation. |
| 309 | * |