From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7ZGg-0007sA-1z for mharc-grub-devel@gnu.org; Mon, 09 Nov 2009 13:47:10 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7ZGd-0007oz-M7 for grub-devel@gnu.org; Mon, 09 Nov 2009 13:47:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7ZGX-0007iD-UI for grub-devel@gnu.org; Mon, 09 Nov 2009 13:47:06 -0500 Received: from [199.232.76.173] (port=37004 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7ZGX-0007i1-Pn for grub-devel@gnu.org; Mon, 09 Nov 2009 13:47:01 -0500 Received: from mail-ew0-f228.google.com ([209.85.219.228]:47781) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N7ZGX-0004VA-9G for grub-devel@gnu.org; Mon, 09 Nov 2009 13:47:01 -0500 Received: by ewy28 with SMTP id 28so4354697ewy.42 for ; Mon, 09 Nov 2009 10:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=GdBCMR0gqa7XPZmLiBxy2PAoEQkn7PEtt9PWq3P/HR0=; b=vO7ey7NFVDEDTXcEvoSfseXKv1iMyc3N/s1OU504rEVhzEAZzoNQb2SJMUoXNBUATx uDx6Lde/Qy+1Mq6DRSU5ORT3EdON0UIjBM7D7xcub1DIzy66x8t1j0pu4jDNX8MKu/lA JWMMaxRAtyqomA5ofv6aGOPiIiw3tOyeRv35k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=USSsQZ+DiSMs02J84QqM1jRQ91JRJUkJsjLEOezLZsTWqHr4CQ6bDxC3DEgaUo4X5o 2rxOphzczuZollomPuDkVjK3b0VNxW6KO8+P7NpTqn1+IOpyc0JFPmyse5fEMZnF4aRe jz5PFK1DknXqfTz2HOZeUVitlmrx/7VaNrJiw= Received: by 10.213.110.4 with SMTP id l4mr3663971ebp.81.1257792419919; Mon, 09 Nov 2009 10:46:59 -0800 (PST) Received: from debian.bg45.phnet (gprs01.swisscom-mobile.ch [193.247.250.1]) by mx.google.com with ESMTPS id 24sm7251233eyx.21.2009.11.09.10.46.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 09 Nov 2009 10:46:58 -0800 (PST) Message-ID: <4AF86387.7090307@gmail.com> Date: Mon, 09 Nov 2009 19:46:31 +0100 From: Vladimir 'phcoder' Serbinenko User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: The development of GNU GRUB References: <20091109010422.GA23417@thorin> <4AF81E2C.2090700@gmail.com> <4AF82868.6090803@gmail.com> <4AF85568.7080105@duboucher.eu> <20091109181010.GA7372@thorin> <4AF85C54.3080302@gmail.com> <20091109182518.GA14767@thorin> In-Reply-To: X-Enigmail-Version: 0.95.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigFBE9BB1A069893CB60EB7A28" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: Imminent bugfix release (1.97.1) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2009 18:47:07 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFBE9BB1A069893CB60EB7A28 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Bean wrote: > On Tue, Nov 10, 2009 at 2:25 AM, Robert Millan wrote:= > =20 >> On Mon, Nov 09, 2009 at 07:15:48PM +0100, Vladimir 'phcoder' Serbinenk= o wrote: >> =20 >>> Robert Millan wrote: >>> =20 >>>> Actually, modern CPUs are very complex and the number of operations = (or >>>> time taken by them) isn't easy to predict. >>>> >>>> >>>> =20 >>> It's generally a good practice to do exactly same operations >>> independently of result just store the result in a separate variable >>> it's how RSA is correctly implemented >>> >>> for (n =3D grub_strlen (s1); n >=3D 0; n--) >>> { >>> if (*s1 !=3D *s2) >>> ret |=3D 1; >>> else >>> ret |=3D 0; >>> =20 >> Uhm I didn't check, but I'd suspect -Os would optimize this out. >> >> Anyhow, if we move the fixed time wait to the outer loop, it should no= >> longer be a problem. >> >> We could also check the approach taken by e.g. su from coreutils. >> =20 > > Hi, > > How about this one: > > int > grub_auth_strcmp (const char *s1, const char *s2) > { > int result =3D 0; > > for (; *s1 !=3D 0; s1++, s2++) > result +=3D (*s1 !=3D *s2); > > return (result !=3D 0); > } > > > =20 Welcome to club: try it with "abc", "abcdef" They will match :(. Exactly the same problem as with my code but I like the approach. Perhaps: int grub_auth_strcmp (const char *s1, const char *s2) { int result =3D 0; for (; *s1 !=3D 0; s1++, s2++) result +=3D (*s1 !=3D *s2); return !(result =3D=3D 0 && *s2 =3D=3D 0); } --=20 Regards Vladimir 'phcoder' Serbinenko --------------enigFBE9BB1A069893CB60EB7A28 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iF4EAREKAAYFAkr4Y58ACgkQNak7dOguQgnJSAD9Fhgr14B0JwAWOhgQgAh1lQj6 OI4vQqEfZ/BUMxTOGgQA/Riy9NtngPHv1M6uSuzdrzMsREgfyxvRsVKi7NbgqHP4 =2zkC -----END PGP SIGNATURE----- --------------enigFBE9BB1A069893CB60EB7A28--