diff options
author | Simon Warta <[email protected]> | 2015-07-22 00:15:55 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-07-24 10:33:40 +0200 |
commit | e5e8635ab5e21991e890b229c9c563ffeec2db31 (patch) | |
tree | 3f8e34c177b46ac95706958f9d84dfa8cdcd1783 /src/lib/math/bigint/big_rand.cpp | |
parent | 10883bb5b8fb2804b9af08c7cfe9f869be811d0b (diff) |
Refactor BigInt
Diffstat (limited to 'src/lib/math/bigint/big_rand.cpp')
-rw-r--r-- | src/lib/math/bigint/big_rand.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/math/bigint/big_rand.cpp b/src/lib/math/bigint/big_rand.cpp index ab66c6cdd..074c368e0 100644 --- a/src/lib/math/bigint/big_rand.cpp +++ b/src/lib/math/bigint/big_rand.cpp @@ -7,6 +7,7 @@ #include <botan/bigint.h> #include <botan/parsing.h> +#include <botan/internal/rounding.h> namespace Botan { @@ -19,15 +20,18 @@ void BigInt::randomize(RandomNumberGenerator& rng, set_sign(Positive); if(bitsize == 0) + { clear(); + } else { - secure_vector<byte> array = rng.random_vec((bitsize + 7) / 8); + secure_vector<byte> array = rng.random_vec(round_up(bitsize, 8) / 8); if(bitsize % 8) array[0] &= 0xFF >> (8 - (bitsize % 8)); array[0] |= 0x80 >> ((bitsize % 8) ? (8 - bitsize % 8) : 0); - binary_decode(array.data(), array.size()); + + binary_decode(array); } } |