Nikos Mavrogiannopoulos <[email protected]> writes:
> On Tue, 2017-05-16 at 22:47 +0200, Niels Möller wrote:
>
>> > + while(left > 0) {
>> > + /* T(i) */
>> > + set_key(mac_ctx, prk_size, prk);
>> > + if (started != 0) {
>> > + update(mac_ctx, digest_size, Ttmp);
>> > + } else {
>> > + started = 1;
>> > + }
>> > + if (info_size)
>> > + update(mac_ctx, info_size, info);
>> > + update(mac_ctx, 1, &i);
>> > +
>> > + if (left < digest_size)
>> > + digest_size = left;
>> > +
>> > + digest(mac_ctx, digest_size, dst);
>> > + Ttmp = dst;
>> > +
>> > + left -= digest_size;
>> > + dst += digest_size;
>> > + i++;
>> > + }
>>
>> I think this loop would clearer if Ttmp was replaced by (dst -
>> digest_size), and maybe it would make sense to take out the first
>> and/or final iterations.
>
> Patch 0005 unrolls the first loop and does that change. I find that
> longer and not as easy to follow, but I may have not caught what you
> meant.
I was thinking of something like
if (!length)
return;
for (;; dst += digest_size, length -= digest_size, i++)
{
update(mac_ctx, info_size, info); /* info_size == 0 should work fine */
update(mac_ctx, 1, &i);
if (left <= digest_size)
{
digest(mac_ctx, left, dst);
return;
}
digest(max_ctx, digest_size, dst);
update(mac_ctx, digest_size, dst);
}
Regards,
/Niels
--
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs