[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gc-pbkdf2-sha1
From: |
Paul Eggert |
Subject: |
Re: gc-pbkdf2-sha1 |
Date: |
Wed, 12 Oct 2005 14:37:16 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Simon Josefsson <address@hidden> writes:
> Bruno Haible <address@hidden> writes:
>
>> Simon Josefsson wrote:
>>
>>> + l = dkLen / hLen;
>>> + if (dkLen % hLen)
>>> + l++;
>>
>> An equivalent but faster code is:
>>
>> l = ((dkLen - 1) / hLen) + 1;
>
> Perhaps for clarity we could change it into:
>
> #define CEIL_DIV(a,b) (((a) - 1) / (b)) + 1
> l = CEIL_DIV (dkLen, hLen);
>
> What do you think?
That implementation of CEIL_DIV doesn't work in general, e.g., if
dkLen has the minimum value for its type. So I wouldn't use it, at
least not without a comment saying that it's not safe in general.
Bruno's rewrite is safe because dkLen cannot possibly be zero here.