git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] replace sha1 with another algorithm
Date: Wed, 26 Oct 2011 17:01:17 -0700	[thread overview]
Message-ID: <20111027000117.GA24161@sigill.intra.peff.net> (raw)
In-Reply-To: <7vaa8n35dc.fsf@alter.siamese.dyndns.org>

On Wed, Oct 26, 2011 at 12:44:15PM -0700, Junio C Hamano wrote:

> > +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

      reply	other threads:[~2011-10-27  0:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-26  0:12 [PATCH] replace sha1 with another algorithm Jeff King
2011-10-26  9:59 ` Michael J Gruber
2011-10-26 19:44 ` Junio C Hamano
2011-10-27  0:01   ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111027000117.GA24161@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).