zabbix-agent2/src/libs/zbxcrypto/sha512crypt.c
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.

IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value.  */
Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.

On some systems it is required that RESBUF is correctly
aligned for a 32 bits value.
Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF . On some systems it is required that RESBUF is correctly aligned for a 32 bits value .
static void *
sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
{
	uint64_t bytes = ctx->buflen;
	unsigned int i = 0;
	size_t pad;
	ctx->total[0] += bytes;
	if (ctx->total[0] < bytes)
		++ctx->total[1];
	pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
	memcpy (&ctx->buffer[bytes], fillbuf, pad);
	*(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP (ctx->total[0] << 3);
	*(uint64_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 61));
	sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
	for (i = 0; i < 8; ++i)
		((uint64_t *) resbuf)[i] = SWAP (ctx->H[i]);
	return resbuf;
}
static void * sha512_finish_ctx ( struct sha512_ctx * ctx , void * resbuf ) { uint64_t bytes = ctx -> buflen ; unsigned int i = 0 ; size_t pad ; ctx -> total [ 0 ] += bytes ; if ( ctx -> total [ 0 ] < bytes ) ++ ctx -> total [ 1 ] ; pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes ; memcpy ( & ctx -> buffer [ bytes ] , fillbuf , pad ) ; * ( uint64_t * ) & ctx -> buffer [ bytes + pad + 8 ] = SWAP ( ctx -> total [ 0 ] << 3 ) ; * ( uint64_t * ) & ctx -> buffer [ bytes + pad ] = SWAP ( ( ctx -> total [ 1 ] << 3 ) | ( ctx -> total [ 0 ] >> 61 ) ) ; sha512_process_block ( ctx -> buffer , bytes + pad + 16 , ctx ) ; for ( i = 0 ; i < 8 ; ++ i ) ( ( uint64_t * ) resbuf ) [ i ] = SWAP ( ctx -> H [ i ] ) ; return resbuf ; }
Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF .
/* Take yet unprocessed bytes into account.  */ /* Now count remaining bytes.  */ /* Put the 128-bit file length in *bits* at the end of the buffer.  */ /* Process last bytes.  */ /* Put result from CTX in first 64 bytes following RESBUF.  */