tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: New function: consttime_memcmp(3)



>> Well, djb's [...]

>>        return (int)(1 & ((ret - 1) >> 8)) - 1;

> The purpose of that expression is to map zero ret to 0 and nonzero
> ret to -1 without conditionals,

Since it's been taken rather drastically out of its context, it might
be a good idea to point out, for the benefit of anyone considering
copying it, that it does that only if ret is no greater than 256, and
even then only if ret is unsigned or the implementation handles right
shifts of negative signed integers the way it expects.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index