Skip to content

Commit

Permalink
Don't inline Null_RNG::fill_bytes_with_input
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed Nov 7, 2023
1 parent 4fb6ec9 commit 723fa3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/lib/rng/rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,12 @@ void RandomNumberGenerator::reseed_from_rng(RandomNumberGenerator& rng, size_t p
}
}

void Null_RNG::fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> /* ignored */) {
// throw if caller tries to obtain random bytes
if(!output.empty()) {
abort();
throw PRNG_Unseeded("Null_RNG called");
}
}

} // namespace Botan
7 changes: 1 addition & 6 deletions src/lib/rng/rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,7 @@ class BOTAN_PUBLIC_API(2, 0) Null_RNG final : public RandomNumberGenerator {
std::string name() const override { return "Null_RNG"; }

private:
void fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> /* ignored */) override {
// throw if caller tries to obtain random bytes
if(!output.empty()) {
throw PRNG_Unseeded("Null_RNG called");
}
}
void fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> /* ignored */) override;
};

} // namespace Botan
Expand Down

0 comments on commit 723fa3a

Please sign in to comment.