From: Bean <bean123ch@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: Imminent bugfix release (1.97.1)
Date: Tue, 10 Nov 2009 22:47:05 +0800 [thread overview]
Message-ID: <ca0f59980911100647l5349f861g28bcc4d1df864948@mail.gmail.com> (raw)
In-Reply-To: <4AF977DD.5090801@duboucher.eu>
On Tue, Nov 10, 2009 at 10:25 PM, Duboucher Thomas <thomas@duboucher.eu> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Bean a écrit :
>> 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)
>> {
>> char r1 = 0;
>> char r2 = 0;
>> char *p;
>> int i, c;
>>
>> p = &r1;
>> c = 0;
>> for (i = 0; i < sizeof (grub_password_t); i++, s1++, s2++)
>> {
>> *p | = (*s1 ^ *s2);
>> if ((int) *s1 == c)
>> {
>> p = &r2;
>> c = 0x100;
>> }
>> }
>>
>> return (r1 != 0);
>> }
>>
>> The condition (int) *s1 == c would be true exactly once.
>>
>
> Well, it seems I lost something somewhere. I don'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)
> {
> int retval, it;
>
> for (it = retval = 0; it < PASSPHRASE_MAXSIZE; it++, input++, key++)
> {
> retval |= (*input != *key);
>
> if (*input == '\0')
> break;
> }
>
> return !retval;
> }
>
> Also, take care that it requires to check how the function is
> optimized; sometimes you have surprises ... ;)
Hi,
My previous function ensures that execution time is the same
regardless of the input. Although it's not necessary, I guess it's a
nice feature to have. BTW, the simpler function does leak one
information, the size of buffer as the execution time would increase
until the buffer size is reached.
--
Bean
My repository: https://launchpad.net/burg
Document: https://help.ubuntu.com/community/Burg
next prev parent reply other threads:[~2009-11-10 14:47 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-09 1:04 Imminent bugfix release (1.97.1) Robert Millan
2009-11-09 1:27 ` Robert Millan
2009-11-09 2:08 ` Jordan Uggla
2009-11-09 14:15 ` Robert Millan
2009-11-09 13:33 ` Bean
2009-11-09 13:50 ` Vladimir 'phcoder' Serbinenko
2009-11-09 14:18 ` Robert Millan
2009-11-09 14:21 ` Bean
2009-11-09 14:34 ` Vladimir 'phcoder' Serbinenko
2009-11-09 17:46 ` Duboucher Thomas
2009-11-09 18:10 ` Robert Millan
2009-11-09 18:15 ` Vladimir 'phcoder' Serbinenko
2009-11-09 18:25 ` Robert Millan
2009-11-09 18:36 ` Bean
2009-11-09 18:46 ` Vladimir 'phcoder' Serbinenko
2009-11-09 18:49 ` Bean
2009-11-09 21:13 ` Duboucher Thomas
2009-11-09 21:34 ` Vladimir 'phcoder' Serbinenko
2009-11-09 21:43 ` Duboucher Thomas
2009-11-09 22:06 ` Robert Millan
2009-11-09 22:46 ` Duboucher Thomas
2009-11-09 23:09 ` Darron Black
2009-11-09 23:50 ` richardvoigt
2009-11-09 23:56 ` Darron Black
2009-11-09 23:46 ` richardvoigt
2009-11-10 5:39 ` Bean
2009-11-10 8:28 ` Bean
2009-11-10 8:46 ` Bean
2009-11-10 8:52 ` Bean
2009-11-10 9:05 ` Bean
2009-11-10 12:37 ` Bean
2009-11-10 14:25 ` Duboucher Thomas
2009-11-10 14:47 ` Bean [this message]
2009-11-10 17:43 ` Duboucher Thomas
2009-11-10 19:01 ` Vladimir 'phcoder' Serbinenko
2009-11-10 19:04 ` Vladimir 'phcoder' Serbinenko
2009-11-10 21:29 ` Duboucher Thomas
2009-11-10 15:27 ` richardvoigt
2009-11-10 17:38 ` Duboucher Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ca0f59980911100647l5349f861g28bcc4d1df864948@mail.gmail.com \
--to=bean123ch@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.