git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] replace sha1 with another algorithm

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 26, 2011, 19:44 UTC
Message-ID
<7vaa8n35dc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20111026001237.GA22195@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> +static void xor_bytes(unsigned char *out, unsigned char *a, unsigned char *b,
> +		      unsigned n)
> +{
> +	unsigned i;
> +	for (i = 0; i < n; i++)
> +		out[i] = a[i] ^ b[i];
> +}
> +
> +static void mix_hash(unsigned char *h, unsigned n)
> +{
> +	unsigned char out[20];
> +	unsigned mid = n / 2;
> +
> +	if (2*mid < n)
> +		return;
> +
> +	xor_bytes(out, h, h + mid, mid);
> +	xor_bytes(out + mid, h + mid, h, mid);
> +	memcpy(h, out, n);
> +
> +	/* If a little bit of mixing is good, then a lot must be GREAT! */
> +	mix_hash(h, mid);
> +	mix_hash(h + mid, mid);
> +}

You seem to want to reduce the hash down to 5-bytes by duplicating the same value on the left and right half, and duplicate that four times to fill 20-byte buffer, but doesn't this look unnecessarily inefficient way to achieve that?

Previous: Michael J GruberNext: Jeff King
Message 3 of 4 in “replace sha1 with another algorithm”
  1. replace sha1 with another algorithmJeff King, Oct 26, 2011
  2. Michael J GruberOct 26, 2011
  3. Junio C HamanoOct 26, 2011
  4. Jeff KingOct 27, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.