aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint/big_rand.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-13 15:54:50 +0000
committerlloyd <[email protected]>2010-09-13 15:54:50 +0000
commit36bfef27271eadffefbc6891a9d7fa7eed7b1e10 (patch)
tree81fe9b37bb580cedba5bb25ac04dfecdd36b18de /src/math/bigint/big_rand.cpp
parent4a7e9edcc92b08a285ea24549fd8c813d10b63b9 (diff)
More vector->pointer conversion removals.
Add RandomNumberGenerator::random_vec, which takes an length n and returns a new SecureVector with randomized contents of that size. This nicely covers most of the cases where randomize was being called on a vector, and is a little cleaner in the code as well, instead of vec.resize(length); rng.randomize(&vec[0], vec.size()); we just write vec = rng.random_vec(length);
Diffstat (limited to 'src/math/bigint/big_rand.cpp')
-rw-r--r--src/math/bigint/big_rand.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/math/bigint/big_rand.cpp b/src/math/bigint/big_rand.cpp
index b641baee2..84ad02587 100644
--- a/src/math/bigint/big_rand.cpp
+++ b/src/math/bigint/big_rand.cpp
@@ -35,8 +35,8 @@ void BigInt::randomize(RandomNumberGenerator& rng,
clear();
else
{
- SecureVector<byte> array((bitsize + 7) / 8);
- rng.randomize(array, array.size());
+ SecureVector<byte> array = rng.random_vec((bitsize + 7) / 8);
+
if(bitsize % 8)
array[0] &= 0xFF >> (8 - (bitsize % 8));
array[0] |= 0x80 >> ((bitsize % 8) ? (8 - bitsize % 8) : 0);