On Sat, 2017-05-20 at 22:19 +0200, Niels Möller wrote:
> 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 */
Would make an function call though, but I guess that shouldn't matter.
> 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);
> }
I'm fine with that. Do you want me to post an updated patch or would
you modify it?
regards,
Nikos
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs