summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMichael Brown2018-03-20 19:42:39 +0100
committerMichael Brown2018-03-20 19:56:01 +0100
commit0d35411f88dd37dda755d52b4549337f8299c698 (patch)
tree9129fb0cee236f97af83024b5910cb2cb2b83b08 /src/crypto
parent[golan] Set log_max_qp to 1 (diff)
downloadipxe-0d35411f88dd37dda755d52b4549337f8299c698.tar.gz
ipxe-0d35411f88dd37dda755d52b4549337f8299c698.tar.xz
ipxe-0d35411f88dd37dda755d52b4549337f8299c698.zip
[rng] Use fixed-point calculations for min-entropy quantities
We currently perform various min-entropy calculations using build-time floating-point arithmetic. No floating-point code ends up in the final binary, since the results are eventually converted to integers and asserted to be compile-time constants. Though this mechanism is undoubtedly cute, it inhibits us from using "-mno-sse" to prevent the use of SSE registers by the compiler. Fix by using fixed-point arithmetic instead. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/entropy.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crypto/entropy.c b/src/crypto/entropy.c
index 5acbc025..ced6fd92 100644
--- a/src/crypto/entropy.c
+++ b/src/crypto/entropy.c
@@ -70,7 +70,8 @@ repetition_count_cutoff ( void ) {
* where W is set at 2^(-30) (in ANS X9.82 Part 2 (October
* 2011 Draft) Section 8.5.2.1.3.1).
*/
- max_repetitions = ( 1 + ( 30 / min_entropy_per_sample() ) );
+ max_repetitions = ( 1 + ( MIN_ENTROPY ( 30 ) /
+ min_entropy_per_sample() ) );
/* Round up to a whole number of repetitions. We don't have
* the ceil() function available, so do the rounding by hand.
@@ -237,7 +238,7 @@ adaptive_proportion_cutoff ( void ) {
/* Look up cutoff value in cutoff table */
n = ADAPTIVE_PROPORTION_WINDOW_SIZE;
- h = min_entropy_per_sample();
+ h = ( min_entropy_per_sample() / MIN_ENTROPY_SCALE );
cutoff = adaptive_proportion_cutoff_lookup ( n, h );
/* Fail unless cutoff value is a build-time constant */