Re: [PATCH 3/3] Makefile: add USE_SHA1DC knob
- From
Jeff King <peff@peff.net>
- Date
- Feb 24, 2017, 18:57 UTC
- Message-ID
- <20170224185754.bic37suvkiwtvyn5@sigill.intra.peff.net>
- In-Reply-To
- <16c6d843-a516-9265-d3e7-61b110acbdcf@ipsumj.de>
On Fri, Feb 24, 2017 at 06:36:00PM +0000, HW42 wrote:
Show 17 quoted lines
> > +ifdef USE_SHA1DC > > + SHA1_HEADER = "sha1dc/sha1.h" > > + LIB_OBJS += sha1dc/sha1.o > > + LIB_OBJS += sha1dc/ubc_check.o > > +else > > ifdef BLK_SHA1 > > SHA1_HEADER = "block-sha1/sha1.h" > > LIB_OBJS += block-sha1/sha1.o > > @@ -1403,6 +1412,7 @@ else > > endif > > endif > > endif > > +endif > > This sets SHA1_MAX_BLOCK_SIZE and the compiler flags for Apple > CommonCrypto even if the user selects USE_SHA1DC. The same happens for > BLK_SHA1. Is this intended?
No, it's not. I suspect that setting BLK_SHA1 has the same problem in the current code, then.
Show 15 quoted lines
> > +void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)
> > +{
> > + const char *data = vdata;
> > + /* We expect an unsigned long, but sha1dc only takes an int */
> > + while (len > INT_MAX) {
> > + SHA1DCUpdate(ctx, data, INT_MAX);
> > + data += INT_MAX;
> > + len -= INT_MAX;
> > + }
> > + SHA1DCUpdate(ctx, data, len);
> > +}
>
> I think you can simply change the len parameter from unsigned into
> size_t (or unsigned long) in SHA1DCUpdate().
> https://github.com/cr-marcstevens/sha1collisiondetection/pull/6Yeah, I agree that is a cleaner solution. My focus was on changing the (presumably tested) sha1dc code as little as possible.
-Peff