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/pk_pad | |
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/pk_pad')
-rw-r--r-- | src/pk_pad/eme1/eme1.cpp | 2 | ||||
-rw-r--r-- | src/pk_pad/emsa4/emsa4.cpp | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp index 84fcf4b83..b695fc2c4 100644 --- a/src/pk_pad/eme1/eme1.cpp +++ b/src/pk_pad/eme1/eme1.cpp @@ -26,7 +26,7 @@ SecureVector<byte> EME1::pad(const byte in[], u32bit in_length, SecureVector<byte> out(key_length); - rng.randomize(out, HASH_LENGTH); + rng.randomize(&out[0], HASH_LENGTH); out.copy(HASH_LENGTH, Phash, Phash.size()); out[out.size() - in_length - 1] = 0x01; diff --git a/src/pk_pad/emsa4/emsa4.cpp b/src/pk_pad/emsa4/emsa4.cpp index 41b1e6971..b056d7c27 100644 --- a/src/pk_pad/emsa4/emsa4.cpp +++ b/src/pk_pad/emsa4/emsa4.cpp @@ -43,8 +43,7 @@ SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg, const u32bit output_length = (output_bits + 7) / 8; - SecureVector<byte> salt(SALT_SIZE); - rng.randomize(salt, SALT_SIZE); + SecureVector<byte> salt = rng.random_vec(SALT_SIZE); for(u32bit j = 0; j != 8; ++j) hash->update(0); |