Пример #1
0
void
ripemd160_digest(struct ripemd160_ctx *ctx, size_t length, uint8_t *digest)
{
  uint64_t bit_count;

  assert(length <= RIPEMD160_DIGEST_SIZE);

  MD_PAD(ctx, 8, COMPRESS);

  /* There are 2^9 bits in one block */
  bit_count = (ctx->count << 9) | (ctx->index << 3);
									\
  /* append the 64 bit count */
  LE_WRITE_UINT64(ctx->block + 56, bit_count);
  _nettle_ripemd160_compress(ctx->state, ctx->block);

  _nettle_write_le32(length, digest, ctx->state);
  ripemd160_init(ctx);
}
Пример #2
0
void
md5_digest(struct md5_ctx *ctx,
	   size_t length,
	   uint8_t *digest)
{
  uint64_t bit_count;
  
  assert(length <= MD5_DIGEST_SIZE);

  MD_PAD(ctx, 8, COMPRESS);

  /* There are 512 = 2^9 bits in one block */
  bit_count = (ctx->count << 9) | (ctx->index << 3);

  LE_WRITE_UINT64(ctx->block + (MD5_BLOCK_SIZE - 8), bit_count);
  _nettle_md5_compress(ctx->state, ctx->block);

  _nettle_write_le32(length, digest, ctx->state);
  md5_init(ctx);
}