Re: [PATCH] replace sha1 with another algorithm
- From
Jeff King <peff@peff.net>
- Date
- Oct 27, 2011, 00:01 UTC
- Message-ID
- <20111027000117.GA24161@sigill.intra.peff.net>
- In-Reply-To
- <7vaa8n35dc.fsf@alter.siamese.dyndns.org>
On Wed, Oct 26, 2011 at 12:44:15PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> > +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?Well, yeah. But when you're writing a really bad hashing algorithm, I feel like obfuscating the bugs is key.
-Peff