[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gc-pbkdf2-sha1
From: |
Simon Josefsson |
Subject: |
Re: gc-pbkdf2-sha1 |
Date: |
Thu, 13 Oct 2005 10:15:06 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
Paul Eggert <address@hidden> writes:
> 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.
Right, I have installed Bruno's version. Thanks!