[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: New function: consttime_memcmp(3)
On Mon, Mar 16, 2015 at 01:58:19AM +0100, Kamil Rytarowski wrote:
> I'm attaching a patch against current adding a new libc and
> kernel function: consttime_memcmp(3). The code is borrowed
> from OpenBSD timingsafe_memcmp(3) .
> consttime_memcmp(3) is similar to memcmp(3) with timing safe layer.
> For details please see below at the preprocessed man-page.
> The patch is modeled after consttime_memequal(3).
> Please review and import into .Nx 8.
Well, djb's NaCl implementation, which should probably be referred to
as the reference implementation, has the return statement codified as:
return (int)(1 & ((ret - 1) >> 8)) - 1;
Various people have tried to decide why it was done this way, but, in
any case, trying to second guess optimisers, compilers or djb is not
my idea of fun, so I'll just leave it at that.
Main Index |
Thread Index |