Avoid negating unsigned values

This commit is contained in:
Frank Denis
2017-02-20 21:12:33 +01:00
parent 40b4462239
commit f5673c7cc0
+1 -1
View File
@@ -140,7 +140,7 @@ randombytes_uniform(const uint32_t upper_bound)
if (upper_bound < 2) {
return 0;
}
min = (uint32_t) (-upper_bound % upper_bound);
min = (1U + ~upper_bound) % upper_bound;
do {
r = randombytes_random();
} while (r < min);