From: Zac Medico Date: Mon, 5 Mar 2012 09:55:39 +0000 (-0800) Subject: whirlpool.py: fix WhirlpoolAdd for bug #406407 X-Git-Tag: v2.2.0_alpha91~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3596fc3822bb82dfe05a58fdb78220e399175a4d;p=portage.git whirlpool.py: fix WhirlpoolAdd for bug #406407 This file is a python port of Whirlpool.c the reference implementation: http://www.larc.usp.br/~pbarreto/whirlpool.zip Comparison of both implementations reveals a difference in loop logic at the very beginning of the WhirlpoolAdd function, which is fixed now. --- diff --git a/pym/portage/util/whirlpool.py b/pym/portage/util/whirlpool.py index 8415e8754..c696f6fc0 100644 --- a/pym/portage/util/whirlpool.py +++ b/pym/portage/util/whirlpool.py @@ -645,7 +645,7 @@ def WhirlpoolAdd(source, sourceBits, ctx): carry = 0 value = sourceBits i = 31 - while i >= 0 and value != 0: + while i >= 0 and (carry != 0 or value != 0): carry += ctx.bitLength[i] + ((value % 0x100000000) & 0xff) ctx.bitLength[i] = carry % 0x100 carry >>= 8