diff options
author | lloyd <[email protected]> | 2010-09-13 15:54:50 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 15:54:50 +0000 |
commit | 36bfef27271eadffefbc6891a9d7fa7eed7b1e10 (patch) | |
tree | 81fe9b37bb580cedba5bb25ac04dfecdd36b18de /src/pubkey | |
parent | 4a7e9edcc92b08a285ea24549fd8c813d10b63b9 (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/pubkey')
-rw-r--r-- | src/pubkey/keypair/keypair.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/pubkey/keypair/keypair.cpp b/src/pubkey/keypair/keypair.cpp index c837bc1f6..857a5328a 100644 --- a/src/pubkey/keypair/keypair.cpp +++ b/src/pubkey/keypair/keypair.cpp @@ -29,8 +29,8 @@ bool encryption_consistency_check(RandomNumberGenerator& rng, if(encryptor.maximum_input_size() == 0) return true; - SecureVector<byte> plaintext(encryptor.maximum_input_size() - 1); - rng.randomize(plaintext, plaintext.size()); + SecureVector<byte> plaintext = + rng.random_vec(encryptor.maximum_input_size() - 1); SecureVector<byte> ciphertext = encryptor.encrypt(plaintext, rng); if(ciphertext == plaintext) @@ -51,8 +51,7 @@ bool signature_consistency_check(RandomNumberGenerator& rng, PK_Signer signer(key, padding); PK_Verifier verifier(key, padding); - SecureVector<byte> message(16); - rng.randomize(message, message.size()); + SecureVector<byte> message = rng.random_vec(16); SecureVector<byte> signature; |