Skip to content

Feature: Generalization of RandomNumberGenerator::random_vec()#3201

Merged
reneme merged 3 commits intomasterfrom
feature/random_vec_with_span
Jan 20, 2023
Merged

Feature: Generalization of RandomNumberGenerator::random_vec()#3201
reneme merged 3 commits intomasterfrom
feature/random_vec_with_span

Conversation

@reneme
Copy link
Copy Markdown
Collaborator

@reneme reneme commented Jan 20, 2023

This is a spin-off from #3195 to harvest the low-hanging fruit. Namely, allowing to use RNG::random_vec() with arbitrary contiguous byte buffers.

Example usage (e.g. as desired in #3150):

// generate a random TLS Session ID
using Session_ID = Botan::Strong<std::vector<uint8_t>, struct Session_ID_>;
const auto random_id = rng.random_vec<Session_ID>(32);

// filling an arbitrary buffer with random bytes
std::array<uint8_t, 32> buffer;
rng.random_vec(buffer);

@reneme reneme changed the title Feature: RandomNumberGenerator::random_vec() uses std::span Feature: Generalization of RandomNumberGenerator::random_vec() Jan 20, 2023
Copy link
Copy Markdown
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is fine

@reneme reneme merged commit d17c9c1 into master Jan 20, 2023
@reneme reneme deleted the feature/random_vec_with_span branch January 20, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants