Exemple #1
0
void
RMD160Final(u_char digest[20], RMD160_CTX *ctx)
{
	int i;
	u_char size[8];
	u_int32_t padlen;

	PUT_64BIT_LE(size, ctx->count);

	/*
	 * pad to 64 byte blocks, at least one byte from PADDING plus 8 bytes
	 * for the size
	 */
	padlen = 64 - ((ctx->count/8) % 64);
	if (padlen < 1 + 8)
		padlen += 64;
	RMD160Update(ctx, PADDING, padlen - 8);		/* padlen - 8 <= 64 */
	RMD160Update(ctx, size, 8);

	if (digest != NULL)
		for (i = 0; i < 5; i++)
			PUT_32BIT_LE(digest + i*4, ctx->state[i]);

	memset(ctx, 0, sizeof (*ctx));
}
Exemple #2
0
/*
 * Pad pad to 64-byte boundary with the bit pattern
 * 1 0* (64-bit count of bits processed, MSB-first)
 */
void
MD5Pad(MD5_CTX *ctx)
{
	u_int8_t count[8];

	/* Convert count to 8 bytes in little endian order. */
	PUT_64BIT_LE(count, ctx->count);

	/* Pad out to 56 mod 64. */
	MD5Update(ctx, RFC1321_padding, 64 - (((ctx->count >> 3) + 8) & 63));
	MD5Update(ctx, count, 8);
}
Exemple #3
0
void
RMD160Pad(RMD160_CTX *ctx)
{
	u_int8_t size[8];
	size_t padlen;

	PUT_64BIT_LE(size, ctx->count);

	/*
	 * pad to RMD160_BLOCK_LENGTH byte blocks, at least one byte from
	 * PADDING plus 8 bytes for the size
	 */
	padlen = RMD160_BLOCK_LENGTH - ((ctx->count / 8) % RMD160_BLOCK_LENGTH);
	if (padlen < 1 + 8)
		padlen += RMD160_BLOCK_LENGTH;
	RMD160Update(ctx, PADDING, padlen - 8);		/* padlen - 8 <= 64 */
	RMD160Update(ctx, size, 8);
}
Exemple #4
0
void RMD160Pad(RMD160CTX* context)
{
    uint8_t len[8];
    uint32_t plen;

    PUT_64BIT_LE(len, context->count);

    plen = RMD160_BLOCK_LENGTH -
        ((context->count / 8) % RMD160_BLOCK_LENGTH);

    if (plen < 1 + 8)
    {
        plen += RMD160_BLOCK_LENGTH;
    }

    RMD160Update(context, PAD, plen - 8);
    RMD160Update(context, len, 8);
}