aboutsummaryrefslogtreecommitdiffstats
path: root/src/rng
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/rng
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/rng')
-rw-r--r--src/rng/rng.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/rng/rng.h b/src/rng/rng.h
index 687f98d13..e024eeb59 100644
--- a/src/rng/rng.h
+++ b/src/rng/rng.h
@@ -32,6 +32,13 @@ class BOTAN_DLL RandomNumberGenerator
*/
virtual void randomize(byte output[], u32bit length) = 0;
+ SecureVector<byte> random_vec(u32bit bytes)
+ {
+ SecureVector<byte> output(bytes);
+ randomize(&output[0], output.size());
+ return output;
+ }
+
/**
* Return a random byte
* @return random byte