From 3596fc3822bb82dfe05a58fdb78220e399175a4d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 5 Mar 2012 01:55:39 -0800 Subject: 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. --- pym/portage/util/whirlpool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pym/portage/util/whirlpool.py') 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 -- cgit v1.2.3-1-g7c22