Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7scx-0006J7-6B for mharc-grub-devel@gnu.org; Tue, 10 Nov 2009 10:27:27 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7scv-0006Io-6r for grub-devel@gnu.org; Tue, 10 Nov 2009 10:27:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7scq-0006Hn-9E for grub-devel@gnu.org; Tue, 10 Nov 2009 10:27:24 -0500 Received: from [199.232.76.173] (port=38230 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7scp-0006Hb-U5 for grub-devel@gnu.org; Tue, 10 Nov 2009 10:27:20 -0500 Received: from gv-out-0910.google.com ([216.239.58.190]:7186) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N7scm-0002I3-Ha for grub-devel@gnu.org; Tue, 10 Nov 2009 10:27:17 -0500 Received: by gv-out-0910.google.com with SMTP id c6so8835gvd.17 for ; Tue, 10 Nov 2009 07:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=QMJW3YjMJFV9MRT7FyV0b/lSORXmYPPgPU5Ch109PAg=; b=ceHag9NySeKLlLT6yseQsXUYxeIrK6tbCf/NVIbJPeMrkqKMApFoNuX37r0xgbA/CW Cg8vQax3VuW4wVG2Tuba4FPZcSZWoH8ibqu11X7FVbn7C3drivZIOj3EJaH+A6agzza5 HCPO2J725lAi+KjOj4pMVrUfvzdMk9oH11758= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=T+CoJeJ4+xgkXiPIqPqO8ErrGIfixVBVH/Hs9NJS4/0UrHrXslKgYxSBbyS3lCajFi DJJC8+r/hNK0tDIifjRic9LgQmUVavpdIII5k4/z6Xq3xm0cUrPn5cWe/3p27QoSm//e fQwvNsviouO2kk6M4ydgPvoZxEXxS+/Je7kHE= MIME-Version: 1.0 Received: by 10.239.145.11 with SMTP id q11mr22669hba.98.1257866828940; Tue, 10 Nov 2009 07:27:08 -0800 (PST) In-Reply-To: <4AF977DD.5090801@duboucher.eu> References: <20091109010422.GA23417@thorin> <4AF885EE.7000709@duboucher.eu> <4AF88AEF.8010102@gmail.com> <4AF977DD.5090801@duboucher.eu> Date: Tue, 10 Nov 2009 09:27:08 -0600 Message-ID: <2e59e6970911100727w2373bedch7691bd8d15edf646@mail.gmail.com> From: "richardvoigt@gmail.com" To: The development of GNU GRUB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Tue, 10 Nov 2009 15:27:25 -0000 On Tue, Nov 10, 2009 at 8:25 AM, Duboucher Thomas wro= te: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Bean a =C3=A9crit : >> Hi, >> >> Oh, I just come up with a better way to do this: >> >> typedef char grub_password_t[1024]; >> >> int >> grub_auth_strcmp (const grub_password_t s1, const grub_password_t s2) >> { >> =C2=A0char r1 =3D 0; >> =C2=A0char r2 =3D 0; >> =C2=A0char *p; >> =C2=A0int i, c; >> >> =C2=A0p =3D &r1; >> =C2=A0c =3D 0; >> =C2=A0for (i =3D 0; i < sizeof (grub_password_t); i++, s1++, s2++) >> =C2=A0 =C2=A0{ >> =C2=A0 =C2=A0 =C2=A0*p | =3D (*s1 ^ *s2); >> =C2=A0 =C2=A0 =C2=A0if ((int) *s1 =3D=3D c) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0{ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0p =3D &r2; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0c =3D 0x100; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0 =C2=A0} >> >> =C2=A0return (r1 !=3D 0); >> } >> >> The condition (int) *s1 =3D=3D c would be true exactly once. >> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0Well, it seems I lost something somewhere. I d= on't understand the need > of doing it exactly sizeof (grub_password_t) times, except from having a > perfectly symetric function. IMHO, stopping the comparison when the > input buffer is done reading, or when the maximum size of a passphrase > is reached does not leak any information to the attacker. So I would > stick to > > typedef char grub_password_t[1024]; > > int > auth_strcmp (const grub_password_t input, grub_password_t key) > { > =C2=A0int retval, it; > > =C2=A0for (it =3D retval =3D 0; it < PASSPHRASE_MAXSIZE; it++, input++, k= ey++) After changing the parameter type, those postincrements won't do what you expect. > =C2=A0{ > =C2=A0 =C2=A0retval |=3D (*input !=3D *key); > > =C2=A0 =C2=A0if (*input =3D=3D '\0') > =C2=A0 =C2=A0 =C2=A0break; > =C2=A0} > > =C2=A0return !retval; > } > > =C2=A0 =C2=A0 =C2=A0 =C2=A0Also, take care that it requires to check how = the function is > optimized; sometimes you have surprises ... ;) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0Thomas. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkr5d90ACgkQBV7eXqefhqio+QCfba54+l45DiQNyI3IzfnwgvVe > tbUAnRTPI+yYSZoVZLfM9fze7c7cvRQN > =3DEjYS > -----END PGP SIGNATURE----- > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel >