[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <532AA307.504@ladisch.de>
Date: Thu, 20 Mar 2014 09:12:55 +0100
From: Clemens Ladisch <clemens@...isch.de>
To: Stephan Mueller <smueller@...onox.de>,
linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org
CC: aquini@...hat.com, jeremy.wayne.powell@...il.com
Subject: Re: [PATCH v2 1/6] SP800-90A Deterministic Random Bit Generator
Stephan Mueller wrote:
> This is a clean-room implementation of the DRBG defined in SP800-90A.
Why? I guess it's for certification?
> +static bool drbg_fips_continuous_test(struct drbg_state *drbg,
> + unsigned char *buf)
> ...
> + ret = memcmp(drbg->prev, buf, drbg_blocklen(drbg));
> + ...
> + /* invert the memcmp result, because the test shall pass when the
> + * two compared values do not match */
> + if (ret)
> + return true;
> + else
> + return false;
This looks strange. The return value of memcmp() is not really
a boolean, and the code appears not to match the comment because the
numeric value of ret is not actually inverted. How about this:
ret = memcmp(...);
...
/* the test shall pass when the compared values are not equal */
return ret != 0;
Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists